Swift 4.2 runtime and Glibc backtrace function on s390x


#1

I am running into a strange problem on s390x architecture. Can't figure out what could be going on ...

On s390x test/Runtime/backtrace.swift fails to show the stack trace.

Here's the output of executing the following testcase:

cat bt.swift
let x = UnsafePointer<Int>(bitPattern: 0)!
print("\(x.pointee)")

./bt
Fatal error: Unexpectedly found nil while unwrapping an Optional value: file bt.swift, line 1
Current stack trace:
Illegal instruction (core dumped)

As you can see no stack trace is output upon running the testcase.

Swift's Error.cpp calls Glibc's backtrace function to obtain backtraces. This function on it's own works on s390x - i.e., I am able to get backtrace when I have a sample cpp program which calls Glibc's backtrace directly.

This leads me to believe that somehow Swift runtime on s390x is preventing the Glibc's backtrace function to function correctly. Interestingly on x86 Linux - this problem does not appear with Swift + glibc.

I am wondering if there is some Swift compile time flag missing on s390x which could result in such behavior.

Would appreciate any other pointers related to this error.

Thanks.