On Sat, May 07, 2016 at 12:05:11AM +0800, Marcel Böhme wrote: > This patch also removes the following part of the comment for method > cplus_demangle_print_callback: > "It does not use heap memory to build an output string, so cannot encounter > memory allocation failure”.
But that exactly is the thing I've talked about. Removing the comment doesn't make it right, supposedly it has been done that way for a reason. The file has lots of different entrypoints, some of them depend on various macros on what is it built for (libstdc++, libgcc, binutils/gdb/gcc in libiberty, ...). And some of them clearly can cope with memory allocation failures, but they should be turned into the allocation_failure flag setting. Others don't want any allocations. E.g. if you read the description of __cxa_demangle, there is *STATUS is set to one of the following values: 0: The demangling operation succeeded. -1: A memory allocation failure occurred. -2: MANGLED_NAME is not a valid name under the C++ ABI mangling rules. -3: One of the arguments is invalid. and thus, it should be ensured that we end up with *STATUS -1 even for the cases where malloc failed on those. But then look at e.g. __gcclibcxx_demangle_callback (but there are various others). Jakub