[jira] [Updated] (GROOVY-11391) GroovyClassLoader hangs on parsing certain types of scripts

2024-06-20 Thread Eric Milles (Jira)


 [ 
https://issues.apache.org/jira/browse/GROOVY-11391?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Eric Milles updated GROOVY-11391:
-
Language: groovy

> GroovyClassLoader hangs on parsing certain types of scripts
> ---
>
> Key: GROOVY-11391
> URL: https://issues.apache.org/jira/browse/GROOVY-11391
> Project: Groovy
>  Issue Type: Bug
>  Components: ast builder, class generator, Compiler, parser, 
> parser-antlr4
>Affects Versions: 3.0.19, 3.0.21, 4.0.21
>Reporter: Fridman Viktor
>Priority: Major
> Attachments: image-2024-05-30-13-32-34-933.png
>
>
> i have a simple sample of code:
> {code:java}
> String script = "import com.atlassian.jira.component.ComponentAccessor\n" +
> "\n" +
> "Set asdf1 = [\n" +
> "\"abc\"\n" +
> "] as Set\n" +
> "\n" +
> "Set asdf2 = [\n" +
> "\"def\"\n" +
> "] as Set\n" +
> "\n" +
> "Set asdf3 = [\n" +
> "\"qwer\",\n" +
> "\"wert\"\n" +
> "] as Set\n" +
> "\n" +
> "Set asdf4 = [\n" +
> "\"qwerty\"\n" +
> "] as Set\n" +
> "\n" +
> "Set asdf5 = [\n" +
> "\"asdvlkjn\",\n" +
> "\"asdlvkasdlkvm\",\n" +
> "\"asdviamsdov\",\n" +
> "\"zxcv\",\n" +
> "\"vcxz\",\n" +
> "\"xcvb\",\n" +
> "\"bvcx\"\n" +
> "] as Set\n" +
> "\n" +
> "Set asdf6 = [ // qwer ty \"asdf\"\n" +
> "\"dfbjknsldfkb \",\n" +
> "\"bvcxcx\",\n" +
> "\"xcvbbv\",\n" +
> "\"bvcx\",\n" +
> "\"xcvb\"\n" +
> "] as Set\n" +
> "\n" +
> "Set asdf7 = [ //aqwerty\n" +
> "\"asdfghj\",\n" +
> "\"jhgfdsa\",\n" +
> "\"asdfg\",\n" +
> "\"gfdsa\"\n" +
> "] as Set\n" +
> "\n" +
> "Set asdf8 = [ //qwerrty\n" +
> "\"zxcv\",\n" +
> "\"vcxz\",\n" +
> "\"xcvbbnm,.\"\n" +
> "] as Set";
> GroovyClassLoader gcl = new GroovyClassLoader();
> GroovyCodeSource codeSource = new GroovyCodeSource(script, "Script", 
> "/groovy/script");
> long l = System.currentTimeMillis();
> try {
> Class aClass = gcl.parseClass(codeSource);
> System.out.println(aClass);
> }
> catch (Exception e) {
> long l1 = System.currentTimeMillis();
> System.out.println(l1 - l);
> }{code}
> code parsing hangs for a long time.
> but if i add ';' after every string like
> {code:java}
> ] as Set{code}
> so it will look like
> {code:java}
> ] as Set;{code}
> in groovy-script, it works fast.
>  
> the problem seems somewhere deep in ParserATNSimulator, its configurations or 
> predictive parsing at all (seems quite greedy) - randomly stopped debugger 
> shows that while it hangs:
>  
> !image-2024-05-30-13-32-34-933.png|width=423,height=1356!
> i understand that the code of script could have errors (for example, import 
> could not be found or smthng else), but i think that the parser hanging is 
> quite abnormal
>  
> in pom tried both (separately ofc):
> implementation 'org.apache.groovy:groovy-all:4.0.21'
> implementation 'org.codehaus.groovy:groovy-all:3.0.21'



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Updated] (GROOVY-11391) GroovyClassLoader hangs on parsing certain types of scripts

2024-05-30 Thread Fridman Viktor (Jira)


 [ 
https://issues.apache.org/jira/browse/GROOVY-11391?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Fridman Viktor updated GROOVY-11391:

  Component/s: ast builder
   class generator
   Compiler
   parser
   parser-antlr4
Affects Version/s: 4.0.21
   3.0.21
   3.0.19

> GroovyClassLoader hangs on parsing certain types of scripts
> ---
>
> Key: GROOVY-11391
> URL: https://issues.apache.org/jira/browse/GROOVY-11391
> Project: Groovy
>  Issue Type: Bug
>  Components: ast builder, class generator, Compiler, parser, 
> parser-antlr4
>Affects Versions: 3.0.19, 3.0.21, 4.0.21
>Reporter: Fridman Viktor
>Priority: Major
> Attachments: image-2024-05-30-13-32-34-933.png
>
>
> i have a simple sample of code:
> {code:java}
> String script = "import com.atlassian.jira.component.ComponentAccessor\n" +
> "\n" +
> "Set asdf1 = [\n" +
> "\"abc\"\n" +
> "] as Set\n" +
> "\n" +
> "Set asdf2 = [\n" +
> "\"def\"\n" +
> "] as Set\n" +
> "\n" +
> "Set asdf3 = [\n" +
> "\"qwer\",\n" +
> "\"wert\"\n" +
> "] as Set\n" +
> "\n" +
> "Set asdf4 = [\n" +
> "\"qwerty\"\n" +
> "] as Set\n" +
> "\n" +
> "Set asdf5 = [\n" +
> "\"asdvlkjn\",\n" +
> "\"asdlvkasdlkvm\",\n" +
> "\"asdviamsdov\",\n" +
> "\"zxcv\",\n" +
> "\"vcxz\",\n" +
> "\"xcvb\",\n" +
> "\"bvcx\"\n" +
> "] as Set\n" +
> "\n" +
> "Set asdf6 = [ // qwer ty \"asdf\"\n" +
> "\"dfbjknsldfkb \",\n" +
> "\"bvcxcx\",\n" +
> "\"xcvbbv\",\n" +
> "\"bvcx\",\n" +
> "\"xcvb\"\n" +
> "] as Set\n" +
> "\n" +
> "Set asdf7 = [ //aqwerty\n" +
> "\"asdfghj\",\n" +
> "\"jhgfdsa\",\n" +
> "\"asdfg\",\n" +
> "\"gfdsa\"\n" +
> "] as Set\n" +
> "\n" +
> "Set asdf8 = [ //qwerrty\n" +
> "\"zxcv\",\n" +
> "\"vcxz\",\n" +
> "\"xcvbbnm,.\"\n" +
> "] as Set";
> GroovyClassLoader gcl = new GroovyClassLoader();
> GroovyCodeSource codeSource = new GroovyCodeSource(script, "Script", 
> "/groovy/script");
> long l = System.currentTimeMillis();
> try {
> Class aClass = gcl.parseClass(codeSource);
> System.out.println(aClass);
> }
> catch (Exception e) {
> long l1 = System.currentTimeMillis();
> System.out.println(l1 - l);
> }{code}
> code parsing hangs for a long time.
> but if i add ';' after every string like
> {code:java}
> ] as Set{code}
> so it will look like
> {code:java}
> ] as Set;{code}
> in groovy-script, it works fast.
>  
> the problem seems somewhere deep in ParserATNSimulator, its configurations or 
> predictive parsing at all (seems quite greedy) - randomly stopped debugger 
> shows that while it hangs:
>  
> !image-2024-05-30-13-32-34-933.png|width=423,height=1356!
> i understand that the code of script could have errors (for example, import 
> could not be found or smthng else), but i think that the parser hanging is 
> quite abnormal
>  
> in pom tried both (separately ofc):
> implementation 'org.apache.groovy:groovy-all:4.0.21'
> implementation 'org.codehaus.groovy:groovy-all:3.0.21'



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Updated] (GROOVY-11391) GroovyClassLoader hangs on parsing certain types of scripts

2024-05-30 Thread Fridman Viktor (Jira)


 [ 
https://issues.apache.org/jira/browse/GROOVY-11391?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Fridman Viktor updated GROOVY-11391:

Description: 
i have a simple sample of code:
{code:java}
String script = "import com.atlassian.jira.component.ComponentAccessor\n" +
"\n" +
"Set asdf1 = [\n" +
"\"abc\"\n" +
"] as Set\n" +
"\n" +
"Set asdf2 = [\n" +
"\"def\"\n" +
"] as Set\n" +
"\n" +
"Set asdf3 = [\n" +
"\"qwer\",\n" +
"\"wert\"\n" +
"] as Set\n" +
"\n" +
"Set asdf4 = [\n" +
"\"qwerty\"\n" +
"] as Set\n" +
"\n" +
"Set asdf5 = [\n" +
"\"asdvlkjn\",\n" +
"\"asdlvkasdlkvm\",\n" +
"\"asdviamsdov\",\n" +
"\"zxcv\",\n" +
"\"vcxz\",\n" +
"\"xcvb\",\n" +
"\"bvcx\"\n" +
"] as Set\n" +
"\n" +
"Set asdf6 = [ // qwer ty \"asdf\"\n" +
"\"dfbjknsldfkb \",\n" +
"\"bvcxcx\",\n" +
"\"xcvbbv\",\n" +
"\"bvcx\",\n" +
"\"xcvb\"\n" +
"] as Set\n" +
"\n" +
"Set asdf7 = [ //aqwerty\n" +
"\"asdfghj\",\n" +
"\"jhgfdsa\",\n" +
"\"asdfg\",\n" +
"\"gfdsa\"\n" +
"] as Set\n" +
"\n" +
"Set asdf8 = [ //qwerrty\n" +
"\"zxcv\",\n" +
"\"vcxz\",\n" +
"\"xcvbbnm,.\"\n" +
"] as Set";


GroovyClassLoader gcl = new GroovyClassLoader();
GroovyCodeSource codeSource = new GroovyCodeSource(script, "Script", 
"/groovy/script");


long l = System.currentTimeMillis();
try {
Class aClass = gcl.parseClass(codeSource);
System.out.println(aClass);
}
catch (Exception e) {
long l1 = System.currentTimeMillis();
System.out.println(l1 - l);
}{code}
code parsing hangs for a long time.

but if i add ';' after every string like
{code:java}
] as Set{code}
so it will look like
{code:java}
] as Set;{code}
in groovy-script, it works fast.

 

the problem seems somewhere deep in ParserATNSimulator, its configurations or 
predictive parsing at all (seems quite greedy) - randomly stopped debugger 
shows that while it hangs:

 

!image-2024-05-30-13-32-34-933.png|width=423,height=1356!

i understand that the code of script could have errors (for example, import 
could not be found or smthng else), but i think that the parser hanging is 
quite abnormal

 

in pom tried both (separately ofc):
implementation 'org.apache.groovy:groovy-all:4.0.21'

implementation 'org.codehaus.groovy:groovy-all:3.0.21'

  was:
i have a simple sample of code:
{code:java}
String script = "import com.atlassian.jira.component.ComponentAccessor\n" +
"\n" +
"Set asdf1 = [\n" +
"\"abc\"\n" +
"] as Set\n" +
"\n" +
"Set asdf2 = [\n" +
"\"def\"\n" +
"] as Set\n" +
"\n" +
"Set asdf3 = [\n" +
"\"qwer\",\n" +
"\"wert\"\n" +
"] as Set\n" +
"\n" +
"Set asdf4 = [\n" +
"\"qwerty\"\n" +
"] as Set\n" +
"\n" +
"Set asdf5 = [\n" +
"\"asdvlkjn\",\n" +
"\"asdlvkasdlkvm\",\n" +
"\"asdviamsdov\",\n" +
"\"zxcv\",\n" +
"\"vcxz\",\n" +
"\"xcvb\",\n" +
"\"bvcx\"\n" +
"] as Set\n" +
"\n" +
"Set asdf6 = [ // qwer ty \"asdf\"\n" +
"\"dfbjknsldfkb \",\n" +
"\"bvcxcx\",\n" +
"\"xcvbbv\",\n" +
"\"bvcx\",\n" +
"\"xcvb\"\n" +
"] as Set\n" +
"\n" +
"Set asdf7 = [ //aqwerty\n" +
"\"asdfghj\",\n" +
"\"jhgfdsa\",\n" +
"\"asdfg\",\n" +
"\"gfdsa\"\n" +
"] as Set\n" +
"\n" +
"Set asdf8 = [ //qwerrty\n" +
"\"zxcv\",\n" +
"\"vcxz\",\n" +
"\"xcvbbnm,.\"\n" +
"] as Set";


GroovyClassLoader gcl = new GroovyClassLoader();
GroovyCodeSource codeSource = new GroovyCodeSource(script, "Script", 
"/groovy/script");


long l = System.currentTimeMillis();
try {
Class aClass = gcl.parseClass(codeSource);
System.out.println(aClass);
}
catch (Exception e) {
long l1 = System.currentTimeMillis();
System.out.println(l1 - l);
}{code}
code parsing hangs for a long time.

but if i add ';' after every string like
{code:java}
] as Set{code}
so it will look like
{code:java}
] as Set;{code}
in groovy-script, it works fast.

 

the problem seems somewhere deep in ParserATNSimulator, its configurations or 
predictive parsing at all (seems quite greedy) - randomly stopped debugger 
shows that while it hangs:

 

!image-2024-05-30-13-32-34-933.png|width=423,height=1356!

i understand that the code of script could have errors (for example, import 
could not be found or smthng else), but i think that the parser hanging is 
quite abnormal


> GroovyClassLoader hangs on parsing certain types of s

[jira] [Updated] (GROOVY-11391) GroovyClassLoader hangs on parsing certain types of scripts

2024-05-30 Thread Fridman Viktor (Jira)


 [ 
https://issues.apache.org/jira/browse/GROOVY-11391?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Fridman Viktor updated GROOVY-11391:

Description: 
i have a simple sample of code:
{code:java}
String script = "import com.atlassian.jira.component.ComponentAccessor\n" +
"\n" +
"Set asdf1 = [\n" +
"\"abc\"\n" +
"] as Set\n" +
"\n" +
"Set asdf2 = [\n" +
"\"def\"\n" +
"] as Set\n" +
"\n" +
"Set asdf3 = [\n" +
"\"qwer\",\n" +
"\"wert\"\n" +
"] as Set\n" +
"\n" +
"Set asdf4 = [\n" +
"\"qwerty\"\n" +
"] as Set\n" +
"\n" +
"Set asdf5 = [\n" +
"\"asdvlkjn\",\n" +
"\"asdlvkasdlkvm\",\n" +
"\"asdviamsdov\",\n" +
"\"zxcv\",\n" +
"\"vcxz\",\n" +
"\"xcvb\",\n" +
"\"bvcx\"\n" +
"] as Set\n" +
"\n" +
"Set asdf6 = [ // qwer ty \"asdf\"\n" +
"\"dfbjknsldfkb \",\n" +
"\"bvcxcx\",\n" +
"\"xcvbbv\",\n" +
"\"bvcx\",\n" +
"\"xcvb\"\n" +
"] as Set\n" +
"\n" +
"Set asdf7 = [ //aqwerty\n" +
"\"asdfghj\",\n" +
"\"jhgfdsa\",\n" +
"\"asdfg\",\n" +
"\"gfdsa\"\n" +
"] as Set\n" +
"\n" +
"Set asdf8 = [ //qwerrty\n" +
"\"zxcv\",\n" +
"\"vcxz\",\n" +
"\"xcvbbnm,.\"\n" +
"] as Set";


GroovyClassLoader gcl = new GroovyClassLoader();
GroovyCodeSource codeSource = new GroovyCodeSource(script, "Script", 
"/groovy/script");


long l = System.currentTimeMillis();
try {
Class aClass = gcl.parseClass(codeSource);
System.out.println(aClass);
}
catch (Exception e) {
long l1 = System.currentTimeMillis();
System.out.println(l1 - l);
}{code}
code parsing hangs for a long time.

but if i add ';' after every string like
{code:java}
] as Set{code}
so it will look like
{code:java}
] as Set;{code}
in groovy-script, it works fast.

 

the problem seems somewhere deep in ParserATNSimulator, its configurations or 
predictive parsing at all (seems quite greedy) - randomly stopped debugger 
shows that while it hangs:

 

!image-2024-05-30-13-32-34-933.png|width=423,height=1356!

i understand that the code of script could have errors (for example, import 
could not be found or smthng else), but i think that the parser hanging is 
quite abnormal

  was:
i have a simple sample of code:
{code:java}
String script = "import com.atlassian.jira.component.ComponentAccessor\n" +
"\n" +
"Set asdf1 = [\n" +
"\"abc\"\n" +
"] as Set\n" +
"\n" +
"Set asdf2 = [\n" +
"\"def\"\n" +
"] as Set\n" +
"\n" +
"Set asdf3 = [\n" +
"\"qwer\",\n" +
"\"wert\"\n" +
"] as Set\n" +
"\n" +
"Set asdf4 = [\n" +
"\"qwerty\"\n" +
"] as Set\n" +
"\n" +
"Set asdf5 = [\n" +
"\"asdvlkjn\",\n" +
"\"asdlvkasdlkvm\",\n" +
"\"asdviamsdov\",\n" +
"\"zxcv\",\n" +
"\"vcxz\",\n" +
"\"xcvb\",\n" +
"\"bvcx\"\n" +
"] as Set\n" +
"\n" +
"Set asdf6 = [ // qwer ty \"asdf\"\n" +
"\"dfbjknsldfkb \",\n" +
"\"bvcxcx\",\n" +
"\"xcvbbv\",\n" +
"\"bvcx\",\n" +
"\"xcvb\"\n" +
"] as Set\n" +
"\n" +
"Set asdf7 = [ //aqwerty\n" +
"\"asdfghj\",\n" +
"\"jhgfdsa\",\n" +
"\"asdfg\",\n" +
"\"gfdsa\"\n" +
"] as Set\n" +
"\n" +
"Set asdf8 = [ //qwerrty\n" +
"\"zxcv\",\n" +
"\"vcxz\",\n" +
"\"xcvbbnm,.\"\n" +
"] as Set";


GroovyClassLoader gcl = new GroovyClassLoader();
GroovyCodeSource codeSource = new GroovyCodeSource(script, "Script", 
"/groovy/script");


long l = System.currentTimeMillis();
try {
Class aClass = gcl.parseClass(codeSource);
System.out.println(aClass);
}
catch (Exception e) {
long l1 = System.currentTimeMillis();
System.out.println(l1 - l);
}{code}
code parsing hangs for a long time.

but if i add ';' after every string like
{code:java}
] as Set{code}
so it will look like
{code:java}
] as Set;{code}
in groovy-script, it works fast.

 

the problem seems somewhere deep in ParserATNSimulator, its configurations or 
predictive parsing at all (seems quite greedy) - randomly stopped debugger 
shows that while it hangs:

 

!image-2024-05-30-13-32-34-933.png|width=423,height=1356!

 


> GroovyClassLoader hangs on parsing certain types of scripts
> ---
>
> Key: GROOVY-11391
> URL: https://issues.apache.org/jira/browse/GROOVY-11391
> Project: Groovy
>  Issue Type: Bug
>Reporter: Fridman Viktor
>Priority: Major
>