Since a TLS key is the address of a block of memory, if a key is allocated after another one is freed, they could accidentally have the same value. I was aware of it and, as a result, TLS keys were assigned auto incremental IDs (the uCounter member) in order to check for reused keys. This turns out to be insufficient, as the if statement at [1] only does the check once. If a TLS key is reused twice or more, GetTlsObject() might not return a valid pointer even if the TLS object actually resides in the map.
In
src/env/thread_env.c
:Since a TLS key is the address of a block of memory, if a key is allocated after another one is freed, they could accidentally have the same value. I was aware of it and, as a result, TLS keys were assigned auto incremental IDs (the
uCounter
member) in order to check for reused keys. This turns out to be insufficient, as theif
statement at [1] only does the check once. If a TLS key is reused twice or more,GetTlsObject()
might not return a valid pointer even if the TLS object actually resides in the map.