Description
Hi, I am studying the https://github.com/fedochet/rust-proc-macro-expander which is an awesome project. And see the issue in rust-lang/rust#60593.
After a little bit of digging, my guess is, it is not related to ABI compatible problem. It seem to be related to the different of thread_local
storage of static linkage and dynamic linkage.
The actual panic is this line.
And state
is actually a thread_local
:
On the other hand, in your example code :
client.run
function will call Bridge::enter and set the state to BridgeState::Connected
. Note that this is statically link to main
crate.
And after that, when the actual TokenStream start to parse, Bridge::with will be called from shared library crate and it will trigger the panic.
It seem to be two thread local are different, such that the panic get raised. But I don't know enough about linux shared librrary and thread local mechanism to understand this bug.