<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - address sanitizer and jni does not work"
   href="https://llvm.org/bugs/show_bug.cgi?id=31861">31861</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>address sanitizer and jni does not work
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.9
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Static Analyzer
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>kremenek@apple.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>physiker@toast2.net
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=17935" name="attach_17935" title="Source code and make.sh">attachment 17935</a> <a href="attachment.cgi?id=17935&action=edit" title="Source code and make.sh">[details]</a></span>
Source code and make.sh

I utilize the address sanitizer to detect errors in shared libraries. When I
try to interface a shared library with java via jni the address
sanitizer it does no longer work. This has been working with gcc versions 5, 6
and
earlier versions of gcc 7.

For previous version of gcc setting DYLD_INSERT_LIBRARIES is not necessary.
Setting DYLD_INSERT_LIBRARIES as suggested for current versions of gcc 7 on
the x86_64-apple-darwin15.6.0 target does not solve the issue.

I do not know how to successfully preload libasan on darwin. It does
not seem to work for the version of clang shipped with the operating system
(Apple LLVM version 8.0.0 (clang-800.0.42.1)) or with clang 3.9.0, either:
Therefore,
Maxim Ostapenko asked me to submit a bug report in the LLVM bug tracker:
(See <a href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79096">https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79096</a>)

|Could you please raise a bug in LLVM bug tracker (<a href="https://llvm.org/bugs/">https://llvm.org/bugs/</a>)? All
|changes to sanitizer runtime library should go to LLVM and after they fix this
|bug we can backport corresponding patch to GCC.

./make.sh 
libTasan.c:7:3: warning: array index 10 is past the end of the array (which
      contains 10 elements) [-Warray-bounds]
  stack_array[10] = 0;
  ^           ~~
libTasan.c:6:3: note: array 'stack_array' declared here
  int stack_array[10];
  ^
1 warning generated.
==99845==ERROR: Interceptors are not working. This may be because
AddressSanitizer is loaded too late (e.g. via dlopen). Please launch the
executable with:
DYLD_INSERT_LIBRARIES=/sw/opt/llvm-3.9/lib/clang/3.9.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib
"interceptors not installed" && 0./make.sh: line 7: 99845 Abort trap:
6
DYLD_INSERT_LIBRARIES=/sw/opt/llvm-3.9/lib/clang/3.9.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib
java Tasan

clang-3.9 --version
clang version 3.9.0 (tags/RELEASE_390/final)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /sw/bin</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>