Saturday, August 4, 2018

Stack Trace got eaten up in the log

During the production troubleshooting today, we found out in the log that NPE was logged occasionally, but without detailed stack trace. We've made sure that we always log the stack trace in our code. So, what was going on?

After searching back in our log history (we have a log aggregation service that keeps log history), we found there were NPEs with the full stack trace, then after some time, the stack trace was gone.

In this end, this turns out to be caused by a Hotspot JIT compiler optimization, when a particular exception keeps being thrown up to a threshold, the same exception stack trace will not be filled anymore due to performance impact of throwing exceptions.

The solution is to turn off this optimization by providing this JVM option:

 -XX:-OmitStackTraceInFastThrow

References:

1. Stackoverflow post on "NullPointerException in Java with no StackTrace"
2. A more detailed analysis with a demo app




2 comments:

  1. Whoa! I’m enjoying the template/theme of this website. It’s simple, yet effective. A lot of times it’s very hard to get that “perfect balance” between superb usability and visual appeal. I must say you’ve done a very good job with this.
    Acer service centre in Chennai | acer mobile service center in chennai | Laptop display replacement in chennai | Laptop motherboard service in chennai | Laptop Water damage service in chennai | acer services in chennai | Laptop data recovery services in chennai | Laptop battery replacement in chennai

    ReplyDelete
  2. I really enjoy the blog article.Much thanks again.
    SAP PP training from india
    SAP Qm training from india
    SAP Sd training from india
    SAP Security training from india
    SAP Grc training from india
    <a href="http://kitsonlinetrainings.com/course/linux-online-training> Linux training from india </a>

    ReplyDelete