Issue 55684
Summary libc++: std::any_cast fails to cast T* when non-executed code is linked into binary (cause unknown)
Labels new issue
Assignees
Reporter luke-jr
    I have failed to find a way to reproduce this in a small test case, so all I can do is provide the code that breaks, a workaround for the issue, and description of what appears to be happening.

Broken git branch: https://github.com/luke-jr/bitcoin/tree/20220524-libc++bug-reproduce%5E
Workaround: https://github.com/luke-jr/bitcoin/commit/e73777b38c64e7309582c078f51ddb0c52a948ae

If `sweepprivkeys` is linked in (not even executed) that assigns `wallet_req.context` (a `std::any`) to a `WalletLoader*`, *all* attempts to any_cast `.context` in `EnsureWalletContext` (`src/wallet/rpc/util.cpp`) return nullptr due to a different `type_info` object being used, *even* for the "normal" codepath through `registerRpcs` that works fine if `sweepprivkeys` is excluded from the project (simply deleting the one assignment of `.context` is sufficient; again, note that `sweepprivkeys` is never actually executed in this scenario - it simply exists in the program).

Note that the workaround does *not* resolve the issue unless `assignContextHACK` also replaces the assignment in `registerRpcs` - using it in `sweepprivkeys` alone is insufficient.

To reproduce:

`./autogen.sh && ./configure '--enable-external-signer' '--enable-suppress-external-warnings' '--enable-zmq' 'CPPFLAGS=-DARENA_DEBUG -DDEBUG_LOCKORDER' 'CXXFLAGS=-g'  'CC=clang' 'CXX=clang++ -stdlib=libc++' '--disable-shared' '--with-pic' '--enable-benchmark=no' --without-bdb && make -j16 && test/functional/wallet_create_tx.py --descriptors`
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to