Skip to content
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-11391] REPL crashes on Arch Linux while demangling symbol #53792

Closed
swift-ci opened this issue Aug 29, 2019 · 9 comments
Closed

[SR-11391] REPL crashes on Arch Linux while demangling symbol #53792

swift-ci opened this issue Aug 29, 2019 · 9 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself Linux Platform: Linux REPL

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-11391
Radar rdar://problem/54894194
Original Reporter segabor (JIRA User)
Type Bug
Status Closed
Resolution Invalid
Environment

OS: Linux

System Version: Linux csihuhu 5.2.9-arch1-1-ARCH #1 SMP PREEMPT Fri Aug 16 11:29:43 UTC 2019 x86_64 GNU/Linux

Snapshot: swift-5.1-DEVELOPMENT-SNAPSHOT-2019-08-28-a

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, Linux, REPL
Assignee None
Priority Medium

md5: 8568b029247b96cae9e017d96be45ead

Issue Description:

Apart from the fact the whole snapshot does not build (aborts at swiftpm projects), swift interpreter crashes.

I started binary under build/buildbot_linux/swift-linux-x86_64/bin/swift in REPL mode and entered just one line let a="hello" it instantly crashed with the following stack trace

[segabor@csihuhu swift-dev]$ /home/segabor/Workspace/swift-dev/build/buildbot_linux/swift-linux-x86_64/bin/swift
***  You are running Swift's integrated REPL,  ***
***  intended for compiler and stdlib          ***
***  development and testing purposes only.    ***
***  The full REPL is built as part of LLDB.   ***
***  Type ':help' for assistance.              ***
(swift) let a="hello"
Stack dump:
0.  Program arguments: /home/segabor/Workspace/swift-dev/build/buildbot_linux/swift-linux-x86_64/bin/swift -frontend -repl -disable-objc-interop -color-diagnostics -module-name REPL 
1.  Swift version 5.1-dev (LLVM c5340df2d1, Swift ec3975a977)
2.  while processing REPL source:
let a="hello"
 #​0 0x00005579721e5e54 PrintStackTraceSignalHandler(void*) (/home/segabor/Workspace/swift-dev/build/buildbot_linux/swift-linux-x86_64/bin/swift+0x46aee54)
 #​1 0x00005579721e3b6e llvm::sys::RunSignalHandlers() (/home/segabor/Workspace/swift-dev/build/buildbot_linux/swift-linux-x86_64/bin/swift+0x46acb6e)
 #​2 0x00005579721e6268 SignalHandler(int) (/home/segabor/Workspace/swift-dev/build/buildbot_linux/swift-linux-x86_64/bin/swift+0x46af268)
 #​3 0x00007f7478935d00 __restore_rt (/usr/lib/libpthread.so.0+0x13d00)
 #​4 0x00007f74771acb01 swift::Demangle::Demangler::demangleBoundGenericType() (/home/segabor/Workspace/swift-dev/build/buildbot_linux/swift-linux-x86_64/lib/swift/linux/libswiftCore.so+0x41db01)
 #​5 0x00007f74771a7f38 swift::Demangle::Demangler::demangleType(llvm::StringRef) (/home/segabor/Workspace/swift-dev/build/buildbot_linux/swift-linux-x86_64/lib/swift/linux/libswiftCore.so+0x418f38)
 #&#8203;6 0x00007f74771955cc swift_getTypeByMangledNameImpl(swift::MetadataRequest, llvm::StringRef, void const* const*, std::function<swift::TargetMetadata<swift::InProcess> const* (unsigned int, unsigned int)>, std::function<swift::TargetWitnessTable<swift::InProcess> const* (swift::TargetMetadata<swift::InProcess> const*, unsigned int)>) (/home/segabor/Workspace/swift-dev/build/buildbot_linux/swift-linux-x86_64/lib/swift/linux/libswiftCore.so+0x4065cc)
 #&#8203;7 0x00007f74771934d7 swift::swift_getTypeByMangledName(swift::MetadataRequest, llvm::StringRef, void const* const*, std::function<swift::TargetMetadata<swift::InProcess> const* (unsigned int, unsigned int)>, std::function<swift::TargetWitnessTable<swift::InProcess> const* (swift::TargetMetadata<swift::InProcess> const*, unsigned int)>) (/home/segabor/Workspace/swift-dev/build/buildbot_linux/swift-linux-x86_64/lib/swift/linux/libswiftCore.so+0x4044d7)
 #&#8203;8 0x00007f74771935c6 swift_getTypeByMangledNameInContext (/home/segabor/Workspace/swift-dev/build/buildbot_linux/swift-linux-x86_64/lib/swift/linux/libswiftCore.so+0x4045c6)
 #&#8203;9 0x00007f7477114906 __swift_instantiateConcreteTypeFromMangledName (/home/segabor/Workspace/swift-dev/build/buildbot_linux/swift-linux-x86_64/lib/swift/linux/libswiftCore.so+0x385906)
Segmentation fault (core dumped)
@belkadan
Copy link
Contributor

@jckarter, any theories?

@jckarter
Copy link
Member

Does the crash only happen in the integrated REPL? Can you also reproduce it in "script mode" if you try putting the code in a file and run it with `swift foo.swift`? We've had integrated-REPL and JIT mode specific problems with relative references in the past.

@swift-ci
Copy link
Collaborator Author

Comment by Gábor Sebestyén (JIRA)

As far as I remember running script went fine but let me check it again.

@swift-ci
Copy link
Collaborator Author

Comment by Gábor Sebestyén (JIRA)

I can confirm script mode runs fine.

[segabor@csihuhu swift-dev]$ cat test2.swift 
let a="hello"
[segabor@csihuhu swift-dev]$ ./build/buildbot_linux/swift-linux-x86_64/bin/swift test2.swift 
[segabor@csihuhu swift-dev]$ 

@swift-ci
Copy link
Collaborator Author

Comment by Gábor Sebestyén (JIRA)

In this case I wanted to know the result of 2*2. I got core dump:

[segabor@csihuhu swift-dev]$ /home/segabor/Workspace/swift-dev/build/buildbot_linux/swift-linux-x86_64/bin/swift
***  You are running Swift's integrated REPL,  ***
***  intended for compiler and stdlib          ***
***  development and testing purposes only.    ***
***  The full REPL is built as part of LLDB.   ***
***  Type ':help' for assistance.              ***
(swift) 2*2
Stack dump:
0.  Program arguments: /home/segabor/Workspace/swift-dev/build/buildbot_linux/swift-linux-x86_64/bin/swift -frontend -repl -disable-objc-interop -color-diagnostics -module-name REPL 
1.  Swift version 5.1-dev (LLVM c5340df2d1, Swift ec3975a977)
2.  while processing REPL source:
2*2
 #&#8203;0 0x000056214b17be54 PrintStackTraceSignalHandler(void*) (/home/segabor/Workspace/swift-dev/build/buildbot_linux/swift-linux-x86_64/bin/swift+0x46aee54)
 #&#8203;1 0x000056214b179b6e llvm::sys::RunSignalHandlers() (/home/segabor/Workspace/swift-dev/build/buildbot_linux/swift-linux-x86_64/bin/swift+0x46acb6e)
 #&#8203;2 0x000056214b17c268 SignalHandler(int) (/home/segabor/Workspace/swift-dev/build/buildbot_linux/swift-linux-x86_64/bin/swift+0x46af268)
 #&#8203;3 0x00007faafe967d00 __restore_rt (/usr/lib/libpthread.so.0+0x13d00)
 #&#8203;4 0x00007faafe9e0120 
 #&#8203;5 0x0000562147149025 llvm::MCJIT::runFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) (/home/segabor/Workspace/swift-dev/build/buildbot_linux/swift-linux-x86_64/bin/swift+0x67c025)
 #&#8203;6 0x000056214714d640 llvm::ExecutionEngine::runFunctionAsMain(llvm::Function*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, char const* const*) (/home/segabor/Workspace/swift-dev/build/buildbot_linux/swift-linux-x86_64/bin/swift+0x680640)
 #&#8203;7 0x0000562147143b21 REPLEnvironment::executeSwiftSource(llvm::StringRef, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&) (/home/segabor/Workspace/swift-dev/build/buildbot_linux/swift-linux-x86_64/bin/swift+0x676b21)
 #&#8203;8 0x000056214713f095 swift::runREPL(swift::CompilerInstance&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, bool) (/home/segabor/Workspace/swift-dev/build/buildbot_linux/swift-linux-x86_64/bin/swift+0x672095)
 #&#8203;9 0x00005621471273b3 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) (/home/segabor/Workspace/swift-dev/build/buildbot_linux/swift-linux-x86_64/bin/swift+0x65a3b3)
#&#8203;10 0x0000562147125449 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) (/home/segabor/Workspace/swift-dev/build/buildbot_linux/swift-linux-x86_64/bin/swift+0x658449)
#&#8203;11 0x00005621470c86a1 main (/home/segabor/Workspace/swift-dev/build/buildbot_linux/swift-linux-x86_64/bin/swift+0x5fb6a1)
#&#8203;12 0x00007faafe18aee3 __libc_start_main (/usr/lib/libc.so.6+0x26ee3)
#&#8203;13 0x00005621470c82de _start (/home/segabor/Workspace/swift-dev/build/buildbot_linux/swift-linux-x86_64/bin/swift+0x5fb2de)
Illegal instruction (core dumped)

But this expression was evaluated from file

[segabor@csihuhu swift-dev]$ echo 2*2 > test3.swift
[segabor@csihuhu swift-dev]$ cat test3.swift 
2*2
[segabor@csihuhu swift-dev]$ /home/segabor/Workspace/swift-dev/build/buildbot_linux/swift-linux-x86_64/bin/swift test3.swift 
test3.swift:1:2: warning: result of operator '*' is unused
2*2
~^~

@belkadan
Copy link
Contributor

As noted, you're not running the real REPL, which is supported by LLDB. The integrated REPL is just meant for testing the compiler and isn't an officially-supported part of the product. (That doesn't mean we wouldn't take patches to improve things, but it does mean a fix probably won't be prioritized.)

@jckarter
Copy link
Member

@swift-ci create

@swift-ci
Copy link
Collaborator Author

Comment by Gábor Sebestyén (JIRA)

Somehow I missed the “integrated” word sorry. I gonna check it with the real REPL.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Sep 3, 2019

Comment by Gábor Sebestyén (JIRA)

I found a serious flaw in the build script that possibly caused this issue. After fixing it the build completed successfully and initial tests in Swift REPL are also good.

@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 in itself Linux Platform: Linux REPL
Projects
None yet
Development

No branches or pull requests

3 participants