mardi févr. 05, 2008

How to get Common Agent Container/detached jvm dump

One of the frequently asked question is : My Jvm just crash but I cannot find any core dump of log.

All this may depend on host and/or Jvm configuration. The Common Agent Container is a service and

then run in background. It is not as easy as with console application to get any traces.

There are several methods I've used, here they are, just pick the one you prefer (some are not working on all jdks).


Note that if you are used to use java debugger like the one in NetBeans it may be useless
for you to read this page :-)


  • getting Jvm stack output using truss/strace.
Just go here.

  • enabling core file dump on the host.
By default on systems like Solaris, the dump of core file is disabled.
Use this with caution, enabling core file can cause security issue and/or fill up your disk.
It is recommended to set everything back to default after investigation is done.
  • On Solaris :
See coreadm(1M) man page for details.
    #coreadm -e log
    #coreadm -e process
    #coreadm -e global
    #coreadm -G all
    #coreadm -i /var/tmp/core.%f.%p.%t
    #coreadm -g /var/tmp/core.%f.%p.%t
    #coreadm -u

It is even better to only change the configuration for the running jvm.
    #coreadm -p /var/tmp/core.%f.%p.%t -P all  <jvm pid>
  • On Linux :
  • set core file limit in /etc/profile.
Replace any line like
ulimit -S -c 0 > /dev/null 2>&1 
by something like
[ `/usr/bin/id -u` -eq 0 ] && ulimit -c unlimited
  • set core file pattern (cf proc(5) fro details)
echo 1 > /proc/sys/kernel/core_uses_pid
echo /var/tmp/core.%f.%p.%t > /proc/sys/kernel/core_pattern
you can also use the systctl command :
sysctl -w kernel.core_pattern=/var/tmp/core.%f.%p.%t

  • Setting Jvm error file path in the command line.
Starting from jdk 6 , you are allowed to set the path of the dump file. This is done with the
XX:ErrorFile option. You can then add this to the Common Agent Container java's flags.

#cacaoadm set-param java-flags=-XX:ErrorFile=/var/tmp/myDump `cacaoadm get-param java-flags --value`

  • Using DTrace to catch Jvm fault.

Using the fault probe of the Proc provider you can print the stack trace each time the jvm
triggers one. I've wrote a small DTrace script that you can use. For all running Jvms it will
print output like the following on case of failure. In that example I've hacked a jni call to trigger
a segmentation fault.  (get the script)


[java:  4213/  2] experiencing fault <address not mapped to object>, signal 11

              libc.so.1`0xff1c5a70
              libc.so.1`0xff2103ec
              Interpreter
              com/sun/cacao/agent/auth/UserPrincipal.internalGetUid(Ljava/lang/String;)I
              com/sun/cacao/agent/auth/UserPrincipal.internalGetUid(Ljava/lang/String;)I
              com/sun/cacao/agent/auth/UserPrincipal.getUid()I
              com/sun/cacao/agent/auth/AssertMechanism.createSubject(Ljava/lang/String;Z)Ljavax/security/auth/Subject;
              com/sun/cacao/container/impl/ContainerPrivate.internalStart(Ljava/lang/String;)V
              com/sun/cacao/container/impl/ContainerPrivate.start(Ljava/lang/String;Ljava/lang/String;)V
              com/sun/cacao/container/impl/ContainerPrivate.main([Ljava/lang/String;)V
              StubRoutines (1)
              libjvm.so`__1cJJavaCallsLcall_helper6FpnJJavaValue_pnMmethodHandle_pnRJavaCallArguments_pnGThread__v_+0x1e4
              libjvm.so`jni_CallStaticVoidMethod+0x4b8
              java`0x13a4c
              libc.so.1`0xff245e28

              unix`trap_cleanup+0x24
              unix`trap+0x1b84
              unix`utl0+0x4c







About

Emmanuel Jannetti blog

Search

Archives
« avril 2014
lun.mar.mer.jeu.ven.sam.dim.
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today