Uploaded image for project: 'Swift'
  1. Swift
  2. SR-12532

swift run --repl crashes with C/C++ dependencies

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: LLDB for Swift
    • Labels:
      None

      Description

      The swift compiler with versions 5.1.3, 5.2 crashes if you run any project containing C/C++ dependencies with --repl attribute: `swift run --repl`.

      This behavior appears on macOS only, on Ubuntu 18 same packages works well in the same situation. The crash appears on import Swift Package that contains the C/C++ dependencies into repl.

      • The `swift test`┬ácommand within the same setup works properly.
      • The same project, but as executable (e.g. MyLibrary.swift renamed to main.swift) works properly with `swift run` command.

      Steps to reproduce:
      1. `swift package init --type library MyLibrary`.
      2.1 Add the following dependency to the package dependencies: `.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.0.0")`.
      2.2 Add follow dependency to MyLibrary target dependencies: `.product(name: "AsyncHTTPClient", package: "async-http-client"),`.
      3. Run `swift run --repl`.
      4. In swift console console type: `import MyLibrary`.

      Expected behavior:

      Package loads and its public types and methods are available within repl runtime.

      Current behavior:

      Repl crashes with the following stacktrace:

      warning: Swift error in fallback scratch context: <module-includes>:1:9: note: in file included from <module-includes>:1:
       #import "/Volumes/devel/Programming/swift/CourtParser/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h"
       ^
      error: /Volumes/devel/Programming/swift/CourtParser/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h:22:10: error: 'CNIOBoringSSL.h' file not found
       #include "CNIOBoringSSL.h"
       ^
      error: could not build Objective-C module 'CNIOBoringSSLShims'
      note: This error message is displayed only once. If the error displayed above is due to conflicting search paths to Clang modules in different images of the debugged executable, this can slow down debugging of Swift code significantly, since a fresh Swift context has to be created every time a conflict is encountered.
      0 lldb 0x0000000103a43f08 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
       1 lldb 0x0000000103a434c5 llvm::sys::RunSignalHandlers() + 85
       2 lldb 0x0000000103a44550 SignalHandler(int) + 272
       3 libsystem_platform.dylib 0x00007fff7218f5fd _sigtramp + 29
       4 libsystem_platform.dylib 0x000070000baca650 _sigtramp + 2576593008
       5 LLDB 0x0000000103caa957 lldb_private::IOHandlerEditline::Run() + 375
       6 LLDB 0x0000000103c92b89 lldb_private::Debugger::ExecuteIOHandlers() + 105
       7 LLDB 0x0000000103c95463 lldb_private::Debugger::IOHandlerThread(void*) + 19
       8 LLDB 0x0000000103d3c547 lldb_private::HostNativeThreadBase::ThreadCreateTrampoline(void*) + 103
       9 libsystem_pthread.dylib 0x00007fff7219b109 _pthread_start + 148
       10 libsystem_pthread.dylib 0x00007fff72196b8b thread_start + 15
       [1] 7804 segmentation fault swift run --repl

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            yaroslav_ya Yaroslav
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: