Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dynamic_cast fails across modules for dynamic linking #8392

Closed
awtcode opened this issue Apr 3, 2019 · 3 comments
Closed

dynamic_cast fails across modules for dynamic linking #8392

awtcode opened this issue Apr 3, 2019 · 3 comments

Comments

@awtcode
Copy link
Contributor

awtcode commented Apr 3, 2019

@kripken and @sbc100 , I have created a new issue for this problem as I believe the root cause is not about pointer inequality. The issue here is that the pointer to the type info is duplicated and since dynamic_cast relies on pointer comparison, the dynamic_cast fails.

The problem can be reproduced when we pass a derived pointer to a function in another module. The dynamic_cast fails in the other module.

main.cpp
`EMSCRIPTEN_KEEPALIVE extern "C"
void mainy(base * arg) {
derived * temp = dynamic_cast < derived * > (arg);
printf("temp:%p\n", temp);
}

extern "C" void sidey(base* arg);

int main() {
derived* temp = new derived();
printf("main: temp:%p\n", temp);
sidey(temp);
return 0;
}`

side.cpp
`EMSCRIPTEN_KEEPALIVE extern "C"
void sidey(base* arg) {
derived * temp1 = dynamic_cast < derived * > (arg);
printf("sidey: arg:%p temp1:%p\n", arg, temp1);

base* temp = new derived();
mainy(temp);
}`

@sbc100
Copy link
Collaborator

sbc100 commented Apr 3, 2019

Thanks. You are correct in your diagnosis I believe. However I already opened an issue and added a test for this. See #8376 and #8377.

@sbc100 sbc100 closed this as completed Apr 3, 2019
@sbc100
Copy link
Collaborator

sbc100 commented Apr 3, 2019

The function pointer equality issue is a separate one that also has an issue and a tested too: #8330 and #8268

@awtcode
Copy link
Contributor Author

awtcode commented Apr 4, 2019

Thanks for the update @sbc100 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants