-
-
Notifications
You must be signed in to change notification settings - Fork 932
Closed
Milestone
Description
Reported via ruby/rake#619.
The failure shown in this PR and below is caused by the following sequence of events:
- An exception is raised with a multi-byte UTF-8 string forced to US-ASCII encoding.
- The exception message is written out to a StringIO by rake's trace feature.
- The exception backtrace is written out to the same StringIO, but because it now contains invalid characters the append logic raises.
The error is here (with -X+C
for better Java trace context):
Error: test_display_exception_details_bad_encoding(TestRakeApplication): Java::JavaLang::RuntimeException: org.jruby.exceptions.EncodingError$CompatibilityError: (CompatibilityError) incompatible encodings: US-ASCII and UTF-8
org.jruby.ext.stringio.StringIO.catString(StringIO.java:1665)
org.jruby.ext.stringio.StringIO.stringIOWrite(StringIO.java:1721)
org.jruby.ext.stringio.StringIO.write(StringIO.java:1594)
org.jruby.ext.stringio.StringIO$INVOKER$i$write.call(StringIO$INVOKER$i$write.gen)
org.jruby.dist/org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:242)
org.jruby.dist/org.jruby.RubyIO.write(RubyIO.java:2998)
org.jruby.dist/org.jruby.RubyIO.print1(RubyIO.java:1969)
org.jruby.dist/org.jruby.RubyIO.print(RubyIO.java:1941)
org.jruby.ext.stringio.StringIO$GenericWritable.print(StringIO.java:2045)
Users.headius.work.rake.lib.rake.trace_output.️❤ def trace_on #2(/Users/headius/work/rake/lib/rake/trace_output.rb:20)
Users.headius.work.rake.lib.rake.application.️❤ def trace #55(/Users/headius/work/rake/lib/rake/application.rb:420)
Users.headius.work.rake.lib.rake.application.️❤ def display_exception_backtrace #30(/Users/headius/work/rake/lib/rake/application.rb:279)
Users.headius.work.rake.lib.rake.application.️❤ def display_exception_details #25(/Users/headius/work/rake/lib/rake/application.rb:246)
Users.headius.work.rake.lib.rake.application.️❤ def display_error_message #24(/Users/headius/work/rake/lib/rake/application.rb:236)
Users.headius.work.rake.lib.rake.application.️❤ def display_error_message #24 **(/Users/headius/work/rake/lib/rake/application.rb:234)
org.jruby.dist/org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:139)
org.jruby.dist/org.jruby.ir.targets.indy.InvokeSite.performIndirectCall(InvokeSite.java:860)
org.jruby.dist/org.jruby.ir.targets.indy.InvokeSite.invoke(InvokeSite.java:785)
Users.headius.work.rake.test.test_rake_application.️❤ {} test_display_exception_details_bad_encoding #13(/Users/headius/work/rake/test/test_rake_application.rb:97)
The test is here:
It seems we are not handling the badly-encoded string properly, either going into the exception or coming out of it. Possibly we are also not handling the case where StringIO receives a badly-encoded string followed by a well-formed string.
Metadata
Metadata
Assignees
Labels
No labels