New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid StackOverflowError while reading a VCF with many lines of meta #252
Conversation
…meta With current implementation, many lines of meta (say 4k lines of contig definition) causes StackOverflowError like below. ``` :cause nil :via [{:type java.lang.StackOverflowError :message nil :at [clojure.lang.PersistentHashMap$BitmapIndexedNode ensureEditable "PersistentHashMap.java" 812]}] :trace [[clojure.lang.PersistentHashMap$BitmapIndexedNode ensureEditable "PersistentHashMap.java" 812] [clojure.lang.PersistentHashMap$BitmapIndexedNode assoc "PersistentHashMap.java" 894] [clojure.lang.PersistentHashMap$TransientHashMap doAssoc "PersistentHashMap.java" 327] [clojure.lang.ATransientMap assoc "ATransientMap.java" 64] [clojure.lang.PersistentHashMap create "PersistentHashMap.java" 78] [clojure.core$hash_map invokeStatic "core.clj" 389] [clojure.core$hash_map doInvoke "core.clj" 381] [clojure.lang.RestFn applyTo "RestFn.java" 137] [clojure.core$apply invokeStatic "core.clj" 667] [clojure.core$apply invoke "core.clj" 662] [cljam.io.vcf.reader$parse_data_line invokeStatic "reader.clj" 173] [cljam.io.vcf.reader$parse_data_line invoke "reader.clj" 154] [cljam.io.vcf.reader$read_data_lines invokeStatic "reader.clj" 181] [cljam.io.vcf.reader$read_data_lines invoke "reader.clj" 175] [cljam.io.vcf.reader$read_data_lines invokeStatic "reader.clj" 183] ;; continues recursive call's stack trace ``` I fixed the problem explicitly call `recur` to utlize tail call optimization.
Codecov Report
@@ Coverage Diff @@
## master #252 +/- ##
=======================================
Coverage 88.70% 88.70%
=======================================
Files 76 76
Lines 6305 6305
Branches 438 438
=======================================
Hits 5593 5593
Misses 274 274
Partials 438 438
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the fix! LGTM 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR! LGTM 👍
With current implementation, many lines of meta (say 4k lines of contig definition) causes StackOverflowError like below.
I fixed the problem by explicitly calling
recur
to utilize tail call optimization.