Skip to content
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

Possible stack overflow when invoking "Expand All" on a domain #3958

Open
pcdavid opened this issue Sep 3, 2024 · 3 comments · May be fixed by #4015
Open

Possible stack overflow when invoking "Expand All" on a domain #3958

pcdavid opened this issue Sep 3, 2024 · 3 comments · May be fixed by #4015

Comments

@pcdavid
Copy link
Member

pcdavid commented Sep 3, 2024

Since the addition of support virtual nodes in the Explorer, and in particular support for EStructuralFeature.Setting, it is possible to create virtually infinite trees.

For example create a Domain definition with two entities A and B; set B as superType of A, and A as superType of B:

image

Then try to invoke "Expand All" on either A or B:

java.util.concurrent.CompletionException: java.lang.StackOverflowError
	at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315) ~[na:na]
	at java.base/java.util.concurrent.CompletableFuture.uniComposeStage(CompletableFuture.java:1194) ~[na:na]
	at java.base/java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:2309) ~[na:na]
	at graphql.GraphQL.parseValidateAndExecute(GraphQL.java:471) ~[graphql-java-22.0.jar:na]
	at graphql.GraphQL.lambda$executeAsync$9(GraphQL.java:429) ~[graphql-java-22.0.jar:na]
	at java.base/java.util.concurrent.CompletableFuture.uniComposeStage(CompletableFuture.java:1187) ~[na:na]
	at java.base/java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:2309) ~[na:na]
	at graphql.GraphQL.executeAsync(GraphQL.java:418) ~[graphql-java-22.0.jar:na]
	at graphql.GraphQL.execute(GraphQL.java:359) ~[graphql-java-22.0.jar:na]
	at org.eclipse.sirius.components.graphql.ws.handlers.StartMessageHandler.handle(StartMessageHandler.java:94) ~[classes/:na]
    [...]
Caused by: java.lang.StackOverflowError: null
	at java.base/java.util.HashMap.putVal(HashMap.java:627) ~[na:na]
	at java.base/java.util.HashMap.putMapEntries(HashMap.java:514) ~[na:na]
	at java.base/java.util.HashMap.<init>(HashMap.java:484) ~[na:na]
	at org.eclipse.sirius.components.representations.VariableManager.getVariables(VariableManager.java:66) ~[classes/:na]
	at org.eclipse.sirius.components.representations.VariableManager.getVariables(VariableManager.java:62) ~[classes/:na]
	at org.eclipse.sirius.components.representations.VariableManager.getVariables(VariableManager.java:62) ~[classes/:na]
@pcdavid
Copy link
Member Author

pcdavid commented Sep 3, 2024

Actually, "Expand All" is not even needed:

Capture.video.du.2024-09-03.19-00-42.mp4

@adaussy
Copy link
Contributor

adaussy commented Sep 17, 2024

I reproduce this problem using UML workflow.

I would try to contribute a fix for this composed of two features:

First add an "ancestorIds" in the variable manager that keeps tracks of all parent ids of the current rendering TreeItem. This variable could be used to generate truly unique id for TreeItem. That would give the opportunity for the specifier to create such loop.

Add a security in Sirius Web that prevents the creating of a child if its id is contained in the "ancestorId" list. To make the user aware of the problem I would suggest to return a "Virtual" Tree item that show the possible infinite loop.

This item will have the same icon than the TreeItem causing the problem plus a warning sign. A prefix will be added to the label to identify the problem.

image

Do you think that could do the trick?

This contribution do not fix the "Expand All" action only the stackoverflow during the render phase.

@adaussy
Copy link
Contributor

adaussy commented Sep 18, 2024

In domain it would give

image

adaussy added a commit to adaussy/sirius-components that referenced this issue Sep 18, 2024
This commit provide a partial fix for the given bug. It only prevents
rendering twice in the same tree path and expanded element because it
would cause an infinite loop.

A fix still need to be implemented in the "Expand All" action to prevent
stackoverfow when rendering a infinite loop with non unique ID.

Bug: eclipse-sirius#3958
Signed-off-by: Arthur Daussy <arthur.daussy@obeo.fr>
@sbegaudeau sbegaudeau added this to the 2024.11.0 milestone Sep 18, 2024
adaussy added a commit to adaussy/sirius-components that referenced this issue Sep 20, 2024
This commit provide a partial fix for the given bug. It only prevents
rendering twice in the same tree path and expanded element because it
would cause an infinite loop.

A fix still need to be implemented in the "Expand All" action to prevent
stackoverfow when rendering a infinite loop with non unique ID.

Bug: eclipse-sirius#3958
Signed-off-by: Arthur Daussy <arthur.daussy@obeo.fr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants