IndexOutOfBoundsException for exceptions with no stack trace filled in #25

Closed
weissjeffm opened this Issue Jul 17, 2013 · 2 comments

2 participants

@weissjeffm
(pst (doto (Exception.)
       (.setStackTrace (make-array java.lang.StackTraceElement 0))))
IndexOutOfBoundsException 
    clojure.lang.RT.nthFrom (RT.java:795)
    clojure.lang.RT.nth (RT.java:764)
    clj-stacktrace.utils/quartile1 (utils.clj:19)
    clj-stacktrace.utils/fence (utils.clj:36)
    clj-stacktrace.repl/find-source-width (repl.clj:95)
    clj-stacktrace.repl/pst-on (repl.clj:107)
    clj-stacktrace.repl/pst (repl.clj:117)

Now, how I end up with an exception with no stack trace in production, I am not 100% sure. I suspect it is the jvm optimization that leaves out stacktraces in recurring exceptions:
http://stackoverflow.com/questions/4659151/recurring-exception-without-a-stack-trace-how-to-reset

I should be able to work around the problem with
:jvm-opts ["-XX:-OmitStackTraceInFastThrow"]
but haven't tried it yet.

clj-stacktrace shouldn't be assuming there is a non-zero length array of StackTraceElement.

Fix should be pretty straightforward, will try to submit a pr.

@weissjeffm

The :jvm-opts did work around the problem so that option being on by default does seem to be the root cause.

@nahuel

I just opened a bug and an analysis before seeing this one, is related: #26

@nahuel nahuel added a commit to nahuel/clj-stacktrace that referenced this issue Aug 24, 2013
@nahuel nahuel fixes IndexOutOfBoundsExceptions when trying to print exceptions with…
… short stack traces (< 3 StackElements). Fixes mmcgrana/clj-stacktrace#25 and mmcgrana/clj-stacktrace#26
62d3d19
@technomancy technomancy closed this in #27 Oct 14, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment