Skip to content

On QEMU, swift immediate mode crashes due to relative pointer relocation failure #60673

Open
@sonsongithub

Description

@sonsongithub

Describe the bug
When I call CommandLine.arguments.first, swift-frontend crashes.

Source code, test.swift.

if let obj = CommandLine.arguments.first {
    print(obj)
}

Steps To Reproduce
Steps to reproduce the behavior:

  1. $ echo "if let obj = CommandLine.arguments.first { print(obj) }" > test.swift
  2. $ docker run --rm -it -v $(pwd):/src --platform linux/amd64 swift:5.6.2 swift /src/test.swift
  3. It crashes.

I got following results,

# swift test.swift "ok"
Stack dump:
0.	Program arguments: /usr/bin/swift-frontend -frontend -interpret test.swift -disable-objc-interop -color-diagnostics -new-driver-path /usr/bin/swift-driver -resource-dir /usr/lib/swift -module-name test -- ok
1.	Swift version 5.6.2 (swift-5.6.2-RELEASE)
2.	Compiling with the current language version
4.	While running user code "test.swift"
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
/usr/bin/swift-frontend[0x5187de3]
/usr/bin/swift-frontend[0x5185b7e]
/usr/bin/swift-frontend[0x5188176]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x12980)[0x4000a46980]
/usr/lib/swift/linux/libswiftCore.so(swift_getTypeByMangledName+0x162)[0x40012676a2]
/usr/lib/swift/linux/libswiftCore.so(swift_getTypeByMangledNameInContext+0xa7)[0x4001267c97]
[0x4011a2b3f4]
[0x4011a2b1d2]
/usr/bin/swift-frontend[0x5cd69a]
/usr/bin/swift-frontend[0x4d4404]
/usr/bin/swift-frontend[0x499e69]
/usr/bin/swift-frontend[0x4993ed]
/usr/bin/swift-frontend[0x48dfb8]
/usr/bin/swift-frontend[0x4463af]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0x4002628c87]
/usr/bin/swift-frontend[0x445dda]
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
Segmentation fault

Expected behavior
Expected results(this results got from swiftc command.)

> swiftc test.swift
> ./test
error
Array<String>
./test

Screenshots
Nothing.

Environment (please fill out the following information)

  • Host machine: MacBook Pro (14-inch, 2021)
  • macOS 12.5.1
  • Docker.app(v4.11.1)
  • Dockerfile
  • OS: Linux 2afa64e6e5c2 5.10.104-linuxkit x86_64 x86_64 x86_64 GNU/Linux
  • Swift version 5.6.2 (swift-5.6.2-RELEASE)
  • Target: x86_64-unknown-linux-gnu

Additional context
Nothing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    JITbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.crashBug: A crash, i.e., an abnormal termination of softwareswift 5.6

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions