Bug #2611

Hang while executing END blocks with redirected stderr

Added by tmat (Tomas Matousek) over 2 years ago. Updated about 1 year ago.

[ruby-core:27608]
Status:Closed Start date:01/17/2010
Priority:Normal Due date:
Assignee:ko1 (Koichi Sasada) % Done:

100%

Category:-
Target version:-
ruby -v:ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-mswin32]

Description

The following code hangs with CPU on 100% at a random point during execution of END blocks.

class C
  def write(x)
    puts "[#{x}]"
  end
end

$stderr = C.new

END {
  raise 'e1'
}
END {
  puts 'e2'
}
END {
  raise 'e3'
}
END {
  puts 'e4'
}
END {
  raise 'e5'
}


output:

ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-mswin32]
[END_exceptions.rb:22:in `block in <main>']
[: ]
[e5]
[ (]
[RuntimeError]
[)
]
e4
[END_exceptions.rb:16:in `block in <main>']
[: ]
[e3]
[ (]
[RuntimeError]

---
Wrks fine in 1.8.6.

err_print.patch (561 Bytes) wanabe (_ wanabe), 01/28/2010 07:19 pm

Associated revisions

Revision 28368
Added by wanabe (_ wanabe) almost 2 years ago

* eval_error.c (error_print): clear raised_flag while error-printing to avoid hang. [ruby-core:27608] * test/ruby/test_beginendblock.rb (test_endblock_raise): add test for above.

History

Updated by rogerdpack (Roger Pack) over 2 years ago

was able to reproduce this for 1.9.1p376 mingw, 1.9.2 mingw (not on linux, though--works fine there).

Updated by naruse (Yui NARUSE) over 2 years ago

  • Status changed from Open to Assigned
  • Assignee set to usa (Usaku NAKAMURA)

Updated by wanabe (_ wanabe) over 2 years ago

  • File err_print.patch added
  • Assignee changed from usa (Usaku NAKAMURA) to ko1 (Koichi Sasada)
I reproduced it on Ubuntu 9.10 by adding "sleep 0.01" at the first line of C#write.

blocking_region_begin() can't stop with th->raised_flag and th->interrupt_flag,
so raised_flag should be clear before entering blocking-region, I guess.

I wrote a patch, but it's doubtful that this is correct.
ko1, How do you think this issue?

Updated by wanabe (_ wanabe) almost 2 years ago

I don't know my patch is good solution, But I think that it is not harmful.
I will commit the patch this weekend, unless any objection.
Anyone, Any comment?

Updated by wanabe (_ wanabe) almost 2 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100
This issue was solved with changeset r28368.
Tomas, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

Also available in: Atom PDF