<< Back to previous view

[CLJ-691] missing stacktrace confuses REPL error reporting Created: 13/Dec/10  Updated: 21/Mar/14  Resolved: 17/Dec/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Release 1.3

Type: Defect Priority: Major
Reporter: Stuart Halloway Assignee: Stuart Halloway
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File 0691-stacktrace-missing.patch    
Approval: Ok

 Description   

when Java is in a bad mood, exceptions start flying without any accompanying stack traces. This causes the default REPL's error reporting to barf, as it currently assumes that the first stack trace element always exists. You can see this by trying the following snippet at the REPL several times in succession:

(def x (byte-array 100000000))

When Java is somewhat angry, you will see the appropriate

OutOfMemoryError Java heap space  clojure.lang.Numbers.byte_array (Numbers.java:1409)

Eventually Java gets angrier and stops providing stack traces, causing an aget error in clojure.main instead.



 Comments   
Comment by Stuart Halloway [ 13/Dec/10 9:46 AM ]

Results with attached patch:

(def x (byte-array 100000000))
=> OutOfMemoryError Java heap space  clojure.lang.Numbers.byte_array (Numbers.java:1409)
;; eventually you get:
def x (byte-array 100000000))
=>OutOfMemoryError Java heap space  [trace missing]
Comment by Ivan Kozik [ 21/Mar/14 3:33 AM ]

To spare readers who find this page after Googling "trace missing": don't go on a wild goose chase for an OpenJDK bug that makes stack traces disappear. It's a somewhat-documented HotSpot optimization, as described here: https://github.com/technomancy/leiningen/issues/1025#issuecomment-38253962

Comment by Andy Fingerhut [ 21/Mar/14 1:49 PM ]

See also CLJ-1102 which fixes some other cases where Clojure was throwing new exceptions when incorrectly expecting at least 1 StackTraceElement in an exception's stack trace. That problem existed up through Clojure 1.5.1, but is fixed in Clojure 1.6.0.

Generated at Sat Oct 25 19:41:48 CDT 2014 using JIRA 4.4#649-r158309.