I sometimes get ArrayIndexOutOfBoundsException after selection changes or on reference resolution, like:

Internal error evaluating editor-properties (ArrayIndexOutOfBoundsException; see error log)
rewriting failed
Internal error evaluating editor-resolve (ArrayIndexOutOfBoundsException; see error log)
Internal error evaluating editor-resolve (ArrayIndexOutOfBoundsException; see error log)
Internal error evaluating editor-properties (ArrayIndexOutOfBoundsException; see error log)
rewriting failed, trace:
Internal error evaluating editor-properties (ArrayIndexOutOfBoundsException; see error log)
rewriting failed, trace:
	position_of_term_1_1

The error log contains no information.

Submitted by Gabriël Konat on 28 March 2014 at 11:15

On 28 March 2014 at 13:18 Daco Harkes commented:

I experience the same error

Internal error evaluating editor-properties (ArrayIndexOutOfBoundsException; see error log)
rewriting failed, trace:
	position_of_term_1_0
	position_of_term_1_1
	position_of_term_1_1

The java stack trace is not really informative:

java.lang.ArrayIndexOutOfBoundsException

On 28 March 2014 at 13:21 Daco Harkes commented:

I’ve also got it for the outline

Internal error evaluating outline (ArrayIndexOutOfBoundsException; see error log)
rewriting failed, trace:
	position_of_term_1_0
	position_of_term_1_1
	position_of_term_1_1

The editor-properties and editor-resolve use more or less the same code. But the outline uses completely different strategies. So the error seems to be somewhere else.


On 28 March 2014 at 16:09 Oskar van Rest commented:

Is this with the latest nightly? I thought I fixed this yesterday. I cannot reproduce it either.


On 28 March 2014 at 16:34 Daco Harkes commented:

Yes: Spoofax Core 1.2.0.0-s41333


On 28 March 2014 at 17:37 Gabriël Konat commented:

Yes, running the same version as Daco. The weird thing is that it only seems to happen once per Eclipse instance, or once per build, and only sometimes in some languages. The easiest way I can reproduce it is to close Eclipse, start it again, and immediately start selecting text (dragging the mouse around in the file) in my editor for the QL language (https://github.com/metaborg/lwc2013/tree/master/org.spoofax.lang.lwc.ql2)


On 28 March 2014 at 17:46 Gabriël Konat commented:

I got more information about the exceptions in my error log this time, 6 of them. Might this be related to https://yellowgrass.org/issue/Spoofax/757, I got 6 exceptions there as well while trying to reproduce this error, some mentioning position of term (see my latest comment). Here’s the stacktraces that I got, it shows ArrayIndexOutOfBoundsException where the index is negative, which will always fail of course.

Internal error evaluating strategy editor-properties
	editor_properties_0_0
	get_all_editor_properties_1_2
	target_prop_1_0
	pp_ast_1_0
	z_112972
	prettyprint_Start_0_0
	pp_one_Z_1_0
	pp_one_1_0
	m_112965
	pp_V_list_1_1
	map_1_0
	pp_one_V_1_0
	pp_one_1_0
	m_112965
	pp_one_Z_1_0
	pp_one_1_0
	m_112965

java.lang.ArrayIndexOutOfBoundsException: -4
	at org.spoofax.interpreter.core.StackTracer.push(StackTracer.java:39)
	at org.strategoxt.stratego_lib.set_config_0_0.invoke(set_config_0_0.java:21)
	at org.strategoxt.imp.runtime.services.StrategoObserver.configureRuntime(StrategoObserver.java:816)
	at org.strategoxt.imp.runtime.services.StrategoObserver.configureRuntime(StrategoObserver.java:807)
	at org.strategoxt.imp.runtime.services.StrategoObserver.invoke(StrategoObserver.java:614)
	at org.strategoxt.imp.runtime.services.StrategoObserver.invokeSilent(StrategoObserver.java:695)
	at org.strategoxt.imp.runtime.services.StrategoObserver.invokeSilent(StrategoObserver.java:686)
	at org.strategoxt.imp.runtime.services.views.properties.PropertiesService.getProperties(PropertiesService.java:90)
	at org.strategoxt.imp.runtime.editor.StrategoTermSelection.getFirstElement(StrategoTermSelection.java:68)
	at org.strategoxt.imp.runtime.editor.SpoofaxEditor$3.run(SpoofaxEditor.java:109)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)

Internal error evaluating strategy editor-properties
	editor_properties_0_0
	get_all_editor_properties_1_2
	target_prop_1_0
	pp_ast_1_0
	z_112972
	prettyprint_Start_0_0
	pp_one_Z_1_0
	pp_one_1_0
	m_112965
	pp_V_list_1_1
	map_1_0
	pp_one_V_1_0
	pp_one_1_0
	m_112965
	pp_one_Z_1_0
	pp_one_1_0
	m_112965
	pp_one_Z_1_0
	pp_one_1_0
	m_112965

java.lang.ArrayIndexOutOfBoundsException: -6
	at org.spoofax.interpreter.core.StackTracer.push(StackTracer.java:39)
	at org.strategoxt.stratego_lib.set_config_0_0.invoke(set_config_0_0.java:21)
	at org.strategoxt.imp.runtime.services.StrategoObserver.configureRuntime(StrategoObserver.java:816)
	at org.strategoxt.imp.runtime.services.StrategoObserver.configureRuntime(StrategoObserver.java:807)
	at org.strategoxt.imp.runtime.services.StrategoObserver.invoke(StrategoObserver.java:614)
	at org.strategoxt.imp.runtime.services.StrategoObserver.invokeSilent(StrategoObserver.java:695)
	at org.strategoxt.imp.runtime.services.StrategoObserver.invokeSilent(StrategoObserver.java:686)
	at org.strategoxt.imp.runtime.services.views.properties.PropertiesService.getProperties(PropertiesService.java:90)
	at org.strategoxt.imp.runtime.editor.StrategoTermSelection.getFirstElement(StrategoTermSelection.java:68)
	at org.strategoxt.imp.runtime.editor.SpoofaxEditor$3.run(SpoofaxEditor.java:109)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)


Internal error evaluating strategy editor-properties
	editor_properties_0_0
	get_all_editor_properties_1_2
	target_prop_1_0
	pp_ast_1_0
	z_112972
	prettyprint_Start_0_0
	pp_one_Z_1_0
	pp_one_1_0
	m_112965

java.lang.ArrayIndexOutOfBoundsException: -3
	at org.spoofax.interpreter.core.StackTracer.push(StackTracer.java:39)
	at org.strategoxt.stratego_lib.set_config_0_0.invoke(set_config_0_0.java:21)
	at org.strategoxt.imp.runtime.services.StrategoObserver.configureRuntime(StrategoObserver.java:816)
	at org.strategoxt.imp.runtime.services.StrategoObserver.configureRuntime(StrategoObserver.java:807)
	at org.strategoxt.imp.runtime.services.StrategoObserver.invoke(StrategoObserver.java:614)
	at org.strategoxt.imp.runtime.services.StrategoObserver.invokeSilent(StrategoObserver.java:695)
	at org.strategoxt.imp.runtime.services.StrategoObserver.invokeSilent(StrategoObserver.java:686)
	at org.strategoxt.imp.runtime.services.views.properties.PropertiesService.getProperties(PropertiesService.java:90)
	at org.strategoxt.imp.runtime.editor.StrategoTermSelection.getFirstElement(StrategoTermSelection.java:68)
	at org.strategoxt.imp.runtime.editor.SpoofaxEditor$3.run(SpoofaxEditor.java:109)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)


Internal error evaluating strategy editor-properties
	editor_properties_0_0
	get_all_editor_properties_1_2
	target_prop_1_0
	pp_ast_1_0
	z_112972
	prettyprint_Start_0_0
	pp_one_Z_1_0
	pp_one_1_0
	m_112965
	pp_V_list_1_1
	map_1_0
	pp_one_V_1_0
	pp_one_1_0
	m_112965
	pp_one_Z_1_0
	pp_one_1_0
	m_112965
	pp_one_Z_1_0
	pp_one_1_0
	m_112965
	pp_one_Z_1_0
	pp_one_1_0


java.lang.ArrayIndexOutOfBoundsException: -5
	at org.spoofax.interpreter.core.StackTracer.push(StackTracer.java:39)
	at org.strategoxt.stratego_lib.set_config_0_0.invoke(set_config_0_0.java:21)
	at org.strategoxt.imp.runtime.services.StrategoObserver.configureRuntime(StrategoObserver.java:816)
	at org.strategoxt.imp.runtime.services.StrategoObserver.configureRuntime(StrategoObserver.java:807)
	at org.strategoxt.imp.runtime.services.StrategoObserver.invoke(StrategoObserver.java:614)
	at org.strategoxt.imp.runtime.services.StrategoObserver.invokeSilent(StrategoObserver.java:695)
	at org.strategoxt.imp.runtime.services.StrategoObserver.invokeSilent(StrategoObserver.java:686)
	at org.strategoxt.imp.runtime.services.views.properties.PropertiesService.getProperties(PropertiesService.java:90)
	at org.strategoxt.imp.runtime.editor.StrategoTermSelection.getFirstElement(StrategoTermSelection.java:68)
	at org.strategoxt.imp.runtime.editor.SpoofaxEditor$3.run(SpoofaxEditor.java:109)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)

Internal error evaluating strategy editor-properties
	editor_properties_0_0
	get_all_editor_properties_1_2
	target_prop_1_0
	pp_ast_1_0
	z_112972
	prettyprint_Start_0_0
	pp_one_Z_1_0
	pp_one_1_0
	m_112965
	pp_V_list_1_1
	map_1_0
	pp_one_V_1_0
	pp_one_1_0
	m_112965
	pp_one_Z_1_0
	pp_one_1_0
	m_112965
	pp_one_Z_1_0

java.lang.ArrayIndexOutOfBoundsException: -2
	at org.spoofax.interpreter.core.StackTracer.push(StackTracer.java:39)
	at org.strategoxt.stratego_lib.set_config_0_0.invoke(set_config_0_0.java:21)
	at org.strategoxt.imp.runtime.services.StrategoObserver.configureRuntime(StrategoObserver.java:816)
	at org.strategoxt.imp.runtime.services.StrategoObserver.configureRuntime(StrategoObserver.java:807)
	at org.strategoxt.imp.runtime.services.StrategoObserver.invoke(StrategoObserver.java:614)
	at org.strategoxt.imp.runtime.services.StrategoObserver.invokeSilent(StrategoObserver.java:695)
	at org.strategoxt.imp.runtime.services.StrategoObserver.invokeSilent(StrategoObserver.java:686)
	at org.strategoxt.imp.runtime.services.views.properties.PropertiesService.getProperties(PropertiesService.java:90)
	at org.strategoxt.imp.runtime.editor.StrategoTermSelection.getFirstElement(StrategoTermSelection.java:68)
	at org.strategoxt.imp.runtime.editor.SpoofaxEditor$3.run(SpoofaxEditor.java:109)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)

Internal error evaluating strategy editor-properties
	term_at_position_0_1
	term_at_position_0_1
	position_of_term_1_0
	position_of_term_1_1
	position_of_term_1_0
	position_of_term_1_1

java.lang.ArrayIndexOutOfBoundsException: -1
	at org.spoofax.interpreter.core.StackTracer.push(StackTracer.java:39)
	at org.strategoxt.stratego_lib.set_config_0_0.invoke(set_config_0_0.java:21)
	at org.strategoxt.imp.runtime.services.StrategoObserver.configureRuntime(StrategoObserver.java:816)
	at org.strategoxt.imp.runtime.services.StrategoObserver.configureRuntime(StrategoObserver.java:807)
	at org.strategoxt.imp.runtime.services.StrategoObserver.invoke(StrategoObserver.java:614)
	at org.strategoxt.imp.runtime.services.StrategoObserver.invokeSilent(StrategoObserver.java:695)
	at org.strategoxt.imp.runtime.services.StrategoObserver.invokeSilent(StrategoObserver.java:686)
	at org.strategoxt.imp.runtime.services.views.properties.PropertiesService.getProperties(PropertiesService.java:90)
	at org.strategoxt.imp.runtime.editor.StrategoTermSelection.getFirstElement(StrategoTermSelection.java:68)
	at org.strategoxt.imp.runtime.editor.SpoofaxEditor$3.run(SpoofaxEditor.java:109)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)

On 28 March 2014 at 18:29 Gabriël Konat commented:

Thinking about these stracktraces a little bit more, maybe this is somehow caused by concurrent use of the StrategoObserver, in a way that is not supported? It looks to me like multiple threads are working with the same StrackTracer instances, screwing up the stack and causing the index to go negative.


On 29 March 2014 at 20:47 Gabriël Konat tagged error

On 1 April 2014 at 23:54 Oskar van Rest commented:

I did some debugging and it indeed seems to be a concurrency issue.

The problem occurs when you’re invoking a Strategy like this, but without first obtaining the reentrant lock of the observer:
position_of_term_1_0.instance.invoke(context, ast, testOrigin);
set_config_0_0.instance.invoke(context, programName);

Both the outline and the properties view rely on methods like StrategoTermPath.getTermPathWithOrigin(...) which invoke strategies in this way, hence the errors.

I think what makes most sense is if we obtain the lock right before we invoke a strategy in such a way, and release it right afterwards. In other words, we should update methods like StrategoTermPath.getTermPathWithOrigin(...) and StrategoTextChangeCalculator.getTextReplacement(...). Any objections?

This issue is indeed related to https://yellowgrass.org/issue/Spoofax/757


On 2 April 2014 at 00:08 Gabriël Konat commented:

If it doesn’t cause any deadlock issues, that would be the fix for now. A proper fix would allow concurrent Stratego use, but that requires architectural changes, so that’s for another time.



On 2 April 2014 at 00:55 Oskar van Rest closed this issue.

On 2 April 2014 at 09:34 Gabriël Konat reopened this issue.

On 2 April 2014 at 09:35 Gabriël Konat commented:

This interface change broke SPT, could you apply the changes to SPT’s Java files as well?



On 2 April 2014 at 18:35 Oskar van Rest closed this issue.

On 2 April 2014 at 18:42 Gabriël Konat commented:

Thanks!

Log in to post comments