Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Exceptions don't work when used with -fvisibility=hidden #51546

Open Quuxplusone opened 2 years ago

Quuxplusone commented 2 years ago
Bugzilla Link PR52579
Status NEW
Importance P normal
Reported by Daniel Schopf (schopf.dan@gmail.com)
Reported on 2021-11-22 07:24:31 -0800
Last modified on 2021-11-24 07:14:48 -0800
Version 13.0
Hardware PC Linux
CC llvm-bugs@lists.llvm.org, mclow.lists@gmail.com, nok.raven@gmail.com
Fixed by commit(s)
Attachments exception.cpp (333 bytes, text/x-c++src)
exception.h (274 bytes, text/x-chdr)
test.cpp (223 bytes, text/x-c++src)
Blocks
Blocked by
See also PR39191
Created attachment 25466
exception source file

Using exceptions in shared libraries compiled with -fvisibility=hidden yields
the wrong results

Steps to Reproduce:

  1. Compile the attached files with the following commands:

    clang++ -shared -stdlib=libc++ -fvisibility=hidden exception.cpp -o libexception.so
    clang++ -stdlib=libc++ test.cpp libexception.so -o exception_test

  2. Run the exception_test binary

Actual Results:

  The output is "Error value = -2"

Expected Results:

  The output should be "Error value = 1"

This error cannot be reproduced when either removing the -fvisibility=hidden
switch or
when using -stdlib=libstdc++. So using -stdlib=libstdc++ together with -
fvisibility=hidden
produces the correct output.

Reproduced with clang-13 on Arch Linux.
Quuxplusone commented 2 years ago

Attached exception.cpp (333 bytes, text/x-c++src): exception source file

Quuxplusone commented 2 years ago

Attached exception.h (274 bytes, text/x-chdr): exception header file

Quuxplusone commented 2 years ago

Attached test.cpp (223 bytes, text/x-c++src): test code