Instrumenting next gives maximum call stack size exceeded
Completed
Description fields
Description
rest and last can be successfully instrumented, but next seems to be vulnerable to a maximum call stack size exceeded error.
Repro:
$ clj -Srepro -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.439"} org.clojure/test.check {:mvn/version "RELEASE"}}}' -m cljs.main -re node -r
ClojureScript 1.10.439
cljs.user=> (require '[clojure.spec.alpha :as s])
nil
cljs.user=> (require '[clojure.spec.test.alpha :as stest])
nil
cljs.user=> (s/fdef clojure.core/next :args (s/cat :coll seqable?))
cljs.core/next
cljs.user=> (stest/instrument `next)
repl:42
throw e__6573__auto__;
^
RangeError: Maximum call stack size exceeded
at /private/var/folders/7t/gpzjxhts24d5wvqys1dfvrd80000gn/T/out92072095452558798682044329212169952/cljs/spec/test/alpha.js:147:18
at Object.G__47574__delegate (/private/var/folders/7t/gpzjxhts24d5wvqys1dfvrd80000gn/T/out92072095452558798682044329212169952/cljs/spec/test/alpha.js:181:27)
at Object.G__47574 [as next] (/private/var/folders/7t/gpzjxhts24d5wvqys1dfvrd80000gn/T/out92072095452558798682044329212169952/cljs/spec/test/alpha.js:191:27)
at Function.cljs.core.apply_to_simple.cljs$core$IFn$_invoke$arity$2 (/private/var/folders/7t/gpzjxhts24d5wvqys1dfvrd80000gn/T/out92072095452558798682044329212169952/cljs/core.js:13123:99)
at Function.cljs.core.apply.cljs$core$IFn$_invoke$arity$2 (/private/var/folders/7t/gpzjxhts24d5wvqys1dfvrd80000gn/T/out92072095452558798682044329212169952/cljs/core.js:13405:34)
at cljs$core$apply (/private/var/folders/7t/gpzjxhts24d5wvqys1dfvrd80000gn/T/out92072095452558798682044329212169952/cljs/core.js:13358:24)
at /private/var/folders/7t/gpzjxhts24d5wvqys1dfvrd80000gn/T/out92072095452558798682044329212169952/cljs/spec/test/alpha.js:157:24
at Object.G__47574__delegate (/private/var/folders/7t/gpzjxhts24d5wvqys1dfvrd80000gn/T/out92072095452558798682044329212169952/cljs/spec/test/alpha.js:181:27)
at Object.G__47574 [as next] (/private/var/folders/7t/gpzjxhts24d5wvqys1dfvrd80000gn/T/out92072095452558798682044329212169952/cljs/spec/test/alpha.js:191:27)
at Function.cljs.core.apply_to_simple.cljs$core$IFn$_invoke$arity$2 (/private/var/folders/7t/gpzjxhts24d5wvqys1dfvrd80000gn/T/out92072095452558798682044329212169952/cljs/core.js:13123:99)
(node:11768) [DEP0097] DeprecationWarning: Using a domain property in MakeCallback is deprecated. Use the async_context variant of MakeCallback or the AsyncResource class instead.
cljs.user=>
Patch CLJS-3023-2 provides a solution by going through the protocol method directly instead of using the function next in apply-to-simple. This seems reasonable, since this was already done to first as well.
Patch CLJS-3023-3 restores the fallback for seqs that do not implement INext.
rest
andlast
can be successfully instrumented, butnext
seems to be vulnerable to a maximum call stack size exceeded error.Repro:
$ clj -Srepro -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.439"} org.clojure/test.check {:mvn/version "RELEASE"}}}' -m cljs.main -re node -r ClojureScript 1.10.439 cljs.user=> (require '[clojure.spec.alpha :as s]) nil cljs.user=> (require '[clojure.spec.test.alpha :as stest]) nil cljs.user=> (s/fdef clojure.core/next :args (s/cat :coll seqable?)) cljs.core/next cljs.user=> (stest/instrument `next) repl:42 throw e__6573__auto__; ^ RangeError: Maximum call stack size exceeded at /private/var/folders/7t/gpzjxhts24d5wvqys1dfvrd80000gn/T/out92072095452558798682044329212169952/cljs/spec/test/alpha.js:147:18 at Object.G__47574__delegate (/private/var/folders/7t/gpzjxhts24d5wvqys1dfvrd80000gn/T/out92072095452558798682044329212169952/cljs/spec/test/alpha.js:181:27) at Object.G__47574 [as next] (/private/var/folders/7t/gpzjxhts24d5wvqys1dfvrd80000gn/T/out92072095452558798682044329212169952/cljs/spec/test/alpha.js:191:27) at Function.cljs.core.apply_to_simple.cljs$core$IFn$_invoke$arity$2 (/private/var/folders/7t/gpzjxhts24d5wvqys1dfvrd80000gn/T/out92072095452558798682044329212169952/cljs/core.js:13123:99) at Function.cljs.core.apply.cljs$core$IFn$_invoke$arity$2 (/private/var/folders/7t/gpzjxhts24d5wvqys1dfvrd80000gn/T/out92072095452558798682044329212169952/cljs/core.js:13405:34) at cljs$core$apply (/private/var/folders/7t/gpzjxhts24d5wvqys1dfvrd80000gn/T/out92072095452558798682044329212169952/cljs/core.js:13358:24) at /private/var/folders/7t/gpzjxhts24d5wvqys1dfvrd80000gn/T/out92072095452558798682044329212169952/cljs/spec/test/alpha.js:157:24 at Object.G__47574__delegate (/private/var/folders/7t/gpzjxhts24d5wvqys1dfvrd80000gn/T/out92072095452558798682044329212169952/cljs/spec/test/alpha.js:181:27) at Object.G__47574 [as next] (/private/var/folders/7t/gpzjxhts24d5wvqys1dfvrd80000gn/T/out92072095452558798682044329212169952/cljs/spec/test/alpha.js:191:27) at Function.cljs.core.apply_to_simple.cljs$core$IFn$_invoke$arity$2 (/private/var/folders/7t/gpzjxhts24d5wvqys1dfvrd80000gn/T/out92072095452558798682044329212169952/cljs/core.js:13123:99) (node:11768) [DEP0097] DeprecationWarning: Using a domain property in MakeCallback is deprecated. Use the async_context variant of MakeCallback or the AsyncResource class instead. cljs.user=>
Patch CLJS-3023-2 provides a solution by going through the protocol method directly instead of using the function
next
inapply-to-simple
. This seems reasonable, since this was already done tofirst
as well.Patch CLJS-3023-3 restores the fallback for seqs that do not implement INext.
Patch CLJS-3023-4 rebased on master.