New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SR-8317] crash when using C struct #50845
Comments
Here's the definition of the AVFilter struct that's not working: https://www.ffmpeg.org/doxygen/3.3/avfilter_8h_source.html#l00144. I don't see anything obviously suspicious there, but maybe some of those fields are forward-declared structs, and that messes things up? @swift-ci create |
I wasn't able to reproduce this with Swift 4.1 and ffmpeg 4.0.2's headers. What version were you using? |
Comment by sunlubo (JIRA) sun$ swift --version sun$ ffmpeg -version |
Comment by sunlubo (JIRA) When I use the toolchain downloaded from swift.org, I get this info: Assertion failed: (offset >= NextOffset && "adding fields out of order"), function addField, file /Users/buildnode/jenkins/workspace/oss-swift-4.1-package-osx/swift/lib/IRGen/GenStruct.cpp, line 751. ... Stack dump: 1. While converting type 'AVFilterLink' |
That certainly sounds like the forward declaration thing. Thanks. |
Comment by sunlubo (JIRA) minimal example can reproduce: #ifndef filter_h
#define filter_h
#include <stdio.h>
typedef struct AVFilterContext AVFilterContext;
typedef struct AVFilterLink AVFilterLink;
struct AVFilterContext {
AVFilterLink **inputs;
};
struct AVFilterLink {
AVFilterContext *src;
// comment out this declaration, everything is okay.
enum {
AVLINK_UNINIT = 0,
AVLINK_STARTINIT,
AVLINK_INIT
} init_state;
int age_index;
};
#endif /* filter_h */ public final class FilterContext {
internal let ctxPtr: UnsafeMutablePointer<AVFilterContext>
internal init(ctxPtr: UnsafeMutablePointer<AVFilterContext>) {
self.ctxPtr = ctxPtr
}
} |
Thank you! Hadn't gotten around to doing that myself yet. |
Attachment: Download
Environment
OS: 10.13.5 (17F77)
Swift: Apple Swift version 4.1.2 (swiftlang-902.0.54 clang-902.0.39.2)
Target: x86_64-apple-darwin17.6.0
Additional Detail from JIRA
md5: 94066004643974004a66e6039ec9f8f6
duplicates:
Issue Description:
Use attachments can produce.
Stack Trace:
0 swift 0x0000000103ff4fea PrintStackTraceSignalHandler(void*) + 42
1 swift 0x0000000103ff43a6 SignalHandler(int) + 966
2 libsystem_platform.dylib 0x00007fff72d9df5a _sigtramp + 26
3 libsystem_platform.dylib 0x0000000000000070 _sigtramp + 2368086320
4 swift 0x00000001007cada8 swift::irgen::TypeConverter::convertStructType(swift::TypeBase*, swift::CanType, swift::StructDecl*) + 1752
5 swift 0x00000001007e8271 swift::irgen::TypeConverter::convertAnyNominalType(swift::CanType, swift::NominalTypeDecl*) + 465
6 swift 0x00000001007e7664 swift::irgen::TypeConverter::getTypeEntry(swift::CanType) + 1060
7 swift 0x00000001007ec0b5 addValueWitnessesForAbstractType(swift::irgen::IRGenModule&, swift::irgen::ConstantArrayBuilder&, swift::CanType, bool&) + 293
8 swift 0x00000001007ebc9a swift::irgen::emitValueWitnessTable(swift::irgen::IRGenModule&, swift::CanType) + 234
9 swift 0x0000000100784cab swift::irgen::IRGenModule::getAddrOfForeignTypeMetadataCandidate(swift::CanType) + 1771
10 swift 0x00000001007843a8 emitForeignTypeMetadataRef(swift::irgen::IRGenFunction&, swift::CanType) + 24
11 swift 0x0000000100783f3f llvm::Value* llvm::function_ref<llvm::Value* (swift::irgen::IRGenFunction&, llvm::Constant*)>::callback_fn<getTypeMetadataAccessFunction(swift::irgen::IRGenModule&, swift::CanType, swift::ForDefinition_t)::$_3>(long, swift::irgen::IRGenFunction&, llvm::Constant*) + 479
12 swift 0x0000000100780e85 swift::irgen::emitLazyCacheAccessFunction(swift::irgen::IRGenModule&, llvm::Function*, llvm::GlobalVariable*, llvm::function_ref<llvm::Value* (swift::irgen::IRGenFunction&)> const&) + 1989
13 swift 0x000000010078432a getTypeMetadataAccessFunction(swift::irgen::IRGenModule&, swift::CanType, swift::ForDefinition_t, llvm::function_ref<llvm::Value* (swift::irgen::IRGenFunction&, llvm::Constant*)>&&) + 922
14 swift 0x0000000100783b75 emitCallToTypeMetadataAccessFunction(swift::irgen::IRGenFunction&, swift::CanType, swift::ForDefinition_t) + 117
15 swift 0x00000001007814f5 swift::irgen::IRGenFunction::emitTypeMetadataRef(swift::CanType) + 533
16 swift 0x000000010078c490 void llvm::function_ref<void (unsigned int, swift::CanType, llvm::Optional<swift::ProtocolConformanceRef>)>::callback_fn<(anonymous namespace)::GenericArguments::collect(swift::irgen::IRGenFunction&, swift::CanType)::'lambda'(unsigned int, swift::CanType, llvm::Optional<swift::ProtocolConformanceRef>)>(long, unsigned int, swift::CanType, llvm::Optional<swift::ProtocolConformanceRef>) + 80
17 swift 0x00000001007c14be swift::irgen::GenericTypeRequirements::enumerateFulfillments(swift::irgen::IRGenModule&, swift::SubstitutionMap const&, llvm::function_ref<void (unsigned int, swift::CanType, llvm::Optional<swift::ProtocolConformanceRef>)>) + 366
18 swift 0x000000010078b56f emitNominalMetadataRef(swift::irgen::IRGenFunction&, swift::NominalTypeDecl*, swift::CanType) + 479
19 swift 0x000000010078161e emitDirectTypeMetadataRef(swift::irgen::IRGenFunction&, swift::CanType) + 238
20 swift 0x0000000100783f4c llvm::Value* llvm::function_ref<llvm::Value* (swift::irgen::IRGenFunction&, llvm::Constant*)>::callback_fn<getTypeMetadataAccessFunction(swift::irgen::IRGenModule&, swift::CanType, swift::ForDefinition_t)::$_3>(long, swift::irgen::IRGenFunction&, llvm::Constant*) + 492
21 swift 0x0000000100780e85 swift::irgen::emitLazyCacheAccessFunction(swift::irgen::IRGenModule&, llvm::Function*, llvm::GlobalVariable*, llvm::function_ref<llvm::Value* (swift::irgen::IRGenFunction&)> const&) + 1989
22 swift 0x000000010078432a getTypeMetadataAccessFunction(swift::irgen::IRGenModule&, swift::CanType, swift::ForDefinition_t, llvm::function_ref<llvm::Value* (swift::irgen::IRGenFunction&, llvm::Constant*)>&&) + 922
23 swift 0x0000000100783b75 emitCallToTypeMetadataAccessFunction(swift::irgen::IRGenFunction&, swift::CanType, swift::ForDefinition_t) + 117
24 swift 0x00000001007814f5 swift::irgen::IRGenFunction::emitTypeMetadataRef(swift::CanType) + 533
25 swift 0x000000010078c490 void llvm::function_ref<void (unsigned int, swift::CanType, llvm::Optional<swift::ProtocolConformanceRef>)>::callback_fn<(anonymous namespace)::GenericArguments::collect(swift::irgen::IRGenFunction&, swift::CanType)::'lambda'(unsigned int, swift::CanType, llvm::Optional<swift::ProtocolConformanceRef>)>(long, unsigned int, swift::CanType, llvm::Optional<swift::ProtocolConformanceRef>) + 80
26 swift 0x00000001007c14be swift::irgen::GenericTypeRequirements::enumerateFulfillments(swift::irgen::IRGenModule&, swift::SubstitutionMap const&, llvm::function_ref<void (unsigned int, swift::CanType, llvm::Optional<swift::ProtocolConformanceRef>)>) + 366
27 swift 0x000000010078b56f emitNominalMetadataRef(swift::irgen::IRGenFunction&, swift::NominalTypeDecl*, swift::CanType) + 479
28 swift 0x000000010078161e emitDirectTypeMetadataRef(swift::irgen::IRGenFunction&, swift::CanType) + 238
29 swift 0x0000000100783f4c llvm::Value* llvm::function_ref<llvm::Value* (swift::irgen::IRGenFunction&, llvm::Constant*)>::callback_fn<getTypeMetadataAccessFunction(swift::irgen::IRGenModule&, swift::CanType, swift::ForDefinition_t)::$_3>(long, swift::irgen::IRGenFunction&, llvm::Constant*) + 492
30 swift 0x0000000100780e85 swift::irgen::emitLazyCacheAccessFunction(swift::irgen::IRGenModule&, llvm::Function*, llvm::GlobalVariable*, llvm::function_ref<llvm::Value* (swift::irgen::IRGenFunction&)> const&) + 1989
31 swift 0x000000010078432a getTypeMetadataAccessFunction(swift::irgen::IRGenModule&, swift::CanType, swift::ForDefinition_t, llvm::function_ref<llvm::Value* (swift::irgen::IRGenFunction&, llvm::Constant*)>&&) + 922
32 swift 0x0000000100783b75 emitCallToTypeMetadataAccessFunction(swift::irgen::IRGenFunction&, swift::CanType, swift::ForDefinition_t) + 117
33 swift 0x00000001007814f5 swift::irgen::IRGenFunction::emitTypeMetadataRef(swift::CanType) + 533
34 swift 0x000000010078c490 void llvm::function_ref<void (unsigned int, swift::CanType, llvm::Optional<swift::ProtocolConformanceRef>)>::callback_fn<(anonymous namespace)::GenericArguments::collect(swift::irgen::IRGenFunction&, swift::CanType)::'lambda'(unsigned int, swift::CanType, llvm::Optional<swift::ProtocolConformanceRef>)>(long, unsigned int, swift::CanType, llvm::Optional<swift::ProtocolConformanceRef>) + 80
35 swift 0x00000001007c14be swift::irgen::GenericTypeRequirements::enumerateFulfillments(swift::irgen::IRGenModule&, swift::SubstitutionMap const&, llvm::function_ref<void (unsigned int, swift::CanType, llvm::Optional<swift::ProtocolConformanceRef>)>) + 366
36 swift 0x000000010078b56f emitNominalMetadataRef(swift::irgen::IRGenFunction&, swift::NominalTypeDecl*, swift::CanType) + 479
37 swift 0x000000010078161e emitDirectTypeMetadataRef(swift::irgen::IRGenFunction&, swift::CanType) + 238
38 swift 0x0000000100783f4c llvm::Value* llvm::function_ref<llvm::Value* (swift::irgen::IRGenFunction&, llvm::Constant*)>::callback_fn<getTypeMetadataAccessFunction(swift::irgen::IRGenModule&, swift::CanType, swift::ForDefinition_t)::$_3>(long, swift::irgen::IRGenFunction&, llvm::Constant*) + 492
39 swift 0x0000000100780e85 swift::irgen::emitLazyCacheAccessFunction(swift::irgen::IRGenModule&, llvm::Function*, llvm::GlobalVariable*, llvm::function_ref<llvm::Value* (swift::irgen::IRGenFunction&)> const&) + 1989
40 swift 0x000000010078432a getTypeMetadataAccessFunction(swift::irgen::IRGenModule&, swift::CanType, swift::ForDefinition_t, llvm::function_ref<llvm::Value* (swift::irgen::IRGenFunction&, llvm::Constant*)>&&) + 922
41 swift 0x0000000100783b75 emitCallToTypeMetadataAccessFunction(swift::irgen::IRGenFunction&, swift::CanType, swift::ForDefinition_t) + 117
42 swift 0x00000001007814f5 swift::irgen::IRGenFunction::emitTypeMetadataRef(swift::CanType) + 533
43 swift 0x000000010078c490 void llvm::function_ref<void (unsigned int, swift::CanType, llvm::Optional<swift::ProtocolConformanceRef>)>::callback_fn<(anonymous namespace)::GenericArguments::collect(swift::irgen::IRGenFunction&, swift::CanType)::'lambda'(unsigned int, swift::CanType, llvm::Optional<swift::ProtocolConformanceRef>)>(long, unsigned int, swift::CanType, llvm::Optional<swift::ProtocolConformanceRef>) + 80
44 swift 0x00000001007c14be swift::irgen::GenericTypeRequirements::enumerateFulfillments(swift::irgen::IRGenModule&, swift::SubstitutionMap const&, llvm::function_ref<void (unsigned int, swift::CanType, llvm::Optional<swift::ProtocolConformanceRef>)>) + 366
45 swift 0x000000010078b56f emitNominalMetadataRef(swift::irgen::IRGenFunction&, swift::NominalTypeDecl*, swift::CanType) + 479
46 swift 0x000000010078161e emitDirectTypeMetadataRef(swift::irgen::IRGenFunction&, swift::CanType) + 238
47 swift 0x0000000100783f4c llvm::Value* llvm::function_ref<llvm::Value* (swift::irgen::IRGenFunction&, llvm::Constant*)>::callback_fn<getTypeMetadataAccessFunction(swift::irgen::IRGenModule&, swift::CanType, swift::ForDefinition_t)::$_3>(long, swift::irgen::IRGenFunction&, llvm::Constant*) + 492
48 swift 0x0000000100780e85 swift::irgen::emitLazyCacheAccessFunction(swift::irgen::IRGenModule&, llvm::Function*, llvm::GlobalVariable*, llvm::function_ref<llvm::Value* (swift::irgen::IRGenFunction&)> const&) + 1989
49 swift 0x000000010078432a getTypeMetadataAccessFunction(swift::irgen::IRGenModule&, swift::CanType, swift::ForDefinition_t, llvm::function_ref<llvm::Value* (swift::irgen::IRGenFunction&, llvm::Constant*)>&&) + 922
50 swift 0x0000000100783b75 emitCallToTypeMetadataAccessFunction(swift::irgen::IRGenFunction&, swift::CanType, swift::ForDefinition_t) + 117
51 swift 0x00000001007814f5 swift::irgen::IRGenFunction::emitTypeMetadataRef(swift::CanType) + 533
52 swift 0x000000010070ef36 swift::irgen::IRGenerator::emitLazyDefinitions() + 3542
53 swift 0x00000001007f9ac3 performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::_1::unique_ptr<swift::SILModule, std::_1::default_delete<swift::SILModule> >, llvm::StringRef, llvm::LLVMContext&, swift::SourceFile*, llvm::GlobalVariable**, unsigned int) + 1555
54 swift 0x000000010065526e performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 38110
55 swift 0x000000010064a304 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7908
56 swift 0x00000001005fece5 main + 18917
57 libdyld.dylib 0x00007fff72a8f015 start + 1
The text was updated successfully, but these errors were encountered: