Skip to content

java.lang.StackOverflowError with deep recursive function call. #284

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

Open
He-Pin opened this issue Apr 18, 2025 · 1 comment
Open

java.lang.StackOverflowError with deep recursive function call. #284

He-Pin opened this issue Apr 18, 2025 · 1 comment

Comments

@He-Pin
Copy link
Contributor

He-Pin commented Apr 18, 2025

recursive_function utest may fail if the stack is not rich.

            local infiniteLoop(x) = infiniteLoop(x + 1);
            infiniteLoop(0)

A better way may be to evaluate with an ArrayDequeue, but this will need some rework on the evaluator.

java.lang.StackOverflowError
	at java.base/java.lang.ClassLoader.defineClass1(Native Method)
	at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1027)
	at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
	at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
	at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
	at sjsonnet.Error$$anonfun$withStackFrame$1.isDefinedAt(Error.scala:63)
	at sjsonnet.Evaluator.visitExpr(Evaluator.scala:72)
	at sjsonnet.Evaluator$$anon$1.evalRhs(Evaluator.scala:599)
	at sjsonnet.Val$Func.apply2(Val.scala:553)
	at sjsonnet.Evaluator.visitApply2(Evaluator.scala:241)
	at sjsonnet.Evaluator.visitExpr(Evaluator.scala:54)
	at sjsonnet.Evaluator.visitIfElse(Evaluator.scala:148)
	at sjsonnet.Evaluator.visitExpr(Evaluator.scala:51)
	at sjsonnet.Evaluator$$anon$1.evalRhs(Evaluator.scala:599)
@He-Pin
Copy link
Contributor Author

He-Pin commented Apr 24, 2025

I checked both go-jsonnet and cpp jsonnet, I found both are using a ArrayDeque like thing to do a stack , which may is more complex, may not need that for now?

and in CertainLach/jrsonnet#121 , @CertainLach is using a hypered one.

Or, we can make use of scala.util.control.TailCalls to handle it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant