Regression in struct implementation causing stack overflow
Description
Environment
Activity

John Berquist 5 December 2019 at 16:20
@Michael Offner: @Brad Wood actually pointed LDEV-2479
out to me on Slack, I am really sorry I missed that earlier ticket - it did in fact solve my issue. I didn’t realize it because it hasn’t made it into a stable release yet. I created the test case above trying to figure out exactly what was causing my issue and apparently bumped into something else. I do appreciate the quick fix.

Michael Offner 5 December 2019 at 14:07
see

Michael Offner 5 December 2019 at 14:04Edited
@John Berquist does this fix solves your problem? i was able to reproduce and solve the issue with equals and the issue with hashcode was already solved in an earlier version.

John Berquist 3 December 2019 at 18:35
@Michael Offner I have a component that computes function names and ranges for CFML source files: (So that for exceptions that report a tag context array I can get the names of the CFML functions being executed from the source files and line numbers given). In order to do that I build a tree of parent and child structs tracking ranges in the source file - where the child structs have a reference their parent structs and the parents have arrays of child structs. At a particular point I needed the index of a child struct in its parent struct's array of child ranges. So I used var idx = func.parent.children.find( func );
That stopped working after the recent struct implementation updates.

Michael Offner 2 December 2019 at 21:36
Details
Details
Assignee

Reporter

Priority
New Issue warning screen
Before you create a new Issue, please post to the mailing list first https://dev.lucee.org
Once the issue has been verified, one of the Lucee team will ask you to file an issue
In Lucee version 5.3.3.54 and following, the struct implementation was changed resulting in the following code causing a stack overflow:
struct1 = {}; struct2 = {}; struct1.struct2 = struct2; struct2.struct1 = struct1; struct1.equals(struct1);
This code causes a stack overflow at:
at java.util.AbstractMap$SimpleEntry.hashCode(AbstractMap.java:712) at java.util.AbstractMap.hashCode(AbstractMap.java:530)
While it is understandable why this causes the overflow at the `hashCode()` method, it did not in prior versions of Lucee and does not in ACF 2018.
For reference this code more closely approximates how I encountered it:
struct1 = {children: [{}]} struct2 = { parent: struct1 }; struct1.children.append(struct2); childIndex = struct2.parent.children.find(struct2);