You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Empirical's pointer tracking infrastructure assumes that object addresses don't change, so when an object is deleted it looks up its address in a table of allocated addresses. But C++ sometimes does change object addresses, specifically with multiple inheritance but this should also happen sometimes with particularly large single inheritance situations although I haven't found an example where that actually happens with single inheritance. Specifically, in the example below the compiler moves the pointer to C forward a little bit to get the B pointer, and the virtual destructor knows how to get the original pointer back but Empirical doesn't.
To Reproduce
Here's a minimal example that fails with -DEMP_TRACK_MEM, but is valid C++ and passes AddressSanitizer:
Expected behavior
The above program doesn't actually contain any memory management errors (as far as I know, and AddressSanitizer agrees), so pointer tracking should not produce any.
Toolchain:
OS: Arch Linux
Compiler: GCC 12.2.0
Empirical Version: current master, but I originally found this problem in Symbulation with 1fe7f9008c
The text was updated successfully, but these errors were encountered:
I just found out that dynamic_cast<void*>(ptr) will obtain the base address of the real object allocation, so using that in Ptr::Delete() and similar methods should hopefully fix this problem. I've made that change in PR #477.
Describe the bug
Empirical's pointer tracking infrastructure assumes that object addresses don't change, so when an object is deleted it looks up its address in a table of allocated addresses. But C++ sometimes does change object addresses, specifically with multiple inheritance but this should also happen sometimes with particularly large single inheritance situations although I haven't found an example where that actually happens with single inheritance. Specifically, in the example below the compiler moves the pointer to
C
forward a little bit to get theB
pointer, and the virtual destructor knows how to get the original pointer back but Empirical doesn't.To Reproduce
Here's a minimal example that fails with
-DEMP_TRACK_MEM
, but is valid C++ and passes AddressSanitizer:Expected behavior
The above program doesn't actually contain any memory management errors (as far as I know, and AddressSanitizer agrees), so pointer tracking should not produce any.
Toolchain:
1fe7f9008c
The text was updated successfully, but these errors were encountered: