[Issue 23061] Exceptions cannot be caught by catch statement in static build

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun May 22 12:56:25 UTC 2022


https://issues.dlang.org/show_bug.cgi?id=23061

--- Comment #2 from Tomoya Tanjo <ttanjo at gmail.com> ---
I found that this issue only happens when dmd is built with
`DRuntime_Use_Libunwind`.

I built dmd with `DRuntime_Use_Libunwind` on Alpine Linux edge and obtained the
following results.

When `app.d` is built without `-lunwind`, it works as intended as follows:
```console
$ ./dmd/generated/linux/release/64/dmd -c app.d
$ cc app.o -o app -m64 -static -Xlinker --export-dynamic
-L./dmd/generated/linux/release/64/../../../../../phobos/generated/linux/release/64
-Xlinker -Bstatic -lphobos2 -lpthread -lm -lrt -ldl
$ ./app
$ echo $?
0
```

On the other hand, when it is built with `-lunwind`, it does not work as
reported.
```console
$ ./dmd/generated/linux/release/64/dmd -c app.d
$ cc app.o -o app -m64 -static -Xlinker --export-dynamic
-L./dmd/generated/linux/release/64/../../../../../phobos/generated/linux/release/64
-Xlinker -Bstatic -lphobos2 -lpthread -lm -lrt -ldl -lunwind
$ ./app
src/rt/dwarfeh.d:330: uncaught exception reached top of stack
This might happen if you're missing a top level catch in your fiber or signal
handler
object.Exception at app.d(5): aa
Aborted
$ echo $?
134
```

--


More information about the Digitalmars-d-bugs mailing list