opengl - Why does java app crash in gdb but runs normally in real life? -


attempting run java app gdb results in segfault, yet running app alone not. app .jar uses jogl , bit of memory-mapping talk gpu.

stacktrace below hints @ sort of memory access problem don't understand why manifests in gdb not in real life. there environment factor gdb needs know allow proper execution?

this issue persists between jvms openjdk 6 , 7, oracle jre 7. oracle jre runs little farther startup before segfault. segfaults otherwise consistent in occurrence , location between trials.

segfault persists between gpus , drivers(!!): nvidia, radeon, fglrx current , fglrx beta (14.xx). gdb attach already-running instance of program, doesn't seem possible gdebugger this, needs work.

there no intent debug gdb. rather trying use gdebugger perform opengl debugging. gdebugger apparently relies on gdb part of backend, if gdb fails, gdebugger. resulted in attempts run gdb alone isolate issue.

gdebugger output: gdb string:  [thread debugging using libthread_db enabled]   gdb string:  using host libthread_db library  /lib/x86_64-linux-gnu/libthread_db.so.1 .   thread created: 140737353893632 (lwp: 3265) thread created: 140737294624512 (lwp: 3266) thread created: 140737293571840 (lwp: 3267) thread created: 140737292519168 (lwp: 3268) thread created: 140737155180288 (lwp: 3269) thread created: 140737154127616 (lwp: 3270) thread created: 140736913602304 (lwp: 3271) thread created: 140736909629184 (lwp: 3272) thread created: 140736908576512 (lwp: 3273) thread created: 140736907523840 (lwp: 3274) thread created: 140736906471168 (lwp: 3275) thread created: 140736905418496 (lwp: 3276) thread created: 140736278275840 (lwp: 3277) thread created: 140736272963328 (lwp: 3278) thread created: 140736271910656 (lwp: 3279) thread created: 140736270857984 (lwp: 3280) thread created: 140736269805312 (lwp: 3281) thread created: 140737287657216 (lwp: 3285) thread created: 140736261945088 (lwp: 3289) gdb string:  [thread 0x7fffb6e67700 (lwp 3289) exited]   thread created: 140736261945088 (lwp: 3290) api connection established: gdebugger servers manager thread created: 140736234641152 (lwp: 3291) gdb string:  [thread 0x7fffb6e67700 (lwp 3290) exited]   api connection established: gdebugger opengl server gdb string:  [thread 0x7fffb77e8700 (lwp 3279) exited]   gdb string:  [thread 0x7fffb76e7700 (lwp 3280) exited]   debug string: gdebugger opengl server initialized thread created: 140736270857984 (lwp: 3292) thread created: 140735692441344 (lwp: 3294) thread created: 140735582430976 (lwp: 3295) thread created: 140735574038272 (lwp: 3296) opengl render context 1 created signal: sigsegv process exit   $ java -versionjava version "1.6.0_33" openjdk runtime environment (icedtea6 1.13.5) (6b33-1.13.5-1ubuntu0.14.04) openjdk 64-bit server vm (build 23.25-b01, mixed mode)  $ gdb -version gnu gdb (ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1  $ cat /etc/lsb-release distrib_id=ubuntu distrib_release=14.04 distrib_codename=trusty distrib_description="ubuntu 14.04.1 lts"  $ fglrxinfo display: :0.0  screen: 0 opengl vendor string: advanced micro devices, inc. opengl renderer string: amd radeon hd 5570      opengl version string: 4.4.12967 compatibility profile context 14.20   $ gdb --args java -jar runme.jar gnu gdb (ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1 copyright (c) 2014 free software foundation, inc. license gplv3+: gnu gpl version 3 or later <http://gnu.org/licenses/gpl.html> free software: free change , redistribute it. there no warranty, extent permitted law.  type "show copying" , "show warranty" details. gdb configured "x86_64-linux-gnu". type "show configuration" configuration details. bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. find gdb manual , other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. help, type "help". type "apropos word" search commands related "word"... reading symbols java...reading symbols /usr/lib/debug//usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java...done. done. (gdb) show configuration gdb configured follows:    configure --host=x86_64-linux-gnu --target=x86_64-linux-gnu              --with-auto-load-dir=$debugdir:$datadir/auto-load              --with-auto-load-safe-path=$debugdir:$datadir/auto-load              --with-expat              --with-gdb-datadir=/usr/share/gdb (relocatable)              --with-jit-reader-dir=/usr/lib/gdb (relocatable)              --without-libunwind-ia64              --with-lzma              --with-python=/usr (relocatable)              --with-separate-debug-dir=/usr/lib/debug (relocatable)              --with-system-gdbinit=/etc/gdb/gdbinit              --with-zlib              --without-babeltrace (gdb) run starting program: /usr/bin/java -jar runme.jar [thread debugging using libthread_db enabled] using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". process 6866 executing new program: /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java [thread debugging using libthread_db enabled] using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". [new thread 0x7ffff7fc4700 (lwp 6870)] [new thread 0x7ffff486c700 (lwp 6871)] [new thread 0x7ffff476b700 (lwp 6872)] [new thread 0x7ffff466a700 (lwp 6873)] [new thread 0x7fffea2d6700 (lwp 6874)] [new thread 0x7fffea1d5700 (lwp 6875)] [new thread 0x7fffea0d4700 (lwp 6876)] [new thread 0x7fffe9d0a700 (lwp 6877)] [new thread 0x7fffe9c09700 (lwp 6878)] [new thread 0x7fffe9b08700 (lwp 6879)] [new thread 0x7fffe9a07700 (lwp 6880)] [new thread 0x7fffe9906700 (lwp 6881)] ... [new thread 0x7fffe8110700 (lwp 6882)] [new thread 0x7fffe3169700 (lwp 6883)] [new thread 0x7fffe3068700 (lwp 6884)] [new thread 0x7fffe2f67700 (lwp 6885)] [new thread 0x7fffe2e66700 (lwp 6886)] [new thread 0x7fffe2d65700 (lwp 6887)] [thread 0x7fffe2d65700 (lwp 6887) exited] [new thread 0x7fffe2d65700 (lwp 6891)] [thread 0x7fffe2d65700 (lwp 6891) exited] [new thread 0x7fffe2d65700 (lwp 6895)] [thread 0x7fffe2d65700 (lwp 6895) exited] [new thread 0x7fffe2d65700 (lwp 6896)] [new thread 0x7fffe0efd700 (lwp 6897)] libegl warning: dri2: failed authenticate [new thread 0x7fff9799f700 (lwp 6898)] [new thread 0x7fff9719e700 (lwp 6899)] [new thread 0x7fff9699d700 (lwp 6900)] [thread 0x7fffe2d65700 (lwp 6896) exited] [new thread 0x7fffe2d65700 (lwp 6901)] [new thread 0x7fffe01ab700 (lwp 6902)] [new thread 0x7fff92f00700 (lwp 6903)] [new thread 0x7fff92dff700 (lwp 6904)] [new thread 0x7fff92cfe700 (lwp 6905)] setting sound system...[new thread 0x7fff92bfd700 (lwp 6906)]  [new thread 0x7fff92afc700 (lwp 6907)] [new thread 0x7fff929fb700 (lwp 6908)] [new thread 0x7fff928fa700 (lwp 6909)] [new thread 0x7fff927f9700 (lwp 6910)] [new thread 0x7fff926f8700 (lwp 6911)] [new thread 0x7fff925f7700 (lwp 6912)]  program received signal sigsegv, segmentation fault. [switching thread 0x7fffe2f67700 (lwp 6885)] 0x00007ffff6b3a770 in acl_copyright ()    /usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64/server/libjvm.so (gdb) #0  0x00007ffff6b3a770 in acl_copyright ()    /usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64/server/libjvm.so #1  0x00007ffff6d51309 in unsafe_copymemory2 (env=<optimized out>,      unsafe=<optimized out>, srcobj=0x0, srcoffset=140737008618496, dstobj=0x0,      dstoffset=140737006779392, size=1024)     @ /build/buildd/openjdk-6-6b33-1.13.5/build/openjdk/hotspot/src/share/vm/prims/unsafe.cpp:689 #2  0x00007fffed011790 in ?? () #3  0x0000000000000400 in ?? () #4  0x0000000000000000 in ?? () warning: current language not match frame. (gdb) quit debugging session active.      inferior 1 [process 6866] killed.  quit anyway? (y or n) y 

update: switched amd codexl (basically recent form of gdebugger) , situation hasn't changed much.

why java app crash in gdb runs in real life?

because doesn't actually crash.

java uses speculative loads. if pointer points addressable memory, load succeeds. pointer not point addressable memory, , attempted load generates sigsegv ... java runtime intercepts, makes memory addressable again, , restarts load instruction.

when debugging java programs, 1 has this:

(gdb) handle sigsegv nostop noprint pass 

unfortunately, if there jni code involved, , that code sigsegvs, gdb happily ignore signal well, resulting in death of inferior (being debugged) process. have not found acceptable solution latter problem.


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -