Bug #2611
Hang while executing END blocks with redirected stderr
| Status: | Closed | Start date: | 01/17/2010 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % 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.
Associated revisions
* 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 Roger Pack about 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 Yui NARUSE about 2 years ago
- Status changed from Open to Assigned
- Assignee set to Usaku NAKAMURA
Updated by _ wanabe about 2 years ago
- File err_print.patch added
- Assignee changed from Usaku NAKAMURA to 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 over 1 year 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 over 1 year 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.