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

Heap overflow when parsing regex #70

Open
freedom1b2830 opened this issue Mar 4, 2023 · 2 comments
Open

Heap overflow when parsing regex #70

freedom1b2830 opened this issue Mar 4, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@freedom1b2830
Copy link

Describe the bug
Heap overflow when parsing regex

To Reproduce
Steps to reproduce the behavior:

  1. With regex pattern :
    hex:28dba5292a303a2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2f2aef0100002bfd2e
    raw:(ۥ)*0:+++++++++++++++++++/*��
    byte[] : [40, -37, -91, 41, 42, 48, 58, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 47, 42, -17, 1, 0, 0, 43, -3, 46]
  2. Use code/API
RgxGen rgxGen = new RgxGen(new String(bytes));
String s = rgxGen.generate();
  1. See error
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
	at java.util.Arrays.copyOf(Arrays.java:3332)
	at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:124)
	at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:448)
	at java.lang.StringBuilder.append(StringBuilder.java:141)
	at com.github.curiousoddman.rgxgen.visitors.GenerationVisitor.visit(GenerationVisitor.java:59)
	at com.github.curiousoddman.rgxgen.nodes.FinalSymbol.visit(FinalSymbol.java:31)
	at com.github.curiousoddman.rgxgen.visitors.GenerationVisitor.visit(GenerationVisitor.java:71)
	at com.github.curiousoddman.rgxgen.nodes.Repeat.visit(Repeat.java:43)
	at com.github.curiousoddman.rgxgen.visitors.GenerationVisitor.visit(GenerationVisitor.java:71)
	at com.github.curiousoddman.rgxgen.nodes.Repeat.visit(Repeat.java:43)
	at com.github.curiousoddman.rgxgen.visitors.GenerationVisitor.visit(GenerationVisitor.java:71)
	at com.github.curiousoddman.rgxgen.nodes.Repeat.visit(Repeat.java:43)
	at com.github.curiousoddman.rgxgen.visitors.GenerationVisitor.visit(GenerationVisitor.java:71)
	at com.github.curiousoddman.rgxgen.nodes.Repeat.visit(Repeat.java:43)
	at com.github.curiousoddman.rgxgen.visitors.GenerationVisitor.visit(GenerationVisitor.java:71)
	at com.github.curiousoddman.rgxgen.nodes.Repeat.visit(Repeat.java:43)
	at com.github.curiousoddman.rgxgen.visitors.GenerationVisitor.visit(GenerationVisitor.java:71)
	at com.github.curiousoddman.rgxgen.nodes.Repeat.visit(Repeat.java:43)
	at com.github.curiousoddman.rgxgen.visitors.GenerationVisitor.visit(GenerationVisitor.java:71)
	at com.github.curiousoddman.rgxgen.nodes.Repeat.visit(Repeat.java:43)
	at com.github.curiousoddman.rgxgen.visitors.GenerationVisitor.visit(GenerationVisitor.java:71)
	at com.github.curiousoddman.rgxgen.nodes.Repeat.visit(Repeat.java:43)
	at com.github.curiousoddman.rgxgen.visitors.GenerationVisitor.visit(GenerationVisitor.java:71)
	at com.github.curiousoddman.rgxgen.nodes.Repeat.visit(Repeat.java:43)
	at com.github.curiousoddman.rgxgen.visitors.GenerationVisitor.visit(GenerationVisitor.java:71)
	at com.github.curiousoddman.rgxgen.nodes.Repeat.visit(Repeat.java:43)
	at com.github.curiousoddman.rgxgen.visitors.GenerationVisitor.visit(GenerationVisitor.java:71)
	at com.github.curiousoddman.rgxgen.nodes.Repeat.visit(Repeat.java:43)
	at com.github.curiousoddman.rgxgen.visitors.GenerationVisitor.visit(GenerationVisitor.java:71)
	at com.github.curiousoddman.rgxgen.nodes.Repeat.visit(Repeat.java:43)
	at com.github.curiousoddman.rgxgen.visitors.GenerationVisitor.visit(GenerationVisitor.java:71)
	at com.github.curiousoddman.rgxgen.nodes.Repeat.visit(Repeat.java:43)

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • OS: Linux 6.2.1-arch1-1
  • JDK/JRE version 1.8
  • RgxGen Version :1.4

Additional context
Provided to improve code quality,
The bug was found during the test, not in the production application

@freedom1b2830 freedom1b2830 added the bug Something isn't working label Mar 4, 2023
@curious-odd-man
Copy link
Owner

curious-odd-man commented Mar 4, 2023

Hello! May I ask you what are you trying to generate?
I am especially interested in +++++++++++++++++++ ?
Why would you need that?

Or is that an example of incorrect regex pattern?

@freedom1b2830
Copy link
Author

This is an example of a wrong regex.

@curious-odd-man curious-odd-man added this to the Version 1.5 milestone Mar 5, 2023
@curious-odd-man curious-odd-man removed this from the Version 1.5 milestone Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants