Clojure

StackOverflowError on exception in reducef for PersistentHashMap fold

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: Release 1.5
  • Fix Version/s: Release 1.6
  • Component/s: None
  • Labels:
    None
  • Environment:
    Clojure 1.5.0-alpha4, Sun Java 1.6.0_35, with [org.codehaus.jsr166-mirror/jsr166y "1.7.0"]
  • Approval:
    Vetted

Description

If reducef throws an exception, the PHM fold code can descend into an infinite loop, causing a stack overflow which masks the problem. This situation is commented "aargh" in PersistentHashMap.java line 444 (as of 412a51d).

To reproduce:

user> (require '[clojure.core.reducers :as r])
nil
user> (r/fold (fn ([]) ([ret k v] (+ 3 "foo") ret)) (into {} (map (juxt identity identity) (range 10000))))
;; boom

This results in a stack like: https://raw.github.com/gist/3bab917287a7fd635a84/f38bfe3e270556e467f3fc02062af7ea10781390/gistfile1.txt

Activity

Timothy Baldridge made changes -
Field Original Value New Value
Assignee Timothy Baldridge [ halgari ]
Timothy Baldridge made changes -
Approval Vetted [ 10003 ]
Priority Minor [ 4 ] Major [ 3 ]
Assignee Timothy Baldridge [ halgari ]
Rich Hickey made changes -
Fix Version/s Release 1.6 [ 10157 ]

People

  • Assignee:
    Unassigned
    Reporter:
    Tom Jack
Vote (0)
Watch (1)

Dates

  • Created:
    Updated: