SlideShare a Scribd company logo
1 of 71
Download to read offline
Всё, что вы хотели знать
о стек-трейсах и хип-дампах
Andrei Pangin
andrey.pangin@corp.mail.ru
2 Questions on StackOverflow
1. http://stackoverflow.com/questions/36343209/which-part-of-throwing-an-exception-is-expensive
2. http://stackoverflow.com/questions/26140182/running-jmap-getting-unable-to-open-socket-file
3. http://stackoverflow.com/questions/35517934/why-does-the-count-of-calls-of-a-recursive-method-causing-a-stackoverflowerror-v
4. http://stackoverflow.com/questions/28631656/runnable-thread-state-but-in-object-wait
5. http://stackoverflow.com/questions/26795573/which-method-is-the-least-obtrusive-for-generating-thread-dumps-in-java
6. http://stackoverflow.com/questions/25701740/java-thread-dump-waiting-on-object-monitor-what-is-it-waiting-on
7. http://stackoverflow.com/questions/36588354/how-to-dump-java-objects-came-from-jvm-heap-old-generation
8. http://stackoverflow.com/questions/30530082/how-can-i-restart-jvm-on-outofmemoryerror-after-making-a-heap-dump
9. http://stackoverflow.com/questions/28767905/what-is-the-difference-between-xss-and-xxthreadstacksize
10. http://stackoverflow.com/questions/25309748/what-is-thread-stack-size-option-xss-given-to-jvm-why-does-it-have-a-limit-of
11. http://stackoverflow.com/questions/35792936/how-to-take-a-heap-dump-in-windows-with-minimum-downtime
12. http://stackoverflow.com/questions/34076680/java-out-of-memory-automatic-heap-dump-file-name
13. http://stackoverflow.com/questions/26548103/how-to-obtain-the-jvm-thread-name-id-through-the-known-pid-tid
14. http://stackoverflow.com/questions/26116181/access-stacktraces-with-good-performance
15. http://stackoverflow.com/questions/23552296/how-to-determine-hotspot-vm-default-thread-stack-size
16. http://stackoverflow.com/questions/36458490/jni-how-to-list-all-the-current-instances
17. http://stackoverflow.com/questions/36279207/get-a-heap-dump-from-a-jre-only-on-windows
18. http://stackoverflow.com/questions/32605962/locate-and-read-objects-of-a-specific-type-from-memory-of-a-running-java-program
19. http://stackoverflow.com/questions/30629014/how-to-get-object-id-as-used-in-heap-dump
20. http://stackoverflow.com/questions/26502836/jmap-fforce-option-doesnt-work
21. http://stackoverflow.com/questions/25007427/how-are-exceptions-caught-and-dealt-with-at-the-low-assembly-level
22. http://stackoverflow.com/questions/23632653/generate-java-heap-dump-on-uncaught-exception
23. http://stackoverflow.com/questions/32198820/why-jstack-not-working-when-the-tmp-java-pidnum-socket-file-has-been-deleted
24. http://stackoverflow.com/questions/23247947/how-to-automatically-dump-memory-when-old-gen-of-jvm-exceeds-some-ratio
3 Exception traces
Exception in thread "main" java.net.UnknownHostException: nonexistent.com
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at java.net.Socket.<init>(Socket.java:434)
at java.net.Socket.<init>(Socket.java:211)
at TestConnection.main(TestConnection.java:6)
Demo 1
5
No stack trace
• Implicit exceptions
- NullPointerException
- ArrayIndexOutOfBoundsException
- ArithmeticException
- ArrayStoreException
- ClassCastException
• -XX:-OmitStackTraceInFastThrow
Exception traces
6 Exception traces
@Benchmark
public Object date() {
return new Date();
}
@Benchmark
public Object exception() {
return new Exception();
}
Benchmark Mode Cnt Score Error Units
Exception.date avgt 10 8,457 ± 0,040 ns/op
Exception.exception avgt 10 1208,841 ± 15,569 ns/op
7 Exception traces
public Throwable() {
fillInStackTrace();
}
public synchronized Throwable fillInStackTrace() {
if (stackTrace != null || backtrace != null) {
fillInStackTrace(0);
stackTrace = UNASSIGNED_STACK;
}
return this;
}
private native Throwable fillInStackTrace(int dummy);
8 Exception traces
@Benchmark
public Object exceptionNoStackTrace() {
return new Exception() {
@Override
public Throwable fillInStackTrace() {
return this;
}
};
}
Benchmark Mode Cnt Score Error Units
Exception.date avgt 10 8,457 ± 0,040 ns/op
Exception.exceptionNoStackTrace avgt 10 7,839 ± 0,034 ns/op
9 Exception traces
protected Exception(String message, Throwable cause,
boolean enableSuppression,
boolean writableStackTrace) {
public class LightException extends Exception {
public LightException(String message, Throwable cause) {
super(message, cause, true, false);
}
}
10 Exception traces
@Param({"1", "2", "10", "100", "1000"})
int depth;
@Benchmark
public Object throwCatch() {
try {
return recursive(depth);
} catch (Exception e) {
return e;
}
}
private Object recursive(int depth) throws Exception {
if (depth == 0) {
throw new LightException();
}
return recursive(depth - 1);
}
11 Exception traces
@Param({"1", "2", "10", "100", "1000"})
int depth;
@Benchmark
public Object throwCatch() {
try {
return recursive(depth);
} catch (Exception e) {
return e;
}
}
private Object recursive(int depth) throws Exception {
if (depth == 0) {
throw new LightException();
}
return recursive(depth - 1);
}
Benchmark (depth) Mode Cnt Score Error Units
Exceptions.throwCatch 1 avgt 10 8,020 ± 0,062 ns/op
Exceptions.throwCatch 2 avgt 10 126,724 ± 0,697 ns/op
Exceptions.throwCatch 10 avgt 10 620,068 ± 3,354 ns/op
Exceptions.throwCatch 100 avgt 10 5750,440 ± 34,838 ns/op
Exceptions.throwCatch 1000 avgt 10 58465,378 ± 251,693 ns/op
12 Exception traces
@Benchmark
public Object fillInStackTrace() {
return new Exception();
}
@Benchmark
public Object getStackTrace() {
return new Exception().getStackTrace();
}
Benchmark Mode Cnt Score Error Units
Exceptions.fillInStackTrace avgt 10 1207,092 ± 10,150 ns/op
Exceptions.getStackTrace avgt 10 13388,665 ± 54,684 ns/op
13 Exception traces
int depth = getStackTraceDepth();
stackTrace = new StackTraceElement[depth];
for (int i = 0; i < depth; i++)
stackTrace[i] = getStackTraceElement(i);
native calls
public final class StackTraceElement {
private String declaringClass;
private String methodName;
private String fileName;
private int lineNumber;
...
}
14 Exception traces
Exception in thread "main" java.net.UnknownHostException: nonexistent.com
at java.net.PlainSocketImpl.connect(java.base@9-ea/PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(java.base@9-ea/SocksSocketImpl.java:402)
at java.net.Socket.connect(java.base@9-ea/Socket.java:591)
at java.net.Socket.connect(java.base@9-ea/Socket.java:540)
at java.net.Socket.<init>(java.base@9-ea/Socket.java:436)
at java.net.Socket.<init>(java.base@9-ea/Socket.java:213)
at TestConnection.main(TestConnection.java:6)
public final class StackTraceElement {
private String moduleName;
private String moduleVersion;
private String declaringClass;
private String methodName;
private String fileName;
private int lineNumber;
new in JDK 9
15
Exception performance
• new Exception() is cheap
- fillInStackTrace() costs!
- getStackTrace() costs even more!
- O(stack_depth)
• throw is cheap
- catch ≈ goto in the same frame
- O(stack_depth)
Exception traces
16
Tips
• Use -XX:-OmitStackTraceInFastThrow
• No exceptions in normal control flow
• But if you really want
- use no-stack-trace constructor
Exception traces
When do you need stack traces?
18 Use cases
"Thread-1" #18 prio=5 os_prio=0 tid=0x1923a800 nid=0xdf8 waiting on condition [0x19faf000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0xd94cec48> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:285)
at RpcTest.clientLoop(RpcTest.java:34)
at java.lang.Thread.run(Thread.java:745)
"Thread-2" #19 prio=5 os_prio=0 tid=0x19243800 nid=0x3d40 runnable [0x1a0af000]
java.lang.Thread.State: RUNNABLE
at one.nio.net.NativeSocket.readFully(Native Method)
at one.nio.rpc.RpcClient.invoke(RpcClient.java:76)
at RpcTest.clientLoop(RpcTest.java:36)
at java.lang.Thread.run(Thread.java:745)
19 Use cases
"Thread-1" #18 prio=5 os_prio=0 tid=0x1923a800 nid=0xdf8 waiting on condition [0x19faf000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0xd94cec48> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:285)
at RpcTest.clientLoop(RpcTest.java:34)
at java.lang.Thread.run(Thread.java:745)
Locked ownable synchronizers:
- None
"Thread-2" #19 prio=5 os_prio=0 tid=0x19243800 nid=0x3d40 runnable [0x1a0af000]
java.lang.Thread.State: RUNNABLE
at one.nio.net.NativeSocket.readFully(Native Method)
at one.nio.rpc.RpcClient.invoke(RpcClient.java:76)
at RpcTest.clientLoop(RpcTest.java:36)
at java.lang.Thread.run(Thread.java:745)
Locked ownable synchronizers:
- <0xd94cec48> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
-XX:+PrintConcurrentLocks
20 Use cases
"RPC Client 192.168.0.11" #19 prio=5 os_prio=0 tid=0x19243800 nid=0x3d40 runnable [0x1a0af000]
java.lang.Thread.State: RUNNABLE
at one.nio.net.NativeSocket.readFully(Native Method)
at one.nio.rpc.RpcClient.invoke(RpcClient.java:76)
at RpcTest.clientLoop(RpcTest.java:36)
at java.lang.Thread.run(Thread.java:745)
Use Thread.currentThread().setName()
Demo 2
22 Use cases
Logging
logger.warning("Operation timed out");
[Controller.java:123] WARNING: Operation timed out
public static String getLocation() {
StackTraceElement s = new Exception().getStackTrace()[2];
return s.getFileName() + ':' + s.getLineNumber();
}
23 Use cases
A better way?
Thread.current().getStackTrace()
public StackTraceElement[] getStackTrace() {
if (this != Thread.currentThread()) {
// ... some magic ...
} else {
// Don't need JVM help for current thread
return (new Exception()).getStackTrace();
}
}
24 Use cases
A better way!
public static String getLocation() {
StackTraceElement s = sun.misc.SharedSecrets.getJavaLangAccess()
.getStackTraceElement(new Exception(), 2);
return s.getFileName() + ':' + s.getLineNumber();
}
Not in
JDK 9
25
Caller sensitive methods
• @CallerSensitive
- Class.forName
- ResourceBundle.getBundle
- System.loadLibrary
- AccessController.doPrivileged
• sun.reflect.Reflection.getCallerClass
Use cases
26
Stack Walking API
• Limit depth
• Filter frames
• Lazy construction
• Class instances instead of Class names
Stack Walking API
27
java.lang.StackWalker
Stack Walking API
28
java.lang.StackWalker
• StackWalker.getInstance()
• StackWalker.getInstance(Set<Option> options)
- RETAIN_CLASS_REFERENCE
- SHOW_REFLECT_FRAMES
- SHOW_HIDDEN_FRAMES
• StackWalker.getInstance(Set<Option> options,
int estimateDepth)
Stack Walking API
29 Stack Walking API
StackWalker sw = StackWalker.getInstance();
sw.forEach(System.out::println);
StackWalking.dumpStackTrace(StackWalking.java:7)
StackWalking.main(StackWalking.java:12)
com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
30 Stack Walking API
StackWalker sw = StackWalker.getInstance(StackWalker.Option.SHOW_REFLECT_FRAMES);
sw.forEach(System.out::println);
StackWalking.dumpStackTrace(StackWalking.java:7)
StackWalking.main(StackWalking.java:12)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:531)
com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
31 Stack Walking API
StackWalker sw = StackWalker.getInstance(StackWalker.Option.SHOW_HIDDEN_FRAMES);
sw.forEach(System.out::println);
StackWalking.dumpStackTrace(StackWalking.java:7)
StackWalking$$Lambda$1/1287712235.run(Unknown Source bci:0)
StackWalking.main(StackWalking.java:12)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:531)
com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
32 Stack Walking API
public <T> T walk(Function<? super Stream<StackFrame>, ? extends T> function)
public static StackFrame getCallerFrame() {
return StackWalker.getInstance()
.walk(stream -> stream.skip(2).findFirst())
.orElseThrow(NoSuchElementException::new);
}
return StackWalker.getInstance(RETAIN_CLASS_REFERENCE).getCallerClass();
33 Stack Walking API
StackWalker sw = StackWalker.getInstance();
List<StackFrame> frames = sw.walk(stream ->
stream.filter(sf -> sf.getClassName().startsWith("org.apache."))
.limit(10)
.collect(Collectors.toList()));
public Stream<StackFrame> stream(); Why
NOT?
34 Stack Walking API
/* package-private */
interface LiveStackFrame extends StackFrame {
public Object[] getMonitors();
public Object[] getLocals();
public Object[] getStack();
public static StackWalker getStackWalker();
}
Demo 3
36 Stack size
Fun with recursion
static int depth;
static void recursion() {
depth++;
recursion();
}
public static void main(String[] args) {
recursion();
}
37
38 Stack size
4
3
2
1
main
2
1
main
3
4
5
6
2
1
main
3
4
5
6
7
8
C1
C1
C2
39
Stack size
• -Xss, -XX:ThreadStackSize
• Thread(threadGroup, target, name, stackSize)
• java.lang.OutOfMemoryError: Unable to create
new native thread
Stack size
40
Stack size
• Default stack size?
- x86: 320 KB
- x64: 1MB
• Minimum stack size?
- ~228 KB
Stack size
frame
empty
shadow
1
2
frame
frame
41
Profiling
43
Types of profiling
• Instrumentation
• Sampling
- Take stack traces every 10 – 100 ms
- Suitable for production
Profiling
public void someMethod(String... args) {
Profiler.onMethodEnter("myClass.someMethod");
// method body
Profiler.onMethodExit("myClass.someMethod");
}
Demo 5
45
Sampling bias
• Stack traces are taken at VM safepoint
• Running and idle threads are sampled equally
• Blocking native calls appear as Runnable
• Victims: VisualVM, JProfiler, YourKit…
Profiling
46
Fair profiler?
• setitimer + SIGPROF
• SIGPROF handler collects stack trace of signaled
thread
• HotSpot internal API: AsyncGetCallTrace
- Used in Oracle Solaris Studio
Profiling
47 Profiling
AsyncGetCallTrace
ASGCT_CallFrame frames[MAX_FRAMES];
ASGCT_CallTrace trace = {env, MAX_FRAMES, frames};
AsyncGetCallTrace(&trace, trace.num_frames, ucontext);
from signal handler
https://github.com/apangin/async-profiler
How to dump?
49
In-process
• Java
- Thread.getAllStackTraces
- ThreadMXBean.getThreadInfo
• JVMTI
- GetAllStackTraces
- Compact representation (jmethodID)
- Used by profilers
Thread dump
StackTraceElement[]
+ locked monitors
50
External
• SIGQUIT (kill -3, Ctrl + )
- Processed by JVM at max. speed
- No intermediate structures
- Prints to stdout
• jstack
- Dynamic attach
• jstack -F
- Serviceability Agent
Thread dump
51 Thread dump
Dynamic attach
jstack JVM
1. creates .attach_pid1234
sends SIGQUIT 2. starts AttachListener
UNIX socket /tmp/.java_pid1234
verifies euid + egid
3. sends “threaddump” 4. executes command
sends output back to socket
52 Thread dump
Dynamic attach on Windows
jstack JVM
1. creates .pipejavatool1234
2. WriteProcessMemory
(command, args, pipe name)
3. CreateRemoteThread 4. executes command
sends output back to pipe
53
jstack
• Pros.
- Performed by JVM at max. speed
- Compatibility with different JVM versions
• Cons.
- Should be run by the same user (euid / egid)
- Works only on healthy JVM
- Can be disabled (-XX:+DisableAttachMechanism)
Thread dump
54
Dynamic attach Demo
• https://github.com/apangin/jattach
- datadump, threaddump, dumpheap, inspectheap
- properties, agentProperties
- printflag, setflag
- jcmd
- load
Thread dump
55 Thread dump
Serviceability Agent
jstack -F JVM
1. PTRACE_ATTACH the process suspends
(SIGSTOP)
2. Read remote memory
PTRACE_PEEKDATA
3. Reconstruct VM structures
4. Traverse reconstructed stack
56
jstack -F
• Pros.
- No cooperation from JVM required
- root can dump any process
- Mixed Java+Natives frames (-m)
• Cons.
- Slow
- Requires the same version of JVM
- No thread names, no lock info
Thread dump
57 Thread dump
How to dump?
public static void dump() throws AttachNotSupportedException, IOException {
String vmName = ManagementFactory.getRuntimeMXBean().getName();
String pid = vmName.substring(0, vmName.indexOf('@'));
HotSpotVirtualMachine vm = (HotSpotVirtualMachine) VirtualMachine.attach(pid);
try {
vm.localDataDump();
} finally {
vm.detach();
}
}
https://github.com/odnoklassniki/one-nio/blob/master/src/one/nio/mgt/
Heap dump
59
jmap
• jmap -dump:live,format=b,file=heap.bin PID
• jmap -histo PID
Heap dump
num #instances #bytes class name
----------------------------------------------
1: 1943 404550984 [J
2: 5622 41517944 [B
3: 306128 33720768 [C
4: 292548 7021152 java.lang.String
5: 131072 4194304 one.nio.lock.RWLock
6: 103634 3316288 java.util.HashMap$Node
7: 89096 2138304 java.lang.Long
8: 17503 1850168 [Ljava.lang.Object;
9: 50688 1622016 [Lone.cassandra12.remoting.Host;
60 Heap dump
jmap vs. jmap -F
+ Speed
+ Version tolerance
+ Supports “live” option
- Requires the same user
- Works only on healthy JVM
+ Can be used on hung process
+ Can be used on core dump
+ root can dump everything
- Slow
- Requires the same JDK
- Heap may be inconsistent
jmap jmap -F
61 Heap dump
Offline heap dumps
$ sudo gcore 1234
$ jmap -dump:format=b,file=heap.bin /path/to/java core.1234
Windows: WinDbg.exe
jmap -dump:format=b,file=heap.bin C:pathtojava.exe core.mdmp
62
Automatic heap dumps
• -XX:+HeapDumpOnOutOfMemoryError
• -XX:+HeapDumpBeforeFullGC
• -XX:+HeapDumpAfterFullGC
• -XX:HeapDumpPath=/tmp (or /tmp/dump.bin)
Heap dump
63 Heap dump
Manageable options
HotSpotDiagnosticMXBean bean = ManagementFactory.newPlatformMXBeanProxy(
ManagementFactory.getPlatformMBeanServer(),
"com.sun.management:type=HotSpotDiagnostic",
HotSpotDiagnosticMXBean.class);
bean.setVMOption("HeapDumpOnOutOfMemoryError", "true");
bean.setVMOption("HeapDumpPath", fileName);
$ jinfo -flag +HeapDumpOnOutOfMemoryError 1234
$ jinfo -flag HeapDumpPath=/tmp 1234
64
Kill JVM after heap dump
• -XX:+ExitOnOutOfMemoryError
• -XX:+CrashOnOutOfMemoryError
Heap dump
$ java -XX:+HeapDumpOnOutOfMemoryError
-XX:OnOutOfMemoryError="kill -9 %p"
com.myproject.TestApp
JDK
8u92
Dump heap programmatically
66 Heap dump
JMX
HotSpotDiagnosticMXBean bean = ManagementFactory.newPlatformMXBeanProxy(
ManagementFactory.getPlatformMBeanServer(),
"com.sun.management:type=HotSpotDiagnostic",
HotSpotDiagnosticMXBean.class);
bean.dumpHeap("/tmp/heap.bin", true);
67 Heap dump
JVMTI
jvmtiIterationControl JNICALL
HeapObjectCallback(jlong class_tag, jlong size,
jlong* tag_ptr, void* user_data) {
*tag_ptr = 1;
return JVMTI_ITERATION_CONTINUE;
}
jvmti->IterateOverInstancesOfClass(targetClass, JVMTI_HEAP_OBJECT_EITHER,
HeapObjectCallback, NULL);
jlong tag = 1;
jint count;
jobject* instances;
jvmti->GetObjectsWithTags(1, &tag, &count, &instances, NULL);
68 Heap dump
Serviceability Agent
SystemDictionary dictionary = VM.getVM().getSystemDictionary();
Klass klass = dictionary.find("java/lang/String", null, null);
VM.getVM().getObjectHeap().iterateObjectsOfKlass(new DefaultHeapVisitor() {
public boolean doObj(Oop obj) {
obj.printValue();
System.out.println();
return false;
}
}, klass); $JAVA_HOME/lib/sa-jdi.jar
Demo 6
70
Conclusions
• Use thread dumps and heap dumps
- In PROD!
• In-process
- Java (JMX), JVMTI
• Externally
- Dynamic attach
- Serviceability Agent
Heap dump
Thank you
@AndreiPangin

More Related Content

What's hot

OWASP Top 10 Vulnerabilities - A5-Broken Access Control; A6-Security Misconfi...
OWASP Top 10 Vulnerabilities - A5-Broken Access Control; A6-Security Misconfi...OWASP Top 10 Vulnerabilities - A5-Broken Access Control; A6-Security Misconfi...
OWASP Top 10 Vulnerabilities - A5-Broken Access Control; A6-Security Misconfi...Lenur Dzhemiliev
 
HTTP Request Smuggling via higher HTTP versions
HTTP Request Smuggling via higher HTTP versionsHTTP Request Smuggling via higher HTTP versions
HTTP Request Smuggling via higher HTTP versionsneexemil
 
Sql injections - with example
Sql injections - with exampleSql injections - with example
Sql injections - with examplePrateek Chauhan
 
XSS - Do you know EVERYTHING?
XSS - Do you know EVERYTHING?XSS - Do you know EVERYTHING?
XSS - Do you know EVERYTHING?Yurii Bilyk
 
Thick client pentesting_the-hackers_meetup_version1.0pptx
Thick client pentesting_the-hackers_meetup_version1.0pptxThick client pentesting_the-hackers_meetup_version1.0pptx
Thick client pentesting_the-hackers_meetup_version1.0pptxAnurag Srivastava
 
Securing AEM webapps by hacking them
Securing AEM webapps by hacking themSecuring AEM webapps by hacking them
Securing AEM webapps by hacking themMikhail Egorov
 
What is security testing and why it is so important?
What is security testing and why it is so important?What is security testing and why it is so important?
What is security testing and why it is so important?ONE BCG
 
Attack and Mitigation for Insecure Deserialization
Attack and Mitigation for Insecure DeserializationAttack and Mitigation for Insecure Deserialization
Attack and Mitigation for Insecure DeserializationSukhpreet Singh
 
Sql injection attack
Sql injection attackSql injection attack
Sql injection attackRaghav Bisht
 
OWASP Top 10 A4 – Insecure Direct Object Reference
OWASP Top 10 A4 – Insecure Direct Object ReferenceOWASP Top 10 A4 – Insecure Direct Object Reference
OWASP Top 10 A4 – Insecure Direct Object ReferenceNarudom Roongsiriwong, CISSP
 
OWASP A4 XML External Entities (XXE)
OWASP A4 XML External Entities (XXE)OWASP A4 XML External Entities (XXE)
OWASP A4 XML External Entities (XXE)Michael Furman
 
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ BehaviourWAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ BehaviourSoroush Dalili
 
Hacking Adobe Experience Manager sites
Hacking Adobe Experience Manager sitesHacking Adobe Experience Manager sites
Hacking Adobe Experience Manager sitesMikhail Egorov
 
Security Testing Training With Examples
Security Testing Training With ExamplesSecurity Testing Training With Examples
Security Testing Training With ExamplesAlwin Thayyil
 
A2 - broken authentication and session management(OWASP thailand chapter Apri...
A2 - broken authentication and session management(OWASP thailand chapter Apri...A2 - broken authentication and session management(OWASP thailand chapter Apri...
A2 - broken authentication and session management(OWASP thailand chapter Apri...Noppadol Songsakaew
 
Excursion Report of Jhanjhra Coal Mines
Excursion Report of Jhanjhra Coal MinesExcursion Report of Jhanjhra Coal Mines
Excursion Report of Jhanjhra Coal MinesAnurag Jha
 
ORM2Pwn: Exploiting injections in Hibernate ORM
ORM2Pwn: Exploiting injections in Hibernate ORMORM2Pwn: Exploiting injections in Hibernate ORM
ORM2Pwn: Exploiting injections in Hibernate ORMMikhail Egorov
 
Insecure direct object reference (null delhi meet)
Insecure direct object reference (null delhi meet)Insecure direct object reference (null delhi meet)
Insecure direct object reference (null delhi meet)Abhinav Mishra
 
Remote File Inclusion (RFI) Vulnerabilities 101
Remote File Inclusion (RFI) Vulnerabilities 101Remote File Inclusion (RFI) Vulnerabilities 101
Remote File Inclusion (RFI) Vulnerabilities 101Imperva
 
CEH v9 cheat sheet notes Certified Ethical Hacker
CEH v9 cheat sheet notes  Certified Ethical HackerCEH v9 cheat sheet notes  Certified Ethical Hacker
CEH v9 cheat sheet notes Certified Ethical HackerDavid Sweigert
 

What's hot (20)

OWASP Top 10 Vulnerabilities - A5-Broken Access Control; A6-Security Misconfi...
OWASP Top 10 Vulnerabilities - A5-Broken Access Control; A6-Security Misconfi...OWASP Top 10 Vulnerabilities - A5-Broken Access Control; A6-Security Misconfi...
OWASP Top 10 Vulnerabilities - A5-Broken Access Control; A6-Security Misconfi...
 
HTTP Request Smuggling via higher HTTP versions
HTTP Request Smuggling via higher HTTP versionsHTTP Request Smuggling via higher HTTP versions
HTTP Request Smuggling via higher HTTP versions
 
Sql injections - with example
Sql injections - with exampleSql injections - with example
Sql injections - with example
 
XSS - Do you know EVERYTHING?
XSS - Do you know EVERYTHING?XSS - Do you know EVERYTHING?
XSS - Do you know EVERYTHING?
 
Thick client pentesting_the-hackers_meetup_version1.0pptx
Thick client pentesting_the-hackers_meetup_version1.0pptxThick client pentesting_the-hackers_meetup_version1.0pptx
Thick client pentesting_the-hackers_meetup_version1.0pptx
 
Securing AEM webapps by hacking them
Securing AEM webapps by hacking themSecuring AEM webapps by hacking them
Securing AEM webapps by hacking them
 
What is security testing and why it is so important?
What is security testing and why it is so important?What is security testing and why it is so important?
What is security testing and why it is so important?
 
Attack and Mitigation for Insecure Deserialization
Attack and Mitigation for Insecure DeserializationAttack and Mitigation for Insecure Deserialization
Attack and Mitigation for Insecure Deserialization
 
Sql injection attack
Sql injection attackSql injection attack
Sql injection attack
 
OWASP Top 10 A4 – Insecure Direct Object Reference
OWASP Top 10 A4 – Insecure Direct Object ReferenceOWASP Top 10 A4 – Insecure Direct Object Reference
OWASP Top 10 A4 – Insecure Direct Object Reference
 
OWASP A4 XML External Entities (XXE)
OWASP A4 XML External Entities (XXE)OWASP A4 XML External Entities (XXE)
OWASP A4 XML External Entities (XXE)
 
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ BehaviourWAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
 
Hacking Adobe Experience Manager sites
Hacking Adobe Experience Manager sitesHacking Adobe Experience Manager sites
Hacking Adobe Experience Manager sites
 
Security Testing Training With Examples
Security Testing Training With ExamplesSecurity Testing Training With Examples
Security Testing Training With Examples
 
A2 - broken authentication and session management(OWASP thailand chapter Apri...
A2 - broken authentication and session management(OWASP thailand chapter Apri...A2 - broken authentication and session management(OWASP thailand chapter Apri...
A2 - broken authentication and session management(OWASP thailand chapter Apri...
 
Excursion Report of Jhanjhra Coal Mines
Excursion Report of Jhanjhra Coal MinesExcursion Report of Jhanjhra Coal Mines
Excursion Report of Jhanjhra Coal Mines
 
ORM2Pwn: Exploiting injections in Hibernate ORM
ORM2Pwn: Exploiting injections in Hibernate ORMORM2Pwn: Exploiting injections in Hibernate ORM
ORM2Pwn: Exploiting injections in Hibernate ORM
 
Insecure direct object reference (null delhi meet)
Insecure direct object reference (null delhi meet)Insecure direct object reference (null delhi meet)
Insecure direct object reference (null delhi meet)
 
Remote File Inclusion (RFI) Vulnerabilities 101
Remote File Inclusion (RFI) Vulnerabilities 101Remote File Inclusion (RFI) Vulnerabilities 101
Remote File Inclusion (RFI) Vulnerabilities 101
 
CEH v9 cheat sheet notes Certified Ethical Hacker
CEH v9 cheat sheet notes  Certified Ethical HackerCEH v9 cheat sheet notes  Certified Ethical Hacker
CEH v9 cheat sheet notes Certified Ethical Hacker
 

Similar to Everything you wanted to know about Stack Traces and Heap Dumps

Down to Stack Traces, up from Heap Dumps
Down to Stack Traces, up from Heap DumpsDown to Stack Traces, up from Heap Dumps
Down to Stack Traces, up from Heap DumpsAndrei Pangin
 
Don't dump thread dumps
Don't dump thread dumpsDon't dump thread dumps
Don't dump thread dumpsTier1app
 
Performance tweaks and tools for Linux (Joe Damato)
Performance tweaks and tools for Linux (Joe Damato)Performance tweaks and tools for Linux (Joe Damato)
Performance tweaks and tools for Linux (Joe Damato)Ontico
 
Debugging Ruby Systems
Debugging Ruby SystemsDebugging Ruby Systems
Debugging Ruby SystemsEngine Yard
 
Locks? We Don't Need No Stinkin' Locks - Michael Barker
Locks? We Don't Need No Stinkin' Locks - Michael BarkerLocks? We Don't Need No Stinkin' Locks - Michael Barker
Locks? We Don't Need No Stinkin' Locks - Michael BarkerJAX London
 
Lock? We don't need no stinkin' locks!
Lock? We don't need no stinkin' locks!Lock? We don't need no stinkin' locks!
Lock? We don't need no stinkin' locks!Michael Barker
 
JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesCharles Nutter
 
Thread dump troubleshooting
Thread dump troubleshootingThread dump troubleshooting
Thread dump troubleshootingJerry Chan
 
Lets crash-applications
Lets crash-applicationsLets crash-applications
Lets crash-applicationsTier1 app
 
A topology of memory leaks on the JVM
A topology of memory leaks on the JVMA topology of memory leaks on the JVM
A topology of memory leaks on the JVMRafael Winterhalter
 
Kickin' Ass with Cache-Fu (without notes)
Kickin' Ass with Cache-Fu (without notes)Kickin' Ass with Cache-Fu (without notes)
Kickin' Ass with Cache-Fu (without notes)err
 
Counter Wars (JEEConf 2016)
Counter Wars (JEEConf 2016)Counter Wars (JEEConf 2016)
Counter Wars (JEEConf 2016)Alexey Fyodorov
 
Solr Troubleshooting - TreeMap approach
Solr Troubleshooting - TreeMap approachSolr Troubleshooting - TreeMap approach
Solr Troubleshooting - TreeMap approachAlexandre Rafalovitch
 
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...Lucidworks
 

Similar to Everything you wanted to know about Stack Traces and Heap Dumps (20)

Down to Stack Traces, up from Heap Dumps
Down to Stack Traces, up from Heap DumpsDown to Stack Traces, up from Heap Dumps
Down to Stack Traces, up from Heap Dumps
 
Don't dump thread dumps
Don't dump thread dumpsDon't dump thread dumps
Don't dump thread dumps
 
Performance tweaks and tools for Linux (Joe Damato)
Performance tweaks and tools for Linux (Joe Damato)Performance tweaks and tools for Linux (Joe Damato)
Performance tweaks and tools for Linux (Joe Damato)
 
Debugging Ruby Systems
Debugging Ruby SystemsDebugging Ruby Systems
Debugging Ruby Systems
 
Solr @ Etsy - Apache Lucene Eurocon
Solr @ Etsy - Apache Lucene EuroconSolr @ Etsy - Apache Lucene Eurocon
Solr @ Etsy - Apache Lucene Eurocon
 
Exception Handling in Scala
Exception Handling in ScalaException Handling in Scala
Exception Handling in Scala
 
Locks? We Don't Need No Stinkin' Locks - Michael Barker
Locks? We Don't Need No Stinkin' Locks - Michael BarkerLocks? We Don't Need No Stinkin' Locks - Michael Barker
Locks? We Don't Need No Stinkin' Locks - Michael Barker
 
Lock? We don't need no stinkin' locks!
Lock? We don't need no stinkin' locks!Lock? We don't need no stinkin' locks!
Lock? We don't need no stinkin' locks!
 
JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for Dummies
 
Thread dump troubleshooting
Thread dump troubleshootingThread dump troubleshooting
Thread dump troubleshooting
 
Unix executable buffer overflow
Unix executable buffer overflowUnix executable buffer overflow
Unix executable buffer overflow
 
Lets crash-applications
Lets crash-applicationsLets crash-applications
Lets crash-applications
 
A topology of memory leaks on the JVM
A topology of memory leaks on the JVMA topology of memory leaks on the JVM
A topology of memory leaks on the JVM
 
Kickin' Ass with Cache-Fu (without notes)
Kickin' Ass with Cache-Fu (without notes)Kickin' Ass with Cache-Fu (without notes)
Kickin' Ass with Cache-Fu (without notes)
 
Counter Wars (JEEConf 2016)
Counter Wars (JEEConf 2016)Counter Wars (JEEConf 2016)
Counter Wars (JEEConf 2016)
 
Solr Troubleshooting - TreeMap approach
Solr Troubleshooting - TreeMap approachSolr Troubleshooting - TreeMap approach
Solr Troubleshooting - TreeMap approach
 
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
 
Hidden Gems of Ruby 1.9
Hidden Gems of Ruby 1.9Hidden Gems of Ruby 1.9
Hidden Gems of Ruby 1.9
 
Curator intro
Curator introCurator intro
Curator intro
 
JVM Mechanics
JVM MechanicsJVM Mechanics
JVM Mechanics
 

Recently uploaded

Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 

Recently uploaded (20)

Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 

Everything you wanted to know about Stack Traces and Heap Dumps

  • 1. Всё, что вы хотели знать о стек-трейсах и хип-дампах Andrei Pangin andrey.pangin@corp.mail.ru
  • 2. 2 Questions on StackOverflow 1. http://stackoverflow.com/questions/36343209/which-part-of-throwing-an-exception-is-expensive 2. http://stackoverflow.com/questions/26140182/running-jmap-getting-unable-to-open-socket-file 3. http://stackoverflow.com/questions/35517934/why-does-the-count-of-calls-of-a-recursive-method-causing-a-stackoverflowerror-v 4. http://stackoverflow.com/questions/28631656/runnable-thread-state-but-in-object-wait 5. http://stackoverflow.com/questions/26795573/which-method-is-the-least-obtrusive-for-generating-thread-dumps-in-java 6. http://stackoverflow.com/questions/25701740/java-thread-dump-waiting-on-object-monitor-what-is-it-waiting-on 7. http://stackoverflow.com/questions/36588354/how-to-dump-java-objects-came-from-jvm-heap-old-generation 8. http://stackoverflow.com/questions/30530082/how-can-i-restart-jvm-on-outofmemoryerror-after-making-a-heap-dump 9. http://stackoverflow.com/questions/28767905/what-is-the-difference-between-xss-and-xxthreadstacksize 10. http://stackoverflow.com/questions/25309748/what-is-thread-stack-size-option-xss-given-to-jvm-why-does-it-have-a-limit-of 11. http://stackoverflow.com/questions/35792936/how-to-take-a-heap-dump-in-windows-with-minimum-downtime 12. http://stackoverflow.com/questions/34076680/java-out-of-memory-automatic-heap-dump-file-name 13. http://stackoverflow.com/questions/26548103/how-to-obtain-the-jvm-thread-name-id-through-the-known-pid-tid 14. http://stackoverflow.com/questions/26116181/access-stacktraces-with-good-performance 15. http://stackoverflow.com/questions/23552296/how-to-determine-hotspot-vm-default-thread-stack-size 16. http://stackoverflow.com/questions/36458490/jni-how-to-list-all-the-current-instances 17. http://stackoverflow.com/questions/36279207/get-a-heap-dump-from-a-jre-only-on-windows 18. http://stackoverflow.com/questions/32605962/locate-and-read-objects-of-a-specific-type-from-memory-of-a-running-java-program 19. http://stackoverflow.com/questions/30629014/how-to-get-object-id-as-used-in-heap-dump 20. http://stackoverflow.com/questions/26502836/jmap-fforce-option-doesnt-work 21. http://stackoverflow.com/questions/25007427/how-are-exceptions-caught-and-dealt-with-at-the-low-assembly-level 22. http://stackoverflow.com/questions/23632653/generate-java-heap-dump-on-uncaught-exception 23. http://stackoverflow.com/questions/32198820/why-jstack-not-working-when-the-tmp-java-pidnum-socket-file-has-been-deleted 24. http://stackoverflow.com/questions/23247947/how-to-automatically-dump-memory-when-old-gen-of-jvm-exceeds-some-ratio
  • 3. 3 Exception traces Exception in thread "main" java.net.UnknownHostException: nonexistent.com at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at java.net.Socket.connect(Socket.java:538) at java.net.Socket.<init>(Socket.java:434) at java.net.Socket.<init>(Socket.java:211) at TestConnection.main(TestConnection.java:6)
  • 5. 5 No stack trace • Implicit exceptions - NullPointerException - ArrayIndexOutOfBoundsException - ArithmeticException - ArrayStoreException - ClassCastException • -XX:-OmitStackTraceInFastThrow Exception traces
  • 6. 6 Exception traces @Benchmark public Object date() { return new Date(); } @Benchmark public Object exception() { return new Exception(); } Benchmark Mode Cnt Score Error Units Exception.date avgt 10 8,457 ± 0,040 ns/op Exception.exception avgt 10 1208,841 ± 15,569 ns/op
  • 7. 7 Exception traces public Throwable() { fillInStackTrace(); } public synchronized Throwable fillInStackTrace() { if (stackTrace != null || backtrace != null) { fillInStackTrace(0); stackTrace = UNASSIGNED_STACK; } return this; } private native Throwable fillInStackTrace(int dummy);
  • 8. 8 Exception traces @Benchmark public Object exceptionNoStackTrace() { return new Exception() { @Override public Throwable fillInStackTrace() { return this; } }; } Benchmark Mode Cnt Score Error Units Exception.date avgt 10 8,457 ± 0,040 ns/op Exception.exceptionNoStackTrace avgt 10 7,839 ± 0,034 ns/op
  • 9. 9 Exception traces protected Exception(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { public class LightException extends Exception { public LightException(String message, Throwable cause) { super(message, cause, true, false); } }
  • 10. 10 Exception traces @Param({"1", "2", "10", "100", "1000"}) int depth; @Benchmark public Object throwCatch() { try { return recursive(depth); } catch (Exception e) { return e; } } private Object recursive(int depth) throws Exception { if (depth == 0) { throw new LightException(); } return recursive(depth - 1); }
  • 11. 11 Exception traces @Param({"1", "2", "10", "100", "1000"}) int depth; @Benchmark public Object throwCatch() { try { return recursive(depth); } catch (Exception e) { return e; } } private Object recursive(int depth) throws Exception { if (depth == 0) { throw new LightException(); } return recursive(depth - 1); } Benchmark (depth) Mode Cnt Score Error Units Exceptions.throwCatch 1 avgt 10 8,020 ± 0,062 ns/op Exceptions.throwCatch 2 avgt 10 126,724 ± 0,697 ns/op Exceptions.throwCatch 10 avgt 10 620,068 ± 3,354 ns/op Exceptions.throwCatch 100 avgt 10 5750,440 ± 34,838 ns/op Exceptions.throwCatch 1000 avgt 10 58465,378 ± 251,693 ns/op
  • 12. 12 Exception traces @Benchmark public Object fillInStackTrace() { return new Exception(); } @Benchmark public Object getStackTrace() { return new Exception().getStackTrace(); } Benchmark Mode Cnt Score Error Units Exceptions.fillInStackTrace avgt 10 1207,092 ± 10,150 ns/op Exceptions.getStackTrace avgt 10 13388,665 ± 54,684 ns/op
  • 13. 13 Exception traces int depth = getStackTraceDepth(); stackTrace = new StackTraceElement[depth]; for (int i = 0; i < depth; i++) stackTrace[i] = getStackTraceElement(i); native calls public final class StackTraceElement { private String declaringClass; private String methodName; private String fileName; private int lineNumber; ... }
  • 14. 14 Exception traces Exception in thread "main" java.net.UnknownHostException: nonexistent.com at java.net.PlainSocketImpl.connect(java.base@9-ea/PlainSocketImpl.java:172) at java.net.SocksSocketImpl.connect(java.base@9-ea/SocksSocketImpl.java:402) at java.net.Socket.connect(java.base@9-ea/Socket.java:591) at java.net.Socket.connect(java.base@9-ea/Socket.java:540) at java.net.Socket.<init>(java.base@9-ea/Socket.java:436) at java.net.Socket.<init>(java.base@9-ea/Socket.java:213) at TestConnection.main(TestConnection.java:6) public final class StackTraceElement { private String moduleName; private String moduleVersion; private String declaringClass; private String methodName; private String fileName; private int lineNumber; new in JDK 9
  • 15. 15 Exception performance • new Exception() is cheap - fillInStackTrace() costs! - getStackTrace() costs even more! - O(stack_depth) • throw is cheap - catch ≈ goto in the same frame - O(stack_depth) Exception traces
  • 16. 16 Tips • Use -XX:-OmitStackTraceInFastThrow • No exceptions in normal control flow • But if you really want - use no-stack-trace constructor Exception traces
  • 17. When do you need stack traces?
  • 18. 18 Use cases "Thread-1" #18 prio=5 os_prio=0 tid=0x1923a800 nid=0xdf8 waiting on condition [0x19faf000] java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0xd94cec48> (a java.util.concurrent.locks.ReentrantLock$NonfairSync) at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:285) at RpcTest.clientLoop(RpcTest.java:34) at java.lang.Thread.run(Thread.java:745) "Thread-2" #19 prio=5 os_prio=0 tid=0x19243800 nid=0x3d40 runnable [0x1a0af000] java.lang.Thread.State: RUNNABLE at one.nio.net.NativeSocket.readFully(Native Method) at one.nio.rpc.RpcClient.invoke(RpcClient.java:76) at RpcTest.clientLoop(RpcTest.java:36) at java.lang.Thread.run(Thread.java:745)
  • 19. 19 Use cases "Thread-1" #18 prio=5 os_prio=0 tid=0x1923a800 nid=0xdf8 waiting on condition [0x19faf000] java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0xd94cec48> (a java.util.concurrent.locks.ReentrantLock$NonfairSync) at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:285) at RpcTest.clientLoop(RpcTest.java:34) at java.lang.Thread.run(Thread.java:745) Locked ownable synchronizers: - None "Thread-2" #19 prio=5 os_prio=0 tid=0x19243800 nid=0x3d40 runnable [0x1a0af000] java.lang.Thread.State: RUNNABLE at one.nio.net.NativeSocket.readFully(Native Method) at one.nio.rpc.RpcClient.invoke(RpcClient.java:76) at RpcTest.clientLoop(RpcTest.java:36) at java.lang.Thread.run(Thread.java:745) Locked ownable synchronizers: - <0xd94cec48> (a java.util.concurrent.locks.ReentrantLock$NonfairSync) -XX:+PrintConcurrentLocks
  • 20. 20 Use cases "RPC Client 192.168.0.11" #19 prio=5 os_prio=0 tid=0x19243800 nid=0x3d40 runnable [0x1a0af000] java.lang.Thread.State: RUNNABLE at one.nio.net.NativeSocket.readFully(Native Method) at one.nio.rpc.RpcClient.invoke(RpcClient.java:76) at RpcTest.clientLoop(RpcTest.java:36) at java.lang.Thread.run(Thread.java:745) Use Thread.currentThread().setName()
  • 22. 22 Use cases Logging logger.warning("Operation timed out"); [Controller.java:123] WARNING: Operation timed out public static String getLocation() { StackTraceElement s = new Exception().getStackTrace()[2]; return s.getFileName() + ':' + s.getLineNumber(); }
  • 23. 23 Use cases A better way? Thread.current().getStackTrace() public StackTraceElement[] getStackTrace() { if (this != Thread.currentThread()) { // ... some magic ... } else { // Don't need JVM help for current thread return (new Exception()).getStackTrace(); } }
  • 24. 24 Use cases A better way! public static String getLocation() { StackTraceElement s = sun.misc.SharedSecrets.getJavaLangAccess() .getStackTraceElement(new Exception(), 2); return s.getFileName() + ':' + s.getLineNumber(); } Not in JDK 9
  • 25. 25 Caller sensitive methods • @CallerSensitive - Class.forName - ResourceBundle.getBundle - System.loadLibrary - AccessController.doPrivileged • sun.reflect.Reflection.getCallerClass Use cases
  • 26. 26 Stack Walking API • Limit depth • Filter frames • Lazy construction • Class instances instead of Class names Stack Walking API
  • 28. 28 java.lang.StackWalker • StackWalker.getInstance() • StackWalker.getInstance(Set<Option> options) - RETAIN_CLASS_REFERENCE - SHOW_REFLECT_FRAMES - SHOW_HIDDEN_FRAMES • StackWalker.getInstance(Set<Option> options, int estimateDepth) Stack Walking API
  • 29. 29 Stack Walking API StackWalker sw = StackWalker.getInstance(); sw.forEach(System.out::println); StackWalking.dumpStackTrace(StackWalking.java:7) StackWalking.main(StackWalking.java:12) com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
  • 30. 30 Stack Walking API StackWalker sw = StackWalker.getInstance(StackWalker.Option.SHOW_REFLECT_FRAMES); sw.forEach(System.out::println); StackWalking.dumpStackTrace(StackWalking.java:7) StackWalking.main(StackWalking.java:12) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:531) com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
  • 31. 31 Stack Walking API StackWalker sw = StackWalker.getInstance(StackWalker.Option.SHOW_HIDDEN_FRAMES); sw.forEach(System.out::println); StackWalking.dumpStackTrace(StackWalking.java:7) StackWalking$$Lambda$1/1287712235.run(Unknown Source bci:0) StackWalking.main(StackWalking.java:12) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:531) com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
  • 32. 32 Stack Walking API public <T> T walk(Function<? super Stream<StackFrame>, ? extends T> function) public static StackFrame getCallerFrame() { return StackWalker.getInstance() .walk(stream -> stream.skip(2).findFirst()) .orElseThrow(NoSuchElementException::new); } return StackWalker.getInstance(RETAIN_CLASS_REFERENCE).getCallerClass();
  • 33. 33 Stack Walking API StackWalker sw = StackWalker.getInstance(); List<StackFrame> frames = sw.walk(stream -> stream.filter(sf -> sf.getClassName().startsWith("org.apache.")) .limit(10) .collect(Collectors.toList())); public Stream<StackFrame> stream(); Why NOT?
  • 34. 34 Stack Walking API /* package-private */ interface LiveStackFrame extends StackFrame { public Object[] getMonitors(); public Object[] getLocals(); public Object[] getStack(); public static StackWalker getStackWalker(); }
  • 36. 36 Stack size Fun with recursion static int depth; static void recursion() { depth++; recursion(); } public static void main(String[] args) { recursion(); }
  • 37. 37
  • 39. 39 Stack size • -Xss, -XX:ThreadStackSize • Thread(threadGroup, target, name, stackSize) • java.lang.OutOfMemoryError: Unable to create new native thread Stack size
  • 40. 40 Stack size • Default stack size? - x86: 320 KB - x64: 1MB • Minimum stack size? - ~228 KB Stack size frame empty shadow 1 2 frame frame
  • 41. 41
  • 43. 43 Types of profiling • Instrumentation • Sampling - Take stack traces every 10 – 100 ms - Suitable for production Profiling public void someMethod(String... args) { Profiler.onMethodEnter("myClass.someMethod"); // method body Profiler.onMethodExit("myClass.someMethod"); }
  • 45. 45 Sampling bias • Stack traces are taken at VM safepoint • Running and idle threads are sampled equally • Blocking native calls appear as Runnable • Victims: VisualVM, JProfiler, YourKit… Profiling
  • 46. 46 Fair profiler? • setitimer + SIGPROF • SIGPROF handler collects stack trace of signaled thread • HotSpot internal API: AsyncGetCallTrace - Used in Oracle Solaris Studio Profiling
  • 47. 47 Profiling AsyncGetCallTrace ASGCT_CallFrame frames[MAX_FRAMES]; ASGCT_CallTrace trace = {env, MAX_FRAMES, frames}; AsyncGetCallTrace(&trace, trace.num_frames, ucontext); from signal handler https://github.com/apangin/async-profiler
  • 49. 49 In-process • Java - Thread.getAllStackTraces - ThreadMXBean.getThreadInfo • JVMTI - GetAllStackTraces - Compact representation (jmethodID) - Used by profilers Thread dump StackTraceElement[] + locked monitors
  • 50. 50 External • SIGQUIT (kill -3, Ctrl + ) - Processed by JVM at max. speed - No intermediate structures - Prints to stdout • jstack - Dynamic attach • jstack -F - Serviceability Agent Thread dump
  • 51. 51 Thread dump Dynamic attach jstack JVM 1. creates .attach_pid1234 sends SIGQUIT 2. starts AttachListener UNIX socket /tmp/.java_pid1234 verifies euid + egid 3. sends “threaddump” 4. executes command sends output back to socket
  • 52. 52 Thread dump Dynamic attach on Windows jstack JVM 1. creates .pipejavatool1234 2. WriteProcessMemory (command, args, pipe name) 3. CreateRemoteThread 4. executes command sends output back to pipe
  • 53. 53 jstack • Pros. - Performed by JVM at max. speed - Compatibility with different JVM versions • Cons. - Should be run by the same user (euid / egid) - Works only on healthy JVM - Can be disabled (-XX:+DisableAttachMechanism) Thread dump
  • 54. 54 Dynamic attach Demo • https://github.com/apangin/jattach - datadump, threaddump, dumpheap, inspectheap - properties, agentProperties - printflag, setflag - jcmd - load Thread dump
  • 55. 55 Thread dump Serviceability Agent jstack -F JVM 1. PTRACE_ATTACH the process suspends (SIGSTOP) 2. Read remote memory PTRACE_PEEKDATA 3. Reconstruct VM structures 4. Traverse reconstructed stack
  • 56. 56 jstack -F • Pros. - No cooperation from JVM required - root can dump any process - Mixed Java+Natives frames (-m) • Cons. - Slow - Requires the same version of JVM - No thread names, no lock info Thread dump
  • 57. 57 Thread dump How to dump? public static void dump() throws AttachNotSupportedException, IOException { String vmName = ManagementFactory.getRuntimeMXBean().getName(); String pid = vmName.substring(0, vmName.indexOf('@')); HotSpotVirtualMachine vm = (HotSpotVirtualMachine) VirtualMachine.attach(pid); try { vm.localDataDump(); } finally { vm.detach(); } } https://github.com/odnoklassniki/one-nio/blob/master/src/one/nio/mgt/
  • 59. 59 jmap • jmap -dump:live,format=b,file=heap.bin PID • jmap -histo PID Heap dump num #instances #bytes class name ---------------------------------------------- 1: 1943 404550984 [J 2: 5622 41517944 [B 3: 306128 33720768 [C 4: 292548 7021152 java.lang.String 5: 131072 4194304 one.nio.lock.RWLock 6: 103634 3316288 java.util.HashMap$Node 7: 89096 2138304 java.lang.Long 8: 17503 1850168 [Ljava.lang.Object; 9: 50688 1622016 [Lone.cassandra12.remoting.Host;
  • 60. 60 Heap dump jmap vs. jmap -F + Speed + Version tolerance + Supports “live” option - Requires the same user - Works only on healthy JVM + Can be used on hung process + Can be used on core dump + root can dump everything - Slow - Requires the same JDK - Heap may be inconsistent jmap jmap -F
  • 61. 61 Heap dump Offline heap dumps $ sudo gcore 1234 $ jmap -dump:format=b,file=heap.bin /path/to/java core.1234 Windows: WinDbg.exe jmap -dump:format=b,file=heap.bin C:pathtojava.exe core.mdmp
  • 62. 62 Automatic heap dumps • -XX:+HeapDumpOnOutOfMemoryError • -XX:+HeapDumpBeforeFullGC • -XX:+HeapDumpAfterFullGC • -XX:HeapDumpPath=/tmp (or /tmp/dump.bin) Heap dump
  • 63. 63 Heap dump Manageable options HotSpotDiagnosticMXBean bean = ManagementFactory.newPlatformMXBeanProxy( ManagementFactory.getPlatformMBeanServer(), "com.sun.management:type=HotSpotDiagnostic", HotSpotDiagnosticMXBean.class); bean.setVMOption("HeapDumpOnOutOfMemoryError", "true"); bean.setVMOption("HeapDumpPath", fileName); $ jinfo -flag +HeapDumpOnOutOfMemoryError 1234 $ jinfo -flag HeapDumpPath=/tmp 1234
  • 64. 64 Kill JVM after heap dump • -XX:+ExitOnOutOfMemoryError • -XX:+CrashOnOutOfMemoryError Heap dump $ java -XX:+HeapDumpOnOutOfMemoryError -XX:OnOutOfMemoryError="kill -9 %p" com.myproject.TestApp JDK 8u92
  • 66. 66 Heap dump JMX HotSpotDiagnosticMXBean bean = ManagementFactory.newPlatformMXBeanProxy( ManagementFactory.getPlatformMBeanServer(), "com.sun.management:type=HotSpotDiagnostic", HotSpotDiagnosticMXBean.class); bean.dumpHeap("/tmp/heap.bin", true);
  • 67. 67 Heap dump JVMTI jvmtiIterationControl JNICALL HeapObjectCallback(jlong class_tag, jlong size, jlong* tag_ptr, void* user_data) { *tag_ptr = 1; return JVMTI_ITERATION_CONTINUE; } jvmti->IterateOverInstancesOfClass(targetClass, JVMTI_HEAP_OBJECT_EITHER, HeapObjectCallback, NULL); jlong tag = 1; jint count; jobject* instances; jvmti->GetObjectsWithTags(1, &tag, &count, &instances, NULL);
  • 68. 68 Heap dump Serviceability Agent SystemDictionary dictionary = VM.getVM().getSystemDictionary(); Klass klass = dictionary.find("java/lang/String", null, null); VM.getVM().getObjectHeap().iterateObjectsOfKlass(new DefaultHeapVisitor() { public boolean doObj(Oop obj) { obj.printValue(); System.out.println(); return false; } }, klass); $JAVA_HOME/lib/sa-jdi.jar
  • 70. 70 Conclusions • Use thread dumps and heap dumps - In PROD! • In-process - Java (JMX), JVMTI • Externally - Dynamic attach - Serviceability Agent Heap dump