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-89] Segfault importing sqlite3.h from system module #63626
Comments
@benlangmuir is this in your area? |
Didn't reproduce for me in a debug build of ToT swift. Trying the packaged version. |
Doesn't reproduce for me with the packaged version either. My sqlite claims to be the same version as yours too (although I had to modify the path because I don't have it in /usr/include). If you want to be really sure, the hash is $ shasum $sdk/usr/include/sqlite3.h
fdbb76c74b2862301b5a941b77e938df98910c50 |
Comment by Michael Buhot (JIRA) Interesting, works for me when using the SDK path also 😃 Even though the file has the same contents: 192-168-1-104:app mbuhot$ shasum /usr/include/sqlite3.h
fdbb76c74b2862301b5a941b77e938df98910c50 /usr/include/sqlite3.h
192-168-1-104:app mbuhot$ shasum /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/sqlite3.h
fdbb76c74b2862301b5a941b77e938df98910c50 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/sqlite3.h I installed the xcode command line tools to get |
This is probably related to the module maps that come with the /usr/include directories as part of the command line tools package. |
Or one of the other headers. I can reproduce using the command-line-tools. In debug, I get: Assertion failed: ((ID || !Mod) && "asked for module ID for non-local, non-imported module"), function getSubmoduleID, file /Users/blangmuir/src/s/llvm/tools/clang/lib/Serialization/ASTWriter.cpp, line 2350.
0 swift 0x0000000114a47dde llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 46
1 swift 0x0000000114a48229 PrintStackTraceSignalHandler(void*) + 25
2 swift 0x0000000114a449c9 llvm::sys::RunSignalHandlers() + 425
3 swift 0x0000000114a48569 SignalHandler(int) + 345
4 libsystem_platform.dylib 0x00007fff8f58352a _sigtramp + 26
5 swift 0x00000001154ebd3c cmark_strbuf__initbuf + 94235
6 swift 0x0000000114a4824b raise + 27
7 swift 0x0000000114a48302 abort + 18
8 swift 0x0000000114a482e1 __assert_rtn + 129
9 swift 0x00000001114df73d clang::ASTWriter::getSubmoduleID(clang::Module*) + 125 |
Hmm seems to be related to the combination of:
If I manually change the SDK path to "/" then it stops crashing. |
I have the same issue. More information that may help: the issue only happens when I import SQLite through another package (when I build package A which depends on package B which depends on CSQLite). However, the issue is not there when I build the package B directly. |
@groue: the workaround is for the path to sqlite.h in the module.modulemap file to match what's being used as the SDK for your compilation. For example, if you're using -sdk /Applications/Xcode.app/.../MacOSX10.11.sdk, then make sure the module map is looking in /Applications/Xcode.app/.../MacOSX10.11.sdk/usr/include/sqlite.h. |
@benlangmuir Thanks for the tip. It does indeed works, but with hard consequences :-) Here is a real modulemap, and it does not even include support for tvOS, watchOS, or linux: https://github.com/groue/GRDB.swift/blob/v0.57.0/Support/module.modulemap framework module GRDB {
umbrella header "GRDB.h"
export *
module * { export * }
}
module SQLiteMacOSX {
header "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/sqlite3.h"
export *
}
module SQLiteiPhoneOS {
header "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/sqlite3.h"
export *
}
module SQLiteiPhoneSimulator {
header "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/sqlite3.h"
export *
} And in the source code, it's also difficult, because one has to pick up the right module depending on the platform (https://github.com/groue/GRDB.swift/blob/v0.57.0/GRDB/Core/Database.swift): #if os(OSX)
import SQLiteMacOSX
#elseif os(iOS)
#if (arch(i386) || arch(x86_64))
import SQLiteiPhoneSimulator
#else
import SQLiteiPhoneOS
#endif
#endif Not practical, but it works... |
Comment by Stefan Urbanek (JIRA) Still having this issue when importing `Csqlite3` with the following module map: module Csqlite3 [system] {
header "/usr/include/sqlite3.h"
link "sqlite3"
export *
} It fails on `import Csqlite3` with: Assertion failed: ((ID || !Mod) && "asked for module ID for non-local, non-imported module"), function getSubmoduleID, file /Users/buildnode/jenkins/workspace/oss-swift-package-osx/llvm/tools/clang/lib/Serialization/ASTWriter.cpp, line 2377.
0 swift 0x000000010351e54b llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
1 swift 0x000000010351d7d6 llvm::sys::RunSignalHandlers() + 70
2 swift 0x000000010351ec1f SignalHandler(int) + 383
3 libsystem_platform.dylib 0x00007fff9140a52a _sigtramp + 26
4 swift 0x00000001040b03f0 clang::vfs::getNextVirtualUniqueID()::UID + 71992
5 swift 0x000000010351e9f6 abort + 22
6 swift 0x000000010351e9d1 __assert_rtn + 81
7 swift 0x000000010198b402 clang::ASTWriter::WritePreprocessor(clang::Preprocessor const&, bool) + 6210
8 swift 0x00000001019a2150 clang::ASTWriter::WriteASTCore(clang::Sema&, llvm::StringRef, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, clang::Module*) + 9168
9 swift 0x000000010199fd32 clang::ASTWriter::WriteAST(clang::Sema&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, clang::Module*, llvm::StringRef, bool) + 642
10 swift 0x00000001019dc700 clang::PCHGenerator::HandleTranslationUnit(clang::ASTContext&) + 112
11 swift 0x00000001018075bc clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) + 44
12 swift 0x00000001019e9ca5 clang::ParseAST(clang::Sema&, bool, bool) + 581
13 swift 0x00000001017d27a9 clang::FrontendAction::Execute() + 73
14 swift 0x000000010179f361 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 1073
15 swift 0x00000001034b096b llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) + 283
16 swift 0x00000001034b0b30 RunSafelyOnThread_Dispatch(void*) + 48
17 swift 0x000000010351fc6d ExecuteOnThread_Dispatch(void*) + 13
18 libsystem_pthread.dylib 0x00007fff88df099d _pthread_body + 131
19 libsystem_pthread.dylib 0x00007fff88df091a _pthread_body + 0
20 libsystem_pthread.dylib 0x00007fff88dee351 thread_start + 13
Stack dump:
0. <eof> parser at end of file
<unknown>:0: error: unable to execute command: Illegal instruction: 4
<unknown>:0: error: compile command failed due to signal (use -v to see invocation)
<unknown>:0: error: build had 1 command failures
error: exit(1): /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-05-09-a.xctoolchain/usr/bin/swift-build-tool -f /Users/stefan/Developer/Projects/AbstractSQL/.build/debug.yaml -v Swift version:
|
Attachment: Download
Environment
OSX 10.11.1 (15B42)
swift-2.2-SNAPSHOT-2015-12-01-a-osx
Additional Detail from JIRA
md5: 6256508fb06b830feeade0377fd99c27
relates to:
-Xcc -I/usr/include
to swiftc)Issue Description:
Trying to build a trivial application (sources attached) that imports sqlite3.h from a system module causes the segfault output below.
Sqlite version info from the header is:
The text was updated successfully, but these errors were encountered: