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

[Truffle] Regex compile error in rexml #2853

Closed
bjfish opened this issue Apr 19, 2015 · 9 comments
Closed

[Truffle] Regex compile error in rexml #2853

bjfish opened this issue Apr 19, 2015 · 9 comments
Assignees

Comments

@bjfish
Copy link
Contributor

bjfish commented Apr 19, 2015

Example

NCNAME_STR = '[A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}][A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}\-\.0-9\u00B7\u0300-\u036F\u203F-\u2040]*'
NAMESPLIT = /^(?:(#{NCNAME_STR}):)?(#{NCNAME_STR})/u
puts "Done"

Expected (ruby, jruby)

Done

Actual

rexml.rb:2:in `<main>': error compiling regex (RuntimeError)
@chrisseaton chrisseaton added this to the truffle-dev milestone Apr 19, 2015
@chrisseaton
Copy link
Contributor

Smaller test case is just:

/[\u{10000}-\u{EFFFF}]/u

@nirvdrum
Copy link
Contributor

I think this is ultimately the same problem as #2802. We need to take a pass on the encoding stuff in our Regexp implementation.

@bjfish bjfish closed this as completed Apr 27, 2015
@bjfish
Copy link
Contributor Author

bjfish commented Apr 27, 2015

Closed the wrong regex issue

@bjfish bjfish reopened this Apr 27, 2015
@chrisseaton
Copy link
Contributor

@bjfish is this blocking something you are working on? I don't think we'll solve this very soon unless it's critical for something and can't be worked around.

@bjfish
Copy link
Contributor Author

bjfish commented May 10, 2015

@chrisseaton I am not actively working on this. This is just to track this issue which is blocking adding the REXML std lib.

@eregon
Copy link
Member

eregon commented May 11, 2015

What uses REXML these days?

@bjfish
Copy link
Contributor Author

bjfish commented Jun 3, 2015

@nirvdrum This compiles now with the your recent updates. There's an issue using the compiled regex now:
Example

NCNAME_STR = '[A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}][A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}\-\.0-9\u00B7\u0300-\u036F\u203F-\u2040]*'
NAMESPLIT = /^(?:(#{NCNAME_STR}):)?(#{NCNAME_STR})/u
puts ("root" =~ NAMESPLIT).to_s
puts "Done"

Expected:

$ ruby rexissue.rb 
0
Done

Actual

$ ~/Documents/jruby/bin/jruby -X+T rexissue.rb 
rexissue.rb:3:in `=~': internal implementation error - ValueException empty range in char class org.joni.ast.CClassNode.nextStateValue(CClassNode.java:486) (RubyTruffleError)
    from rexissue.rb:3:in `<main>'
Brandons-MacBook-Pro:jruby-patches brandonfish$ ~/Documents/jruby/bin/jruby -X+T -Xtruffle.exceptions.print_java=true rexissue.rb 
org.joni.exception.ValueException: empty range in char class
    at org.joni.ast.CClassNode.nextStateValue(CClassNode.java:486)
    at org.joni.Parser.parseCharClassValEntry2(Parser.java:405)
    at org.joni.Parser.parseCharClass(Parser.java:199)
    at org.joni.Parser.parseExp(Parser.java:854)
    at org.joni.Parser.parseBranch(Parser.java:1069)
    at org.joni.Parser.parseSubExp(Parser.java:1095)
    at org.joni.Parser.parseEnclose(Parser.java:635)
    at org.joni.Parser.parseExp(Parser.java:716)
    at org.joni.Parser.parseBranch(Parser.java:1069)
    at org.joni.Parser.parseSubExp(Parser.java:1095)
    at org.joni.Parser.parseEnclose(Parser.java:425)
    at org.joni.Parser.parseExp(Parser.java:716)
    at org.joni.Parser.parseBranch(Parser.java:1078)
    at org.joni.Parser.parseSubExp(Parser.java:1095)
    at org.joni.Parser.parseRegexp(Parser.java:1128)
    at org.joni.Parser.parse(Parser.java:65)
    at org.joni.Analyser.compile(Analyser.java:80)
    at org.joni.Regex.<init>(Regex.java:159)
    at org.joni.Regex.<init>(Regex.java:136)
    at org.joni.Regex.<init>(Regex.java:122)
    at org.jruby.truffle.runtime.core.RubyRegexp.matchCommon(RubyRegexp.java:116)
    at org.jruby.truffle.runtime.core.RubyRegexp.matchCommon(RubyRegexp.java:108)
    at org.jruby.truffle.nodes.core.StringNodes$MatchOperatorNode.match(StringNodes.java:752)
    at org.jruby.truffle.nodes.core.StringNodesFactory$MatchOperatorNodeFactory$MatchOperatorNodeGen.execute(StringNodesFactory.java:2108)
    at org.jruby.truffle.nodes.control.SequenceNode.execute(SequenceNode.java:93)
    at org.jruby.truffle.nodes.methods.ExceptionTranslatingNode.execute(ExceptionTranslatingNode.java:59)
    at org.jruby.truffle.nodes.RubyRootNode.execute(RubyRootNode.java:57)
    at com.oracle.truffle.api.impl.DefaultCallTarget.call(DefaultCallTarget.java:76)
    at com.oracle.truffle.api.impl.DefaultDirectCallNode.call(DefaultDirectCallNode.java:65)
    at org.jruby.truffle.nodes.dispatch.CachedBoxedDispatchNode.executeDispatch(CachedBoxedDispatchNode.java:115)
    at org.jruby.truffle.nodes.dispatch.UnresolvedDispatchNode.executeDispatch(UnresolvedDispatchNode.java:108)
    at org.jruby.truffle.nodes.dispatch.DispatchHeadNode.dispatch(DispatchHeadNode.java:46)
    at org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode.call(CallDispatchHeadNode.java:34)
    at org.jruby.truffle.nodes.dispatch.RubyCallNode.execute(RubyCallNode.java:148)
    at org.jruby.truffle.nodes.dispatch.RubyCallNode.execute(RubyCallNode.java:110)
    at org.jruby.truffle.nodes.dispatch.RubyCallNode.executeArguments(RubyCallNode.java:164)
    at org.jruby.truffle.nodes.dispatch.RubyCallNode.execute(RubyCallNode.java:143)
    at org.jruby.truffle.nodes.RubyNode.executeVoid(RubyNode.java:67)
    at org.jruby.truffle.nodes.control.SequenceNode.execute(SequenceNode.java:90)
    at org.jruby.truffle.nodes.methods.CatchNextNode.execute(CatchNextNode.java:36)
    at org.jruby.truffle.nodes.methods.CatchReturnAsErrorNode.execute(CatchReturnAsErrorNode.java:35)
    at org.jruby.truffle.nodes.methods.CatchRetryAsErrorNode.execute(CatchRetryAsErrorNode.java:32)
    at org.jruby.truffle.nodes.methods.SetMethodDeclarationContext.execute(SetMethodDeclarationContext.java:46)
    at org.jruby.truffle.nodes.control.SequenceNode.execute(SequenceNode.java:93)
    at org.jruby.truffle.nodes.exceptions.TopLevelRaiseHandler.execute(TopLevelRaiseHandler.java:33)
    at org.jruby.truffle.nodes.RubyRootNode.execute(RubyRootNode.java:57)
    at com.oracle.truffle.api.impl.DefaultCallTarget.call(DefaultCallTarget.java:76)
    at org.jruby.truffle.runtime.RubyContext.execute(RubyContext.java:366)
    at org.jruby.truffle.runtime.RubyContext.execute(RubyContext.java:354)
    at org.jruby.truffle.runtime.RubyContext.load(RubyContext.java:289)
    at org.jruby.truffle.runtime.RubyContext.execute(RubyContext.java:639)
    at org.jruby.Ruby.runInterpreter(Ruby.java:871)
    at org.jruby.Ruby.runInterpreter(Ruby.java:885)
    at org.jruby.Ruby.runNormally(Ruby.java:757)
    at org.jruby.Ruby.runFromMain(Ruby.java:574)
    at org.jruby.Main.doRunFromMain(Main.java:401)
    at org.jruby.Main.internalRun(Main.java:296)
    at org.jruby.Main.run(Main.java:225)
    at org.jruby.Main.main(Main.java:197)
rexissue.rb:3:in `=~': internal implementation error - ValueException empty range in char class org.joni.ast.CClassNode.nextStateValue(CClassNode.java:486) (RubyTruffleError)
    from rexissue.rb:3:in `<main>'

@nirvdrum
Copy link
Contributor

nirvdrum commented Jun 3, 2015

I still have a fair bit more to do. Just getting basic encoding support in caused a 89 failures & errors combined. Working through those took up most of my time. Let's put this issue on hold until I get all the Regexp specs passing (which should also get all the String specs passing).

@bjfish
Copy link
Contributor Author

bjfish commented Jun 10, 2015

@nirvdrum This looks like it works now, thanks. I've added rexml here: 09bd02f

@bjfish bjfish closed this as completed Jun 10, 2015
@enebo enebo added this to the Invalid or Duplicate milestone Dec 7, 2017
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

5 participants