From the source code of the __cxa_demangle or libcxxrt: https://github.com/pathscale/libcxxrt/blob/c94e7e03165e26a085cd1f7b887c5aec15f387a9/src/typeinfo.cc#L95 It seems in this case the buf and n are all NULL, thus the status won’t be changed when the function returned. I have tried it works with libstdc++ And from https://github.com/llvm-mirror/libcxx/blob/e013dacf4a4217343f82b2b5fddb2428d26572c5/test/support/demangle.h the libc++ test use the same check. The patch LGTM, we just keep the status here to avoid other problem. And maybe you could add some inline comments about this.
Thanks Xiuli -----Original Message----- From: Beignet [mailto:beignet-boun...@lists.freedesktop.org] On Behalf Of Jan Beich Sent: Friday, March 17, 2017 8:08 PM To: beignet@lists.freedesktop.org Subject: [Beignet] [PATCH] Properly check return value from __cxa_demangle FreeBSD uses libcxxrt (not GCC) for __cxa_demangle which doesn't modify status variable on success thus makes Beignet rely on unitialized value. Instead, assume it'd return NULL on failure. https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=213732 --- backend/src/llvm/llvm_gen_backend.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/llvm/llvm_gen_backend.hpp b/backend/src/llvm/llvm_gen_backend.hpp index 1ab77c9d..fde5e705 100644 --- a/backend/src/llvm/llvm_gen_backend.hpp +++ b/backend/src/llvm/llvm_gen_backend.hpp @@ -84,7 +84,7 @@ namespace gbe if (it == map.end()) { int status; char *realName = abi::__cxa_demangle(symbol.c_str(), NULL, NULL, &status); - if (status == 0) { + if (realName) { std::string realFnName(realName), stripName; stripName = realFnName.substr(0, realFnName.find("(")); it = map.find(stripName); _______________________________________________ Beignet mailing list Beignet@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/beignet _______________________________________________ Beignet mailing list Beignet@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/beignet