[PATCH] D40382: Plug dlerror() leak for swift_demangle

Kamil Rytarowski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 22 22:16:16 PST 2017


krytarowski created this revision.
krytarowski added a project: Sanitizers.

InitializeSwiftDemangler() attempts to resolve the
swift_demangle symbol. If this is not available, we
observe dlerror message leak.

Caught on NetBSD/amd64 in TSan.

Sponsored by <The NetBSD Foundation>


Repository:
  rL LLVM

https://reviews.llvm.org/D40382

Files:
  lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc


Index: lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc
===================================================================
--- lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc
+++ lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc
@@ -77,6 +77,7 @@
 // symbolication.
 static void InitializeSwiftDemangler() {
   swift_demangle_f = (swift_demangle_ft)dlsym(RTLD_DEFAULT, "swift_demangle");
+  (void)dlerror(); // Cleanup error message in case of failure
 }
 
 // Attempts to demangle a Swift name. The demangler will return nullptr if a


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40382.124036.patch
Type: text/x-patch
Size: 566 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171123/83387a3f/attachment.bin>


More information about the llvm-commits mailing list