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-2929] Segfault only when running swift in system-wide directory #45523

Open
swift-ci opened this issue Oct 12, 2016 · 8 comments
Open

[SR-2929] Segfault only when running swift in system-wide directory #45523

swift-ci opened this issue Oct 12, 2016 · 8 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-2929
Radar None
Original Reporter dowobeha (JIRA User)
Type Bug

Attachment: Download

Environment

$ uname -a
Linux 4.4.0-38-generic #57-Ubuntu SMP Tue Sep 6 15:42:33 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Additional Detail from JIRA
Votes 0
Component/s
Labels Bug
Assignee None
Priority Medium

Watchers: @shahmishal

md5: 258159ac7c9dad1429a1e8c2048fa9f8

Issue Description:

I'm on Ubuntu 16, and just downloaded the latest Swift package. When I run swift from /opt (installed using sudo) as a normal user, I get a segfault. When I run it from /opt as root, no problems. When I run from my home dir as a normal user, things are fine.

Run swift (installed in /opt using sudo) as local user - I get a segfault.

lanes:~$ /opt/swift-3.0.1-PREVIEW-2-ubuntu16.04/usr/bin/swift
Welcome to Swift version 3.0.1 (swift-3.0.1-PREVIEW-2). Type :help for assistance.
1> print("Hello")
Segmentation fault (core dumped)

Run swift (installed in home dir) as local user - everything is fine.

lanes:~$ ~/Downloads/swift-3.0.1-PREVIEW-2-ubuntu16.04/usr/bin/swift
Welcome to Swift version 3.0.1 (swift-3.0.1-PREVIEW-2). Type :help for assistance.
1> print("Hello")
Hello

Run swift (installed in /opt using sudo) as root - everything is fine.

root:~# /opt/swift-3.0.1-PREVIEW-2-ubuntu16.04/usr/bin/swift
Welcome to Swift version 3.0.1 (swift-3.0.1-PREVIEW-2). Type :help for assistance.
1> print("Hello")
Hello

@shahmishal
Copy link
Member

Can you please provide the Segmentation fault error?

@swift-ci
Copy link
Collaborator Author

Comment by Lane Schwartz (JIRA)

Thread 8 "io-handler" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffd2933700 (LWP 6389)]
0x00007ffff455f577 in llvm::verifyModule(llvm::Module const&, llvm::raw_ostream*, bool*) () from /opt/swift-3.0.1-PREVIEW-2-ubuntu16.04/usr/bin/../lib/liblldb.so.3.9.0
(gdb) bt
#​0  0x00007ffff455f577 in llvm::verifyModule(llvm::Module const&, llvm::raw_ostream*, bool*) () from /opt/swift-3.0.1-PREVIEW-2-ubuntu16.04/usr/bin/../lib/liblldb.so.3.9.0
#​1  0x00007ffff64b8184 in LLVMVerifyModule () from /opt/swift-3.0.1-PREVIEW-2-ubuntu16.04/usr/bin/../lib/liblldb.so.3.9.0
#​2  0x00007ffff4a794ba in lldb_private::SwiftExpressionParser::Parse(lldb_private::DiagnosticManager&, unsigned int, unsigned int, unsigned int) ()
from /opt/swift-3.0.1-PREVIEW-2-ubuntu16.04/usr/bin/../lib/liblldb.so.3.9.0
#​3  0x00007ffff4a718f0 in lldb_private::SwiftUserExpression::Parse(lldb_private::DiagnosticManager&, lldb_private::ExecutionContext&, lldb_private::ExecutionPolicy, bool, bool, unsigned int) ()
from /opt/swift-3.0.1-PREVIEW-2-ubuntu16.04/usr/bin/../lib/liblldb.so.3.9.0
#&#8203;4  0x00007ffff4713f2c in lldb_private::UserExpression::Evaluate(lldb_private::ExecutionContext&, lldb_private::EvaluateExpressionOptions const&, char const*, char const*, lldb_private::SharingPtr<lldb_private::ValueObject>&, lldb_private::Error&, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, std::shared_ptr<lldb_private::Module>*) ()
from /opt/swift-3.0.1-PREVIEW-2-ubuntu16.04/usr/bin/../lib/liblldb.so.3.9.0
#&#8203;5  0x00007ffff4711bb9 in lldb_private::REPL::IOHandlerInputComplete(lldb_private::IOHandler&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) ()
from /opt/swift-3.0.1-PREVIEW-2-ubuntu16.04/usr/bin/../lib/liblldb.so.3.9.0
#&#8203;6  0x00007ffff46797f7 in lldb_private::IOHandlerEditline::Run() () from /opt/swift-3.0.1-PREVIEW-2-ubuntu16.04/usr/bin/../lib/liblldb.so.3.9.0
#&#8203;7  0x00007ffff4662a90 in lldb_private::Debugger::ExecuteIOHandlers() () from /opt/swift-3.0.1-PREVIEW-2-ubuntu16.04/usr/bin/../lib/liblldb.so.3.9.0
#&#8203;8  0x00007ffff466673f in lldb_private::Debugger::IOHandlerThread(void*) () from /opt/swift-3.0.1-PREVIEW-2-ubuntu16.04/usr/bin/../lib/liblldb.so.3.9.0
#&#8203;9  0x00007ffff29cd6fa in start_thread (arg=0x7fffd2933700) at pthread_create.c:333
#&#8203;10 0x00007ffff1e62b5d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

@swift-ci
Copy link
Collaborator Author

Comment by Lane Schwartz (JIRA)

Also note: doing a chown -R to a non-root user on the relevant directory also works around the issue. But that shouldn't be necessary.

@martinr448
Copy link

The reason for the crash seems to be that all files in the usr/lib/swift/CoreFoundation subdirectory can only be read by "root". This is already wrong in the TAR archive:

$ tar tvzf swift-3.0.1-RELEASE-ubuntu16.04.tar.gz | grep CoreFoundation 
drwxr-xr-x root/root         0 2016-10-29 04:10 swift-3.0.1-RELEASE-ubuntu16.04/usr/lib/swift/CoreFoundation/
-rw-r----- root/root      8945 2016-10-29 04:10 swift-3.0.1-RELEASE-ubuntu16.04/usr/lib/swift/CoreFoundation/CFLocale.h
-rw-r----- root/root      5247 2016-10-29 04:10 swift-3.0.1-RELEASE-ubuntu16.04/usr/lib/swift/CoreFoundation/CFStringEncodingConverterExt.h
-rw-r----- root/root      2067 2016-10-29 04:10 swift-3.0.1-RELEASE-ubuntu16.04/usr/lib/swift/CoreFoundation/CFStringEncodingConverterPriv.h
-rw-r----- root/root      5772 2016-10-29 04:10 swift-3.0.1-RELEASE-ubuntu16.04/usr/lib/swift/CoreFoundation/CFPlugIn.h
...

Adding the read-permission for "other" fixes the issue:

# chmod -R o+r swift-3.0.1-RELEASE-ubuntu16.04/usr/lib/swift/CoreFoundation/

This should probably be fixed where the TAR archive is created.

@swift-ci
Copy link
Collaborator Author

Comment by Lane Schwartz (JIRA)

Has this been addressed in newer releases?

@martinr448
Copy link

Apparently this has been fixed in newer releases. I cannot reproduce the problem anymore, and the permissions in the TAR archive look good:

$ tar tvzf swift-4.2-RELEASE-ubuntu18.04.tar.gz | grep CoreFoundation
-rw-r--r-- root/root      4441 2018-09-13 03:14 swift-4.2-RELEASE-ubuntu18.04/usr/lib/swift/shims/CoreFoundationShims.h
-rw-r--r-- root/root      1038 2018-09-13 03:14 swift-4.2-RELEASE-ubuntu18.04/usr/lib/swift/shims/CoreFoundationOverlayShims.h
drwxr-xr-x root/root         0 2018-09-13 03:43 swift-4.2-RELEASE-ubuntu18.04/usr/lib/swift/CoreFoundation/
-rw-r--r-- root/root      4514 2018-09-13 03:43 swift-4.2-RELEASE-ubuntu18.04/usr/lib/swift/CoreFoundation/CFPlugInCOM.h
-rw-r--r-- root/root     17578 2018-09-13 03:43 swift-4.2-RELEASE-ubuntu18.04/usr/lib/swift/CoreFoundation/CFURL.inc.h
-rw-r--r-- root/root      1953 2018-09-13 03:43 swift-4.2-RELEASE-ubuntu18.04/usr/lib/swift/CoreFoundation/CFKnownLocations.h
...

@swift-ci
Copy link
Collaborator Author

Comment by Lane Schwartz (JIRA)

This problem is still present in swift-4.2.2-RELEASE-ubuntu16.04.tar.gz

@swift-ci
Copy link
Collaborator Author

Comment by Lane Schwartz (JIRA)

The workaround is to do the following as root:

$ sudo chmod -R a+r swift-4.2.2-RELEASE-ubuntu16.04

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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.
Projects
None yet
Development

No branches or pull requests

3 participants