I have an array with 2791 subarrays.

[[DotEdge("io_stratego2abox_0_0","io_wrap_1_0")],[DotEdge("stratego2abox_0_0","topdown_1_0"), ..., [],[],[],[]]

Trying to concat this into a single array causes a stack overflow.

Fatal error at
	io_wrap_custom_6_0
	option_wrap_5_0
	io_input_2_0
	io_output_2_0
	analyze_callgraph_0_0
	concat_0_0
	at_end_1_0
	at_end_1_0
...truncated...
	at_end_1_0
	at_end_1_0
	at_end_1_0
Stack overflow (use java -ss4m to increase the stack size)
Exception in thread "main" java.lang.StackOverflowError
	at org.strategoxt.lang.SRTS_EXT_at_end_1_0.invoke(SRTS_EXT_at_end_1_0.java:28)
	at org.strategoxt.lang.compat.override.performance_tweaks.at_end_1_0_override.invoke(at_end_1_0_override.java:21)
	at org.strategoxt.stratego_lib.g_1317.invoke(g_1317.java:46)
	at org.strategoxt.stratego_lib.lifted2006.invoke(lifted2006.java:24)
	at org.strategoxt.lang.SRTS_EXT_at_end_1_0.invoke(SRTS_EXT_at_end_1_0.java:44)
	at org.strategoxt.lang.compat.override.performance_tweaks.at_end_1_0_override.invoke(at_end_1_0_override.java:21)
	at org.strategoxt.stratego_lib.g_1317.invoke(g_1317.java:46)
	at org.strategoxt.stratego_lib.lifted2006.invoke(lifted2006.java:24)
...truncated...
	at org.strategoxt.lang.SRTS_EXT_at_end_1_0.invoke(SRTS_EXT_at_end_1_0.java:44)
	at org.strategoxt.lang.compat.override.performance_tweaks.at_end_1_0_override.invoke(at_end_1_0_override.java:21)
	at org.strategoxt.stratego_lib.g_1317.invoke(g_1317.java:46)
	at org.strategoxt.stratego_lib.lifted2006.invoke(lifted2006.java:24)

This, of course, is to be expected since the definition of both concat (and the at_end strategy it uses) are recursive. However, firstly, ideally this shouldn’t cause a Java exception/crash. Secondly, such a basic strategy might be better implemented in an iterative way (perhaps as a primitive?), or Stratego should support tail call optimization?

Submitted by D. Pelsmaeker on 25 November 2014 at 16:20

On 25 November 2014 at 17:26 Gabriël Konat commented:

If concat does not have a performance override, that seems like a major oversight. There is a way to add performance overrides in: https://github.com/metaborg/strategoxt/blob/java-bootstrap/strategoxt/stratego-libraries/java-backend/java/runtime/org/strategoxt/lang/compat/override/performance-tweaks.str. You could add an override to an external strategy that is implemented in Java, similar to how at-end is overridden to: https://github.com/metaborg/strategoxt/blob/java-bootstrap/strategoxt/stratego-libraries/java-backend/java/runtime/org/strategoxt/lang/SRTS_EXT_at_end_1_0.java.


On 5 December 2014 at 14:59 D. Pelsmaeker commented:

There’s now a performance override for concat (see strategoxt pull request #12).


On 23 August 2016 at 09:40 Jeff Smits closed this issue.

Log in to post comments