JRuby (please use github issues at http://bugs.jruby.org)
  1. JRuby (please use github issues at http://bugs.jruby.org)
  2. JRUBY-6613

special characters like umlauts make Kramdown hang (works with MRI Rubies)

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.7.0.pre1
    • Fix Version/s: JRuby 1.7.0.pre2
    • Component/s: Interpreter
    • Labels:
      None
    • Environment:
      It happens with jruby-1.6.7 final and also with the current jruby-head, on Linux.
    • Number of attachments :
      0

      Description

      Hi,

      I hope this is the right place for this issue (and not in the Kramdown issues list)

      Reproducing it is simple:
      install the current kramdown gem with jruby and run

      > require 'kramdown'
      > puts Kramdown::Document.new('ab').to_html

      with irb.

      It will run in an endless loop whenever there are special chars like or or in the string.
      With Ruby 1.9.3 it works fine.
      Currently I'm not able to get more information by looking at the JVM's stacktrace.

      Maybe this relates to https://github.com/rtomayko/rdiscount/pull/58 where Charly said: "and rdiscount_test.rb appears to hang (possibly a JRuby bug)."

        Activity

        Hide
        Hiro Asari added a comment -

        Our regex state machine seems to be going into an infinite loop. Further reduction is probably possible.

        Show
        Hiro Asari added a comment - Our regex state machine seems to be going into an infinite loop. Further reduction is probably possible.
        Hide
        Dominique Broeglin added a comment -

        Hello!

        I can confirm the issue on jruby 1.6.7.2 on Mac OS X. One detail though: it works when in --1.8 mode but loops in --1.9 mode.

        Show
        Dominique Broeglin added a comment - Hello! I can confirm the issue on jruby 1.6.7.2 on Mac OS X. One detail though: it works when in --1.8 mode but loops in --1.9 mode.
        Hide
        Dominique Broeglin added a comment - - edited

        I think I was able to track it down to this somewhat simpler example:

        require 'strscan'
        re = /(?=(?-mix:\*|_|`|<|<|\[|!?\[|[^\\]?["']|\$|\{:|&|--|\.\.\.|(?:\\| )?(?:<<|>>)|(  |\\)(?=\n)|\\))/
        StringScanner.new('ab', :text_type => :text).scan_until(re)
        

        Which returns nil in --1.8 mode and loops in --1.9 mode.

        The regexp comes from Kramdown. I'm not knowledgeable enough about regexes to dumb down the example further, sorry. But anyway, scan_until should always return, right ?

        Show
        Dominique Broeglin added a comment - - edited I think I was able to track it down to this somewhat simpler example: require 'strscan' re = /(?=(?-mix:\*|_|`|<|<|\[|!?\[|[^\\]?["']|\$|\{:|&|--|\.\.\.|(?:\\| )?(?:<<|>>)|( |\\)(?=\n)|\\))/ StringScanner. new ('ab', :text_type => :text).scan_until(re) Which returns nil in --1.8 mode and loops in --1.9 mode. The regexp comes from Kramdown. I'm not knowledgeable enough about regexes to dumb down the example further, sorry. But anyway, scan_until should always return, right ?
        Hide
        Dominique Broeglin added a comment -

        BTW, a stack dump while looping puts the execution somewhere in joni:

           java.lang.Thread.State: RUNNABLE
        	at org.joni.StackMachine.pushAlt(StackMachine.java:200)
        	at org.joni.ByteCodeMachine.opPush(ByteCodeMachine.java:1429)
        	at org.joni.ByteCodeMachine.matchAt(ByteCodeMachine.java:263)
        	at org.joni.Matcher.matchCheck(Matcher.java:293)
        	at org.joni.Matcher.search(Matcher.java:461)
        	at org.jruby.RubyStringScanner.scan(RubyStringScanner.java:210)
        	at org.jruby.RubyStringScanner.scan_until(RubyStringScanner.java:257)
        	at org.jruby.RubyStringScanner$i$1$0$scan_until.call(RubyStringScanner$i$1$0$scan_until.gen:65535)
        	at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:312)
        	at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:169)
        	at org.jruby.ast.CallOneArgNode.interpret(CallOneArgNode.java:57)
        
        Show
        Dominique Broeglin added a comment - BTW, a stack dump while looping puts the execution somewhere in joni: java.lang. Thread .State: RUNNABLE at org.joni.StackMachine.pushAlt(StackMachine.java:200) at org.joni.ByteCodeMachine.opPush(ByteCodeMachine.java:1429) at org.joni.ByteCodeMachine.matchAt(ByteCodeMachine.java:263) at org.joni.Matcher.matchCheck(Matcher.java:293) at org.joni.Matcher.search(Matcher.java:461) at org.jruby.RubyStringScanner.scan(RubyStringScanner.java:210) at org.jruby.RubyStringScanner.scan_until(RubyStringScanner.java:257) at org.jruby.RubyStringScanner$i$1$0$scan_until.call(RubyStringScanner$i$1$0$scan_until.gen:65535) at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:312) at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:169) at org.jruby.ast.CallOneArgNode.interpret(CallOneArgNode.java:57)
        Hide
        Dominique Broeglin added a comment -

        This is likely to be a duplicate of https://github.com/jruby/jruby/issues/174

        Show
        Dominique Broeglin added a comment - This is likely to be a duplicate of https://github.com/jruby/jruby/issues/174
        Hide
        Dominique Broeglin added a comment -

        The issue was probably solved by https://github.com/jruby/jruby/issues/174

        The example

        > require 'kramdown'
        > puts Kramdown::Document.new('ab').to_html

        is now working with a fresh jruby-head installed through RVM.

        Show
        Dominique Broeglin added a comment - The issue was probably solved by https://github.com/jruby/jruby/issues/174 The example > require 'kramdown' > puts Kramdown::Document.new('ab').to_html is now working with a fresh jruby-head installed through RVM.
        Hide
        Charles Oliver Nutter added a comment -

        Works on master.

        Show
        Charles Oliver Nutter added a comment - Works on master.

          People

          • Assignee:
            Charles Oliver Nutter
            Reporter:
            Heiko Seebach
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: