ramosian-glider / sanitizer-issues

test
0 stars 0 forks source link

asan crashes in jni #58

Closed ramosian-glider closed 9 years ago

ramosian-glider commented 9 years ago

Originally reported on Google Code with ID 58

What steps will reproduce the problem?
My code uses jni to access hadoop hdfs file. it seems asan is not compatible with code
in jvm.

What is the expected output? What do you see instead?
asan crashes.

What version of the product are you using? On what operating system?
llvm 3.1, centos 6.2, java 1.7

Please provide any additional information below.
the crash message is attached.

Reported by huas.su on 2012-03-29 09:10:08


ramosian-glider commented 9 years ago
Hi!
Could you give steps to reproduce the problem? Is it possible to somehow symbolize
the stack trace (e.g, what stack trace do you get under gdb if you compile with "-g")?
Also, it would be great if you provide the whole stderr when you run your test with
ASAN_OPTIONS=verbosity=2. Currently we see problems when C++ libraries compiled with
ASan are called from Java, but it's probably not the case here.

Reported by samsonov@google.com on 2012-03-29 13:45:05

ramosian-glider commented 9 years ago
Two more things to do:

1. Run the program under strace -f
2. Run the program with ASAN_OPTIONS=sleep_before_dying=100. When the program crashes,
dump the contents of /proc/<PID>/maps (PID is printed between "=="s in the log).
You can also try to run gdb -p <PID> and look at the stack trace there, but the top
frames are most probably originating from Java, so it won't help much (I may be mistaking).

Reported by ramosian.glider on 2012-03-29 14:26:40

ramosian-glider commented 9 years ago
we don't have enough information to proceed. 

Reported by konstantin.s.serebryany on 2012-04-09 22:42:24

ramosian-glider commented 9 years ago
Hi, I have a similar problem as the one that was reported, with the same error line:

ASAN:SIGSEGV
ERROR: AddressSanitizer crashed on unknown address 0x000000000008

In my case, I am trying to start a Java program that calls into a native library, which
I would like to check for illegal memory accesses. However, ASan crashes shortly after
starting the JVM (maybe that is what was stated in comment #1 ?).

AFAIK, SIGSEGV is used internally by the JVM (I am using sun/oracle jdk 1.6+1.7). There
is some option to "reduce signal usage" (-Xrs), but SIGSEGV cannot be deactivated.

Is there some solution/hint how it would be possible to handle/ignore SIGSEGV?

Reported by polygox on 2013-03-17 22:25:10

ramosian-glider commented 9 years ago
You can disable the asan SEGV handler (ASAN_OPTIONS=handle_segv=0), but it will hardly
help you. 

asan can not be used with jni unless you rebuild the JVM binary (you need the main
binary to be linked with asan run-time) or somehow else inject the asan run-time 
into the process at startup time. (You may try LD_PRELOAD, but you are on your own)

Reported by konstantin.s.serebryany on 2013-03-18 04:13:53

ramosian-glider commented 9 years ago
Adding Project:AddressSanitizer as part of GitHub migration.

Reported by ramosian.glider on 2015-07-30 09:12:58