I get a segmentation fault when trying to load my program. The crash happens in the function d_find_pack during demangling. The name which ultimately causes this error is: _ZN3Psi7VariantIIcPKcEE5visitIIRZN11VariantTest9TestVisit11test_methodEvEUlS2_E0_RZNS6_11test_methodEvEUlcE1_RZNS6_11test_methodEvEUlNS_4NoneEE_EEENS_13VariantDetail19SelectVisitorResultIIDpT_EE4typeEDpOSG_ I'll attach a GDB session tracking the error. This appears to be related to 64-bit, since the s_unary_num.num field is set to zero in this instance which on a 32-bit system would cause the s_binary.right field to be NULL, but that does not happen here. In any case I don't think the s_binary member should be accessed since the type is DEMANGLE_COMPONENT_LAMBDA, so I've fixed it by adding a case to d_find_pack to check for it: @@ -3467,7 +3467,8 @@ case DEMANGLE_COMPONENT_PACK_EXPANSION: return NULL; + case DEMANGLE_COMPONENT_LAMBDA: case DEMANGLE_COMPONENT_NAME: case DEMANGLE_COMPONENT_OPERATOR: case DEMANGLE_COMPONENT_BUILTIN_TYPE: I don't know if this is really the right place to fix it though.
Created attachment 4770 [details] GDB session with backtrace and dumps of relevant data structures
The best way to get a review of this patch is to submit it to GCC, where this code is canonically maintained. Also you might consider adding a regression test to the demangler test suite.
I checked in the fix and test case.