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-1093] Cannot run swift REPL in 2016-03-24-a-ubuntu15.10 dev snapshot #4529

Closed
swift-ci opened this issue Mar 29, 2016 · 14 comments
Closed
Labels

Comments

@swift-ci
Copy link

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

FROM ubuntu:15.10

RUN apt-get -y update && apt-get install -y \
wget \
git \
rsync \
clang \
libicu-dev \
libpython2.7-dev \
libxml2 \
autoconf \
libtool \
pkg-config \
systemtap-sdt-dev \
libblocksruntime-dev \
libkqueue-dev \
libbsd-dev

ENV SWIFT_BRANCH development
ENV SWIFT_VERSION DEVELOPMENT-SNAPSHOT-2016-03-24-a
ENV SWIFT_PLATFORM ubuntu15.10

  1. Install Swift keys
    RUN wget -q -O - https://swift.org/keys/all-keys.asc | gpg --import - && \
    gpg --keyserver hkp://pool.sks-keyservers.net --refresh-keys Swift
  1. Install Swift Ubuntu 15.10 Snapshot
    RUN SWIFT_ARCHIVE_NAME=swift-$SWIFT_VERSION-$SWIFT_PLATFORM && \
    SWIFT_URL=https://swift.org/builds/$SWIFT_BRANCH/$(echo "$SWIFT_PLATFORM" | tr d .)/swift$SWIFT_VERSION/$SWIFT_ARCHIVE_NAME.tar.gz && \
    wget $SWIFT_URL && \
    wget $SWIFT_URL.sig && \
    gpg --verify $SWIFT_ARCHIVE_NAME.tar.gz.sig && \
    tar -xvzf $SWIFT_ARCHIVE_NAME.tar.gz --directory / --strip-components=1 && \
    rm -rf $SWIFT_ARCHIVE_NAME* /tmp/* /var/tmp/*
  1. Set Swift Path
    ENV PATH /usr/bin:$PATH
  1. Print Installed Swift Version
    RUN swift --version
Additional Detail from JIRA
Votes 1
Component/s LLDB for Swift
Labels Bug, Linux, REPL
Assignee k8stone (JIRA)
Priority Medium

md5: add30712c212582258f5b9fecc929001

Issue Description:

I install dependencies, download and install the last development snapshot of Swift. I can build packages and run "swift --version" but if I just try to run "swift" I get this error.

==5515==ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.

I have a docker container available for testing with if you need it.

@belkadan
Copy link

Did we accidentally post an ASan-enabled LLDB?

@swift-ci
Copy link
Author

Comment by Joel Saltzman (JIRA)

I'm not sure. How can I check for you?

@belkadan
Copy link

I, hm. I'm not sure either. @AnnaZaks, granataenrico (JIRA User)?

@AnnaZaks
Copy link
Mannequin

AnnaZaks mannequin commented Mar 30, 2016

Looks like the new warning we added in ASan.

Most likely a library that has been built with ASan is being dlopened. We can check if a library has been built with ASan by checking if it's been linked against the ASan runtime:
$ otool -L ~/tmp/a.out | grep "libclang_rt.asan_osx_dynamic.dylib"
@rpath/libclang_rt.asan_osx_dynamic.dylib (compatibility version 0.0.0, current version 0.0.0)

@swift-ci
Copy link
Author

swift-ci commented Apr 9, 2016

Comment by Joel Saltzman (JIRA)

Is there a certain path that I can check? Or should I wait for the next release?

@swift-ci
Copy link
Author

Comment by Jay Buffington (JIRA)

Still broken in swift-DEVELOPMENT-SNAPSHOT-2016-04-12-a-ubuntu14.04.tar.gz

@swift-ci
Copy link
Author

Comment by Kate Stone (JIRA)

I have our swift-DEVELOPMENT-SNAPSHOT-2016-04-12-a-ubuntu14.04.tar.gz snapshot installed on an ubuntu14.04 machine and the REPL works normally, so I suspect there's something else in play here.

@swift-ci
Copy link
Author

Comment by Kate Stone (JIRA)

Since this doesn't happen to everyone chances are one or more system libraries have been built using ASAN and are getting loaded by the REPL. You can debug the dynamic library loading process and hopefully get more insight into where the failure is occurring with the following from the snapshot's root directory:

LD_DEBUG=files usr/bin/lldb --repl

This will start the debugger in REPL mode (swift is just a wrapper that does essentially the same thing) with the dynamic linker's debugging mode engaged. It should print out progress as it finds and initializes each library so you can see what library is failing to initialize.

@trfiala
Copy link
Mannequin

trfiala mannequin commented Apr 25, 2016

Hi Joel,

I just straightened out some issues with importing modules in the REPL on Ubuntu 15.10 (and Ubuntu 14.04) this past weekend. Can you try this again with a clean build directory? (Those fixes were listed in SR-1109 - they would become problematic at some point when using the REPL on Ubuntu, even if they weren't what you were hitting directly).

If you continue to have trouble, please post the exact build-script line you are using to do the build, along with the hashes you are synched against for each of the repositories.

Thanks!

@swift-ci
Copy link
Author

Comment by Kate Stone (JIRA)

We've now seen the failure even without the REPL involved, just launching LLDB will trigger this problem on an affected machine so I don't think this experiment is needed. The current working theory is that installing the snapshot package to the root directory ✔ is what leads to this problem, though I'm still interested in the exact mechanism and will be investigating further.

@trfiala
Copy link
Mannequin

trfiala mannequin commented Apr 25, 2016

Yes, I'd be very skeptical of installing the package to Root. Before we went public, I had us pull out references to doing that in the "How to use on Ubuntu" instructions because (1) we haven't tested that heavily, (2) installing in root is inherently the kind of thing that should be done by somebody making official packages for the system, where it really gets tested against a live system, (3) it seems likely to conflict if a system has clang/llvm installed or any other components that are .so files and/or lay down other static resources we look at, but are for "straight clang" vs. "the clang we build and use from LLDB that match the Swift build we made", etc. It's definitely not a tested configuration and I'm sure there are some gotchas there. As an aside, there is also a readline.so Python module that will quite likely clobber the system Python readline.so package, which is definitely not something you want to have happen. (The Ubuntu readline.so is used by LLDB to suppress a conflict between system Python readline.so pulling in the GNU readline module, which cannot co-exist with libedit, which LLDB and the REPL pull in when python is executed within LLDB).

Eventually we look forward to somebody doing some real packaging for Linux distributions, during which I expect some of these issues would be (need to be) resolved.

@swift-ci
Copy link
Author

Comment by Kate Stone (JIRA)

Indeed this proved to be the root issue. When LLDB is installed in /usr/bin/lldb we also wind up with content under /usr/lib/lldb that are presumed to be plugins – even though they aren't. When an ASAN enabled library is loaded to initialize the plugin it notices LLDB isn't running with the ASAN runtime and immediately terminates it.

Workarounds: don't install Swift packages in the root directory, or install and then rename /usr/lib/lldb to /usr/lib/lldb-disabled.

A fix for this is being tracked as <rdar://problem/25921276>

@swift-ci
Copy link
Author

Comment by Joel Saltzman (JIRA)

mv /usr/lib/lldb /usr/lib/lldb-disabled

This did indeed fix the problem. Thank you!

@swift-ci
Copy link
Author

Comment by Kate Stone (JIRA)

Fixed upstream (Committed revision 267749.)

Cherry picked to master:
commit ec12d4930bf8a7d19c22da4ae2bea405b464a4a7 (HEAD -> master, origin/master, origin/HEAD)
Author: Kate Stone <katherine.stone@apple.com>
Date: Wed Apr 27 10:49:51 2016

Renamed system plugin directory to address https://bugs.swift.org/browse/SR-1093

@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
Labels
Projects
None yet
Development

No branches or pull requests

2 participants