+++ This bug was initially created as a clone of Bug #372120 +++ For the below code, the demanglers demangle a non c++ symbol as if it would be a mangled c++ name. This was detected on an Ada program (as gnat mangles Ada names by replacing . by __) but that equally happens on c symbols having 2 underscores. To reproduce: gcc -g -o demang demang.c ./vg-in-place --leak-check=full ./demang ==30660== 90 bytes in 9 blocks are definitely lost in loss record 2 of 2 ==30660== at 0x4C27BB5: malloc (vg_replace_malloc.c:299) ==30660== by 0x400515: main__calling__some(...)(long long,...)(char) (demang.c:7) ==30660== by 0x40052C: main (demang.c:12) #include <stdlib.h> char *v; void main__calling__some__exec(void) { int i; for (i = 0; i < 10; i++) v = malloc(10); } main () { main__calling__some__exec(); }
Currently we only support demangling (modern) C++ style symbol demangling (which includes Rust demangling, which is based on C++/gnu_v3 style demangling). This is because not all demangling styles can be auto-detected (we only handle symbols starting with "_Z" at the moment). We could detect the language if we have debuginfo from the CU DW_AT_language covering the symbol address. In that case we could set the language style first before calling ML_(cplus_demangle). See demangle.h for the language styles supported.