Skip to content

[SR-10335] Swift compiler crash while compiling the BlueSignals dependency #52735

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

Closed
swift-ci opened this issue Apr 8, 2019 · 13 comments
Closed
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself debug info Area → compiler → IRGen: Debug information emission

Comments

@swift-ci
Copy link
Contributor

swift-ci commented Apr 8, 2019

Previous ID SR-10335
Radar None
Original Reporter stamba (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

PowerPC64LE

Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug, DebugInfo
Assignee @slavapestov
Priority Medium

md5: 53c3f2819c4d04f49868102943164497

Issue Description:

I have built Apple Swift 5 toolchain on PowerPC64LE. I also managed to run all the test suites in the toolchain.

Now I am trying to build and run tests in Kitura for Swift.

I tried the following steps mentioned at https://github.com/IBM-Swift/Kitura :-

  1. Clone this repository.
    $ git clone https://github.com/IBM-Swift/Kitura

  2. Build and run tests.
    $ swift test

However I am seeing the below issues.

{{ sar@267538d18c75:~/extra-tests-swift/kitura$ git clone https://github.com/IBM-Swift/Kitura

Cloning into 'Kitura'...
remote: Enumerating objects: 122, done.
remote: Counting objects: 100% (122/122), done.
remote: Compressing objects: 100% (70/70), done.
remote: Total 7777 (delta 56), reused 101 (delta 45), pack-reused 7655
Receiving objects: 100% (7777/7777), 6.46 MiB | 2.98 MiB/s, done.
Resolving deltas: 100% (4696/4696), done.
Checking connectivity... done.

sar@267538d18c75:~/extra-tests-swift/kitura$ cd Kitura/

sar@267538d18c75:~/extra-tests-swift/kitura/Kitura$ ls
Configuration LICENSE.txt Package.swift [email protected] README.md Sources docker-compose.yml vagrantfile
Documentation NOTICES.txt [email protected] [email protected] Scripts Tests docs

sar@267538d18c75:/extra-tests-swift/kitura/Kitura$ swift test
Fetching https://github.com/IBM-Swift/Kitura-net.git
Fetching https://github.com/IBM-Swift/Kitura-TemplateEngine.git
Fetching https://github.com/IBM-Swift/KituraContracts.git
Fetching https://github.com/IBM-Swift/TypeDecoder.git
Fetching https://github.com/IBM-Swift/LoggerAPI.git
Fetching https://github.com/IBM-Swift/BlueSignals.git
Fetching https://github.com/IBM-Swift/BlueSocket.git
Fetching https://github.com/IBM-Swift/BlueSSLService.git
Fetching https://github.com/IBM-Swift/OpenSSL.git
Completed resolution in 15.42s
Cloning https://github.com/IBM-Swift/OpenSSL.git
Resolving https://github.com/IBM-Swift/OpenSSL.git at 2.2.2
Cloning https://github.com/IBM-Swift/LoggerAPI.git
Resolving https://github.com/IBM-Swift/LoggerAPI.git at 1.8.1
Cloning https://github.com/IBM-Swift/KituraContracts.git
Resolving https://github.com/IBM-Swift/KituraContracts.git at 1.1.2
Cloning https://github.com/IBM-Swift/Kitura-net.git
Resolving https://github.com/IBM-Swift/Kitura-net.git at 2.2.1
Cloning https://github.com/IBM-Swift/TypeDecoder.git
Resolving https://github.com/IBM-Swift/TypeDecoder.git at 1.3.3
Cloning https://github.com/IBM-Swift/BlueSSLService.git
Resolving https://github.com/IBM-Swift/BlueSSLService.git at 1.0.45
Cloning https://github.com/IBM-Swift/BlueSocket.git
Resolving https://github.com/IBM-Swift/BlueSocket.git at 1.0.45
Cloning https://github.com/IBM-Swift/Kitura-TemplateEngine.git
Resolving https://github.com/IBM-Swift/Kitura-TemplateEngine.git at 2.0.1
Cloning https://github.com/IBM-Swift/BlueSignals.git
Resolving https://github.com/IBM-Swift/BlueSignals.git at 1.0.17
Incorrect reconstructed type for $sSay7SignalsAAC6SignalO6signal_ys5Int32VXC6actiontGD
Original type:
(bound_generic_struct_type decl=Swift.(file).Array
(tuple_type num_elements=2
(tuple_type_elt name=signal
(enum_type decl=Signals.(file).Signals.Signal@/home/sar/extra-tests-swift/kitura/Kitura/.build/checkouts/BlueSignals/Sources/Signals/Signals.swift:38:14
(parent=class_type decl=Signals.(file).Signals@/home/sar/extra-tests-swift/kitura/Kitura/.build/checkouts/BlueSignals/Sources/Signals/Signals.swift:31:14)))
(tuple_type_elt name=action
(function_type representation=c escaping
(input=function_params num_params=1
(param
(struct_type decl=Swift.(file).Int32)))
(output=tuple_type num_elements=0)))))
Reconstructed type:
(bound_generic_struct_type decl=Swift.(file).Array
(tuple_type num_elements=2
(tuple_type_elt name=signal
(enum_type decl=Signals.(file).Signals.Signal@/home/sar/extra-tests-swift/kitura/Kitura/.build/checkouts/BlueSignals/Sources/Signals/Signals.swift:38:14
(parent=class_type decl=Signals.(file).Signals@/home/sar/extra-tests-swift/kitura/Kitura/.build/checkouts/BlueSignals/Sources/Signals/Signals.swift:31:14)))
(tuple_type_elt name=action
(function_type representation=c
(input=function_params num_params=1
(param
(struct_type decl=Swift.(file).Int32)))
(output=tuple_type num_elements=0)))))
Stack dump:
0. Program arguments: /home/sar/extra-tests-swift/usr/bin/swift -frontend -c -primary-file /home/sar/extra-tests-swift/kitura/Kitura/.build/checkouts/BlueSignals/Sources/Signals/Signals.swift -emit-module-path /home/sar/extra-tests-swift/kitura/Kitura/.build/powerpc64le-unknown-linux/debug/Signals.build/Signals
partial.swiftmodule -emit-module-doc-path /home/sar/extra-tests-swift/kitura/Kitura/.build/powerpc64le-unknown-linux/debug/Signals.build/Signals~partial.swiftdoc -emit-dependencies-path /home/sar/extra-tests-swift/kitura/Kitura/.build/powerpc64le-unknown-linux/debug/Signals.build/Signals.d -emit-reference-dependencies-path /home/sar/extra-tests-swift/kitura/Kitura/.build/powerpc64le-unknown-linux/debug/Signals.build/Signals.swiftdeps -target powerpc64le-unknown-linux -disable-objc-interop -sdk / -I /home/sar/extra-tests-swift/kitura/Kitura/.build/powerpc64le-unknown-linux/debug -enable-testing -g -module-cache-path /home/sar/extra-tests-swift/kitura/Kitura/.build/powerpc64le-unknown-linux/debug/ModuleCache -swift-version 4 -Onone -D SWIFT_PACKAGE -D DEBUG -color-diagnostics -enable-anonymous-context-mangled-names -parse-as-library -module-name Signals -o /home/sar/extra-tests-swift/kitura/Kitura/.build/powerpc64le-unknown-linux/debug/Signals.build/Signals.swift.o -index-store-path /home/sar/extra-tests-swift/kitura/Kitura/.build/powerpc64le-unknown-linux/debug/index/store -index-system-modules 1. While emitting IR SIL function "@$s7SignalsAAC4trap7signalsySayAB6SignalO6signal_ys5Int32VXC6actiontG_tFZ". for 'trap(signals:)' (at /home/sar/extra-tests-swift/kitura/Kitura/.build/checkouts/BlueSignals/Sources/Signals/Signals.swift:123:9)
/home/sar/extra-tests-swift/usr/bin/swift[0x150bc2a8]
/home/sar/extra-tests-swift/usr/bin/swift[0x150b9548]
/home/sar/extra-tests-swift/usr/bin/swift[0x150bc968]
[0x3fff7ac404d8]
/lib/powerpc64le-linux-gnu/libc.so.6(gsignal+0x40)[0x3fff7a5bec90]
/lib/powerpc64le-linux-gnu/libc.so.6(abort+0x2b4)[0x3fff7a5c11f4]
/home/sar/extra-tests-swift/usr/bin/swift[0x1039663c]
/home/sar/extra-tests-swift/usr/bin/swift[0x103970e8]
/home/sar/extra-tests-swift/usr/bin/swift[0x10396cb4]
/home/sar/extra-tests-swift/usr/bin/swift[0x1038c6e4]
/home/sar/extra-tests-swift/usr/bin/swift[0x1038d450]
/home/sar/extra-tests-swift/usr/bin/swift[0x1038d340]
/home/sar/extra-tests-swift/usr/bin/swift[0x103a26a4]
/home/sar/extra-tests-swift/usr/bin/swift[0x1028dedc]
/home/sar/extra-tests-swift/usr/bin/swift[0x101cfff0]
/home/sar/extra-tests-swift/usr/bin/swift[0x101d0778]
/home/sar/extra-tests-swift/usr/bin/swift[0x1012b860]
/home/sar/extra-tests-swift/usr/bin/swift[0x10126c90]
/home/sar/extra-tests-swift/usr/bin/swift[0x100aa89c]
/home/sar/extra-tests-swift/usr/bin/swift[0x100a9ee0]
/lib/powerpc64le-linux-gnu/libc.so.6(+0x2309c)[0x3fff7a5a309c]
/lib/powerpc64le-linux-gnu/libc.so.6(__libc_start_main+0xb8)[0x3fff7a5a3298]

sar@267538d18c75:~/extra-tests-swift/kitura/Kitura$}}

Can anyone explain what this piece of code is trying to do?

Also if the error looks familiar or am I missing anything here?

@swift-ci
Copy link
Contributor Author

swift-ci commented Apr 8, 2019

Comment by Sarvesh Tamba (JIRA)

Here is the source of the file which is found in the error above:-

https://github.com/IBM-Swift/BlueSignals/blob/master/Sources/Signals/Signals.swift

@belkadan
Copy link
Contributor

belkadan commented Apr 8, 2019

It'd be helpful to run that failing `swift -frontend` command in a debugger to get a symbolicated stack trace.

@swift-ci
Copy link
Contributor Author

Comment by Sarvesh Tamba (JIRA)

Hi @jrose,

I built swift toolchain in release mode as debug build runs out of space (needs more than 80GB space and 6 hrs of build time).
However I did run through the core dump in gdb which was generated by above error and this is what I found:-

sar@267538d18c75:~/extra-tests-swift/kitura/Kitura$ gdb /home/sar/extra-tests-swift/usr/bin/swift core
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html\>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "powerpc64le-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/\>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/\>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /home/sar/extra-tests-swift/usr/bin/swift...(no debugging symbols found)...done.
[New LWP 11937]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/powerpc64le-linux-gnu/libthread_db.so.1".
Core was generated by `/home/sar/extra-tests-swift/usr/bin/swift -frontend -c -primary-file /home/sar/'.
Program terminated with signal SIGABRT, Aborted.
#0 0x00003fffa9c0ec90 in __GI_raise (sig=<optimized out>) at ../sysdeps/unix/sysv/linux/raise.c:54
54 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0 0x00003fffa9c0ec90 in __GI_raise (sig=<optimized out>) at ../sysdeps/unix/sysv/linux/raise.c:54
#1 0x00003fffa9c11044 in __GI_abort () at abort.c:118
#2 0x000000001039663c in (anonymous namespace)::IRGenDebugInfoImpl::getOrCreateType(swift::irgen::DebugTypeInfo) ()
#3 0x00000000103970e8 in (anonymous namespace)::IRGenDebugInfoImpl::createParameterType(llvm::SmallVectorImpl<llvm::Metadata*>&, swift::SILType) ()
#4 0x0000000010396cb4 in (anonymous namespace)::IRGenDebugInfoImpl::createParameterTypes(swift::CanTypeWrapper<swift::SILFunctionType>) ()
#5 0x000000001038c6e4 in (anonymous namespace)::IRGenDebugInfoImpl::emitFunction(swift::SILDebugScope const*, llvm::Function*, swift::SILFunctionTypeRepresentation, swift::SILType, swift::DeclContext*) ()
#6 0x000000001038d450 in (anonymous namespace)::IRGenDebugInfoImpl::emitFunction(swift::SILFunction&, llvm::Function*) ()
#7 0x000000001038d340 in swift::irgen::IRGenDebugInfo::emitFunction(swift::SILFunction&, llvm::Function*) ()
#8 0x00000000103a26a4 in swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) ()
#9 0x000000001028dedc in swift::irgen::IRGenerator::emitGlobalTopLevel() ()
#10 0x00000000101cfff0 in performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::LLVMContext&, swift::SourceFile*, llvm::GlobalVariable**) ()
#11 0x00000000101d0778 in swift::performIRGeneration(swift::IRGenOptions&, swift::SourceFile&, std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::LLVMContext&, llvm::GlobalVariable**) ()
#12 0x000000001012b860 in performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) ()
#13 0x0000000010126c90 in swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) ()
#14 0x00000000100aa89c in run_driver(llvm::StringRef, llvm::ArrayRef<char const*>) ()
#15 0x00000000100a9ee0 in main ()
(gdb)

I tried going through the code in the stack trace, however I am not well versed with the finer details of the code and will require help from swift community. Anyone you could point me to who can guide me on this?

Also I tried runnung these same Kitura tests on x86_64 using the release candidate at:
https://swift.org/builds/swift-5.0-release/ubuntu1604/swift-5.0-RELEASE/swift-5.0-RELEASE-ubuntu16.04.tar.gz

In this case the swift execution proceeds and passes all the tests in the Kitura framework.

@belkadan
Copy link
Contributor

Okay, so the differences here are whether the function type is escaping…which shouldn't make a difference when used within a larger type like this. @slavapestov, @adrian-prantl, have either of you seen this mangling failure before? It doesn't seem like something that would be PPC64-related at all.

@slavapestov
Copy link
Contributor

I don't think it's PowerPC64-related. If you look at the original type, it's "(function_type representation=c escaping", while the demangled version does not have 'escaping'. This doesn't make sense; escaping/non-escaping should not be a property of a C function pointer at all. We should not set the escaping bit when we build C function pointer types.

@adrian-prantl
Copy link
Contributor

> I built swift toolchain in release mode as debug build runs out of space (needs more than 80GB space and 6 hrs of build time).

If you are building on Linux, I'd recommend configuring with -DLLVM_USE_SPLIT_DWARF=1. Alternatively / in addition you can combine a release LLVM with a debug swift compiler by building -r --debug-swift.

> Slava Pestov, Adrian Prantl, have either of you seen this mangling failure before?

This is probably the assertion that verifies that the type can be reconstructed form the mangled name. If you can the mangled name for which it is failing @slavapestov may be able to fix it.

@slavapestov
Copy link
Contributor

stamba (JIRA User) As a workaround, you can build without debug info for now. Sorry for the inconvenience.

@swift-ci
Copy link
Contributor Author

Comment by Sarvesh Tamba (JIRA)

@slavapestov do you mean I build the swift toolchain without debug info? As mentioned above, that is exactly what I am doing right now, i.e building swift toolchain in release mode due to space constraints for a debug build. And the tests fail with this release built swift compiler.

If you meant build the tests those are failing without debug info, can you please let me know how do I go about this?

@swift-ci
Copy link
Contributor Author

Comment by Sarvesh Tamba (JIRA)

> This is probably the assertion that verifies that the type can be reconstructed form the mangled name. If you can the mangled name for which it is failing Slava Pestov may be able to fix it.
@adrian-prantl do you need anything from me here?

@slavapestov
Copy link
Contributor

Sorry, I meant build Kitura without debug info.

@slavapestov
Copy link
Contributor

stamba (JIRA User) We have enough information to construct a test case and fix the issue. Thank you for the bug report.

@swift-ci
Copy link
Contributor Author

swift-ci commented Jun 6, 2019

Comment by David Jones (JIRA)

@slavapestov Thought I should add that this is not specific to PPC64LE. I get the same failure trying to compile the BlueSignals package on x64 (Ubuntu 16.04) with the latest 5.1 snapshot (5.1-DEVELOPMENT-SNAPSHOT-2019-05-29-a).

It compiles fine with the 5.0.1-RELEASE build.

(see: Kitura/BlueSignals#20

@slavapestov
Copy link
Contributor

#25423

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself debug info Area → compiler → IRGen: Debug information emission
Projects
None yet
Development

No branches or pull requests

4 participants