[PATCH] D33784: Bug 33206 - Sanitizer CHECK failed: ((allocated_for_dlsym)) < ((kDlsymAllocPoolSize)) (1036, 1024)) with preload

Denis Khalikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 2 01:44:11 PDT 2017


denis13 added a comment.

I forgot to provide full explanation, sorry for that.

This issue happens with LD_PRELOAD on Linux (x86_64 and armv7l)

When we set LD_PRELOAD to libasan and trying to execute binary which was not build with asan, we got following error:

  12007:	
  12007:	calling init: /lib/x86_64-linux-gnu/libpthread.so.0
  12007:	
  12007:	
  12007:	calling init: /lib/x86_64-linux-gnu/libc.so.6
  12007:	
  12007:	
  12007:	calling init: /usr/lib/x86_64-linux-gnu/libgraphite2.so.3
  12007:	
  12007:	
  12007:	calling init: /usr/lib/x86_64-linux-gnu/libXdmcp.so.6
  12007:	
  12007:	
  12007:	calling init: /usr/lib/x86_64-linux-gnu/libXau.so.6
  12007:	
  12007:	
  12007:	calling init: /usr/lib/x86_64-linux-gnu/libdatrie.so.1
  12007:	
  12007:	
  12007:	calling init: /lib/x86_64-linux-gnu/libexpat.so.1
  12007:	
  12007:	
  12007:	calling init: /lib/x86_64-linux-gnu/libpcre.so.3
  12007:	
  12007:	
  12007:	calling init: /lib/x86_64-linux-gnu/libglib-2.0.so.0
  12007:	
  12007:	
  12007:	calling init: /lib/x86_64-linux-gnu/libz.so.1
  12007:	
  12007:	
  12007:	calling init: /lib/x86_64-linux-gnu/libm.so.6
  12007:	
  12007:	
  12007:	calling init: /lib/x86_64-linux-gnu/libpng12.so.0
  12007:	
  12007:	
  12007:	calling init: /usr/lib/x86_64-linux-gnu/libfreetype.so.6
  12007:	
  12007:	
  12007:	calling init: /usr/lib/x86_64-linux-gnu/libharfbuzz.so.0
  12007:	
  12007:	
  12007:	calling init: /lib/x86_64-linux-gnu/libresolv.so.2
  12007:	
  12007:	
  12007:	calling init: /usr/lib/x86_64-linux-gnu/libxcb.so.1
  12007:	
  12007:	
  12007:	calling init: /usr/lib/x86_64-linux-gnu/libxcb-render.so.0
  12007:	
  12007:	
  12007:	calling init: /usr/lib/x86_64-linux-gnu/libxcb-shm.so.0
  12007:	
  12007:	
  12007:	calling init: /usr/lib/x86_64-linux-gnu/libpixman-1.so.0
  12007:	
  12007: ==Sanitizer== CHECK failed: /home/denis/gcc-trunk/gcc/libsanitizer/asan/asan_malloc_linux.cc:40 ((allocated_for_dlsym)) < ((kDlsymAllocPoolSize)) (1036, 1024)

As far as i understood rtld does not provide the order in which shared libs gonna be initializing.
In this case we have faced the situation when asan initializing later than some shared libraries.
As we can see at the debug log above, crash happens when rtld calling static constructor in libpixman
and this constructor has malloc.

call:

  static void __attribute__((constructor))
   pixman_constructor (void)
   {
       global_implementation = _pixman_choose_implementation ();
   }  

call :_pixman_choose_implementation
call :_pixman_implementation_create_general
call: _pixman_implementation_create

  pixman_implementation_t *
   _pixman_implementation_create (pixman_implementation_t *fallback,
                                  const pixman_fast_path_t *fast_paths)
   {
      pixman_implementation_t *imp;
           
       assert (fast_paths);
       
       if ((imp = malloc (sizeof (pixman_implementation_t))))
       {
           pixman_implementation_t *d; 
   
           memset (imp, 0, sizeof *imp);
   
           imp->fallback = fallback;
           imp->fast_paths = fast_paths; 
           
           /* Make sure the whole fallback chain has the right toplevel */ 
           for (d = imp; d != NULL; d = d->fallback)
              d->toplevel = imp;
       }
          
      return imp;
   }   

In this case we can just increase local pool size.
But should we make more flexible solution with dynamic allocation ?

Thanks.


https://reviews.llvm.org/D33784





More information about the llvm-commits mailing list