-
Notifications
You must be signed in to change notification settings - Fork 292
Open
Labels
Description
Description
Static references to symbols obtained via dlsym behave unexpectedly in the latest release (29.0.14206865). Instead of returning the value of the variable, reading the static reference appears to return the address.
Steps from my environment
- Retrieve symbol pointer:
auto ptr_to_var = dlsym(pLib, "variable_name");
- Assign the symbol to a local static reference inside a function:
void foo(){
static auto &variable_name = *reinterpret_cast<int*>(ptr_to_var);
}
- Reading the reference returns the address rather than the value:
int foo(){
static auto &variable_name = *reinterpret_cast<int*>(ptr_to_var);
return variable_name; // returns `reinterpret_cast<int>(&variable_name)` instead of value of variable_name
}
Workaround
Passing the reference as an rvalue argument to a function seems to behave correctly:
void bar(int &&variable_name){
// reference reads correct
}
void foo(){
static auto &variable_name = *reinterpret_cast<int*>(ptr_to_var);
bar(variable_name);
}
A minimal test case could not be constructed, but the bug is reproducible in real usage as described above.
I am using a supported NDK
- I have checked and the NDK I'm using is currently supported
Affected versions
r29