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

problem with string concatenation with parboiled java 1.4.1 #203

Open
plamaiziere opened this issue Jun 8, 2022 · 2 comments
Open

problem with string concatenation with parboiled java 1.4.1 #203

plamaiziere opened this issue Jun 8, 2022 · 2 comments

Comments

@plamaiziere
Copy link

Hello,

I use parboiled since a long time to parse some routers configuration files. I've got a lot of test cases to test the parsers results.
With version 1.4.1 few test cases fail when, in the parser rules, i use string concatenation wih the '+' operator.
If I replace the '+' operator with the String.concat method this works fine.

Exemple:

public Rule AceTcpOldFlag() {
return
	Sequence(
		FirstOf(
			String("ack"),
			String("fin"),
			String("psh"),
			String("rst"),
			String("syn"),
			String("urg")
		),
		_ace.getTcpFlags().add("+" + match()), // ace.getTcpflags is a String list
		_ace.setTcpKeyword("match-any"),
		SkipSpaces()
	);
}

In a test case for this rule like "ack rst psh fin syn urg", flags are set with the match() value, (ie ack, fin, psh etc), but without the "+" at the start as if the string + operator does nothing.
If I replace the + operator with String.concat it works fine : _ace.getTcpFlags().add("+".concat(match()))

I tried with jdk11, jdk16 with the same problem. Also tried to use asm 9.3 instead asm 9.2.
All works fine if I specify 8 in the maven compiler plugin.

I think there is something wrong with the String + operator and ASM but I cannot reproduce this problem with a simple test parser
Any clue?

Thanks regards,

@sirthias
Copy link
Owner

Thank you, @plamaiziere, for this bug report.
It'd be helpful if you could distill a minimal, stand-alone test case that demonstrates a problem in a reproducible form.
But even then I'm afraid that there is currently no one with the capacity to look into the codebase and identify + fix the problem. parboiled is now 12 years old and hasn't really been maintained for at least 8 years.
It's old and nobody really knows plus understands its internals anymore...

@plamaiziere
Copy link
Author

@sirthias hello
I tried to reproduce the problem with a simple parser but it works fine and i can't reproduce it. It's hard to tell why.
I understand well that Partboiled is unmaintened, that's already nice to have a new version for jdk > 8
My issue was mostly for the record if someone else is seeing this pb.
Regards,

plamaiziere pushed a commit to plamaiziere/lsfw that referenced this issue Jan 24, 2023
dhalperi added a commit to batfish/batfish that referenced this issue Jul 8, 2024
See: sirthias/parboiled#203

For some reason, when upgrading beyond Java 8 something about String concatenation optimizations
breaks Parboiled. This is a workaround to let us keep moving forward despite using this unmaintained
library.

commit-id:4b660bb9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants