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-2783] REPL crashes due to bad permissions CoreFoundation header files (Ubuntu) #4585

swift-ci opened this issue Sep 28, 2016 · 10 comments


Copy link

Previous ID SR-2783
Radar None
Original Reporter qwerty (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download


plateform: Amazon 3.13.0-92-generic #139-Ubuntu SMP Tue Jun 28 20:42:26 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.4 LTS
Release: 14.04
Codename: trusty

libghc-llvm-base-dev/trusty amd64
libghc-llvm-base-doc/trusty all
libghc-llvm-base-prof/trusty amd64
libghc-llvm-dev/trusty amd64
libghc-llvm-doc/trusty all
libghc-llvm-prof/trusty amd64
libllvm-3.3-ocaml-dev/trusty 1:3.3-16ubuntu1 amd64
libllvm-3.4-ocaml-dev/trusty 1:3.4-1ubuntu3 amd64
libllvm-3.5-ocaml-dev/trusty-updates,trusty-security 1:3.5-4ubuntu2~trusty2 amd64
libllvm-3.6-ocaml-dev/trusty-updates 1:3.6-2ubuntu1~trusty1 amd64
libllvm-3.8-ocaml-dev/trusty-updates 1:3.8-2ubuntu3~trusty4 amd64
libllvm-ocaml-dev/trusty 1:3.4-0ubuntu1 amd64
libllvm3.3/trusty 1:3.3-16ubuntu1 amd64
libllvm3.3-dbg/trusty 1:3.3-16ubuntu1 amd64
libllvm3.4/trusty,now 1:3.4-1ubuntu3 amd64 [installed,automatic]
libllvm3.4-dbg/trusty 1:3.4-1ubuntu3 amd64
libllvm3.5/trusty-updates,trusty-security 1:3.5-4ubuntu2~trusty2 amd64
libllvm3.5-dbg/trusty-updates,trusty-security 1:3.5-4ubuntu2~trusty2 amd64
libllvm3.6/trusty-updates 1:3.6-2ubuntu1~trusty1 amd64
libllvm3.6-dbg/trusty-updates 1:3.6-2ubuntu1~trusty1 amd64
libllvm3.8v4/trusty-updates 1:3.8-2ubuntu3~trusty4 amd64
libllvm3.8v4-dbg/trusty-updates 1:3.8-2ubuntu3~trusty4 amd64
llvm/trusty 1:3.4-0ubuntu1 amd64
llvm-3.3/trusty 1:3.3-16ubuntu1 amd64
llvm-3.3-dev/trusty 1:3.3-16ubuntu1 amd64
llvm-3.3-doc/trusty 1:3.3-16ubuntu1 all
llvm-3.3-examples/trusty 1:3.3-16ubuntu1 all
llvm-3.3-runtime/trusty 1:3.3-16ubuntu1 amd64
llvm-3.4/trusty,now 1:3.4-1ubuntu3 amd64 [installed,automatic]
llvm-3.4-dev/trusty,now 1:3.4-1ubuntu3 amd64 [installed,automatic]
llvm-3.4-doc/trusty 1:3.4-1ubuntu3 all
llvm-3.4-examples/trusty 1:3.4-1ubuntu3 all
llvm-3.4-runtime/trusty,now 1:3.4-1ubuntu3 amd64 [installed,automatic]
llvm-3.5/trusty-updates,trusty-security 1:3.5-4ubuntu2~trusty2 amd64
llvm-3.5-dev/trusty-updates,trusty-security 1:3.5-4ubuntu2~trusty2 amd64
llvm-3.5-doc/trusty-updates,trusty-security 1:3.5-4ubuntu2~trusty2 all
llvm-3.5-examples/trusty-updates,trusty-security 1:3.5-4ubuntu2~trusty2 all
llvm-3.5-runtime/trusty-updates,trusty-security 1:3.5-4ubuntu2~trusty2 amd64
llvm-3.5-tools/trusty-updates,trusty-security 1:3.5-4ubuntu2~trusty2 amd64
llvm-3.6/trusty-updates 1:3.6-2ubuntu1~trusty1 amd64
llvm-3.6-dev/trusty-updates 1:3.6-2ubuntu1~trusty1 amd64
llvm-3.6-doc/trusty-updates 1:3.6-2ubuntu1~trusty1 all
llvm-3.6-examples/trusty-updates 1:3.6-2ubuntu1~trusty1 all
llvm-3.6-runtime/trusty-updates 1:3.6-2ubuntu1~trusty1 amd64
llvm-3.6-tools/trusty-updates 1:3.6-2ubuntu1~trusty1 amd64
llvm-3.8/trusty-updates 1:3.8-2ubuntu3~trusty4 amd64
llvm-3.8-dev/trusty-updates 1:3.8-2ubuntu3~trusty4 amd64
llvm-3.8-doc/trusty-updates 1:3.8-2ubuntu3~trusty4 all
llvm-3.8-examples/trusty-updates 1:3.8-2ubuntu3~trusty4 all
llvm-3.8-runtime/trusty-updates 1:3.8-2ubuntu3~trusty4 amd64
llvm-dev/trusty 1:3.4-0ubuntu1 amd64
llvm-gcc-4.7/trusty 3.3-2 amd64
llvm-gcc-4.8/trusty 3.3-2 amd64
llvm-runtime/trusty 1:3.4-0ubuntu1 amd64
apt list clang
Listing... Done
clang/trusty,now 1:3.4-0ubuntu1 amd64 [installed]

Additional Detail from JIRA
Votes 3
Component/s Compiler, LLDB for Swift
Labels Bug, CompilerCrash, REPL
Assignee qwerty (JIRA)
Priority Medium

Watchers: @shahmishal

md5: 9c53f82acf612e733b7f2dd8ea44b1d8

relates to:

  • SR-5524 Importing a modulemapped C library in REPL throws an error

Issue Description:

software: swift-3.0-RELEASE-ubuntu14.04.tar.gz
plateform: 3.13.0-92-generic #139-Ubuntu SMP Tue Jun 28 20:42:26 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Welcome to Swift version 3.0 (swift-3.0-RELEASE). Type :help for assistance.
  1> help
Segmentation fault (core dumped)

note: no core found... seg fault on all commands.
What am I missing?

which swift
echo $PATH
Copy link

'help' and ':help' are different but that shouldn't be the problem here.

Copy link

Comment by Alex (JIRA)

Actually, it crashes no matter the input, 1 + 1 results in a crash as well. Anyway I can get a core dump?

Not sure if useful, but just in case
strace -o output.txt swift
Welcome to Swift version 3.0 (swift-3.0-RELEASE). Type :help for assistance.
1> 1 + 1
Segmentation fault (core dumped)
attached, the strace output...

tail output.txt
clone(child_stack=0x7f22ecfeaf30, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f22ecfeb9d0, tls=0x7f22ecfeb700, child_tidptr=0x7f22ecfeb9d0) = 1320
futex(0x3179da4, FUTEX_WAIT_PRIVATE, 1, NULL <unfinished ...>
+++ killed by SIGSEGV (core dumped) +++

Copy link

Comment by Alex (JIRA)

:help actually does work though... so are commands preceded by ':'...
code such as let d = "test" result in crash

Welcome to Swift version 3.0 (swift-3.0-RELEASE). Type :help for assistance.
  1> :help

The REPL (Read-Eval-Print-Loop) acts like an interpreter.  Valid statements, expressions, and declarations are immediately compiled and executed.

The complete set of LLDB debugging commands are also available as described below.  Commands must be prefixed with a colon at the REPL prompt (:quit for example.)  Typing just a colon
followed by return will switch to the LLDB prompt.

Debugger commands:

  apropos           -- List debugger commands related to a word or subject.

Copy link

Comment by Alex (JIRA)

Hi Jordan,

I've tried on my own machine, seems to be working fine... but it's a 16.04. I know, it's not the right one, but can't really wait to get my stuff running on AWS Ubuntu 14.04.

I think I'm going to switch to the Swift-PREVIEW on 16.04 - and wait until it's released - so everything is clean.

I think there's a problem with 3.0 GA on AWS- ubuntu, not sure which one though.
Fell free to close this issue.

Copy link

Comment by Eric Sheppard (JIRA)

I got this crash in the REPL too, but with a stock Ubuntu 16.04 AWS EC2 instance. It basically would crash on any Swift code at all such as "1+1".

Then later after trying the 'swift build' command and getting an error about a header file in .../usr/lib/swift/CoreFoundation, i discovered the permissions of the header files in that directory were not readable by the world (only root), so i fixed the permissions with 'chmod -R a+r *' in the top-level usr directory and that fixed both the 'swift build' and the REPL no longer crashed after that! So it looks like it was due to a file permissions issue. Some of the files in the Ubuntu 16.04 Swift 3.0.2 tarball don't have proper world read permissions. Also the REPL should probably handle this condition more gracefully.

Copy link

swift-ci commented Feb 3, 2017

Comment by Mason Mark (JIRA)

I just noticed this same issue (with latest Swift 3.1 snapshot for Ubuntu 16.04), and verified that it is just the CoreFoundation headers in the tarball that cause the crashes. Once identified, it is easy to fix, but should be fixed in the tarball itself.

(Note that this issue probably manifests for many users, but not others, depending on how their UNIX users and groups are set up.)

SYMPTOM: Swift REPL (and other tools) crash when run by regular non-root user:

ubuntu@mason-linux-2017:~$ ls -l /swift
lrwxrwxrwx 1 root root 55 Feb  3 10:34 /swift -> swift-3.1-DEVELOPMENT-SNAPSHOT-2017-01-31-a-ubuntu16.04
ubuntu@mason-linux-2017:~$ swift
Welcome to Swift version 3.1-dev (LLVM a568eff4bf, Clang a27f59ecee, Swift 228feb1ee0). Type :help for assistance.
  1> print("oh no, it doesn't work for non-root user like me! :-( ")
error: Couldn't IRGen expression, no additional error

  1> ^D
ubuntu@mason-linux-2017:~$ sudo bash
root@mason-linux-2017:~# swift
Welcome to Swift version 3.1-dev (LLVM a568eff4bf, Clang a27f59ecee, Swift 228feb1ee0). Type :help for assistance.
  1> print("IT WORKS FOR ROOT, BRO! >:-D ")
  2> ^D

REASON: The CoreFoundation headers are not readable by all users:

root@mason-linux-2017:/swift# find . ! -perm -a+r

WORKAROUND: Fix permissions on CoreFoundation headers:

root@mason-linux-2017:/swift# chmod a+r /swift/usr/lib/swift/CoreFoundation/*
root@mason-linux-2017:/swift# find . ! -perm -a+r

CONFIRM: It works as expected after doing that, even for regular user:

root@mason-linux-2017:/swift# exit
ubuntu@mason-linux-2017:~$ swift
Welcome to Swift version 3.1-dev (LLVM a568eff4bf, Clang a27f59ecee, Swift 228feb1ee0). Type :help for assistance.
  1> print("now it works for even lowly users like me :D ")
now it works for even lowly users like me :D 
  2> ^D

Copy link

belkadan commented Feb 3, 2017

@shahmishal, any ideas why the permissions would get messed up like this?

Copy link

Comment by Søren Mortensen (JIRA)

mason (JIRA User), I had the same problem on 16.04 (Swift version 4.0.3) and this workaround fixed it for me.

Copy link

Copy link

Comment by Dmitriy Borovikov (JIRA)

The same problem exist on 16.04 (Swift version 4.2).

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 7, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

3 participants