Backport #3910

SEGV at fptr_finalize

Added by Masaki Matsushita over 3 years ago. Updated almost 3 years ago.

[ruby-dev:42341]
Status:Closed
Priority:Normal
Assignee:Yuki Sonoda

Description

=begin
次のようなコードを実行すると、SEGVします。

#-- coding: utf-8 --
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'RMagick'

def create
io = open("data","w+:UTF-8")
io.print "hoge"
end

create

doc = Nokogiri::XML(open("http://www.google.co.jp/"))

puts "sleep"
sleep

--ここまで--

~/ruby% ruby SEGV.rb
internal:lib/rubygems/custom_require:29: [BUG] Segmentation fault
ruby 1.9.2p0 (2010-08-18) [i686-linux]

-- control frame ----------
c:0014 p:---- s:0088 b:0088 l:000087 d:000087 CFUNC :require
c:0013 p:0013 s:0084 b:0084 l:000083 d:000083 METHOD internal:lib/rubygems/custom_require:29
c:0012 p:0132 s:0079 b:0079 l:000078 d:000078 METHOD /usr/local/lib/ruby/1.9.1/open-uri.rb:260
c:0011 p:0024 s:0059 b:0059 l:000058 d:000058 METHOD /usr/local/lib/ruby/1.9.1/open-uri.rb:769
c:0010 p:0047 s:0053 b:0053 l:000ca0 d:000052 BLOCK /usr/local/lib/ruby/1.9.1/open-uri.rb:203
c:0009 p:---- s:0051 b:0051 l:000050 d:000050 FINISH
c:0008 p:---- s:0049 b:0049 l:000048 d:000048 CFUNC :catch
c:0007 p:0491 s:0045 b:0045 l:000ca0 d:000ca0 METHOD /usr/local/lib/ruby/1.9.1/open-uri.rb:201
c:0006 p:0328 s:0031 b:0031 l:000030 d:000030 METHOD /usr/local/lib/ruby/1.9.1/open-uri.rb:146
c:0005 p:0022 s:0020 b:0020 l:000019 d:000019 METHOD /usr/local/lib/ruby/1.9.1/open-uri.rb:671
c:0004 p:0096 s:0015 b:0015 l:000014 d:000014 METHOD /usr/local/lib/ruby/1.9.1/open-uri.rb:33
c:0003 p:0093 s:0008 b:0007 l:0024ec d:001bf8 EVAL SEGV.rb:14
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:0024ec d:0024ec TOP


-- Ruby level backtrace information ----------------------------------------
SEGV.rb:14:in <main>'
/usr/local/lib/ruby/1.9.1/open-uri.rb:33:in
open'
/usr/local/lib/ruby/1.9.1/open-uri.rb:671:in open'
/usr/local/lib/ruby/1.9.1/open-uri.rb:146:in
openuri'
/usr/local/lib/ruby/1.9.1/open-uri.rb:201:in open_loop'
/usr/local/lib/ruby/1.9.1/open-uri.rb:201:in
catch'
/usr/local/lib/ruby/1.9.1/open-uri.rb:203:in block in open_loop'
/usr/local/lib/ruby/1.9.1/open-uri.rb:769:in
buffer
open'
/usr/local/lib/ruby/1.9.1/open-uri.rb:260:in open_http'
<internal:lib/rubygems/custom_require>:29:in
require'
internal:lib/rubygems/custom_require:29:in `require'

-- C level backtrace information -------------------------------------------
ruby(rbvmbugreport+0xa5) [0x81613e5]
ruby() [0x81a0189]
ruby(rbbug+0x28) [0x81a0238]
ruby() [0x80f34d8]
[0x2a3410]
ruby() [0x8137b72]
ruby(rb
classpath+0x16) [0x8137d76]
ruby(rb
objclassname+0x3a) [0x813888a]
ruby() [0x81a1835]
ruby(rb
checktypeddata+0x26) [0x81a18f6]
ruby(rb
mutexlock+0x1c) [0x816723c]
ruby(rb
mutexsynchronize+0x12) [0x81677e2]
ruby() [0x8077edc]
ruby() [0x80782ed]
ruby(rb
iofptrfinalize+0xd4) [0x8078c44]
ruby() [0x806711e]
ruby(rbgcfinalizedeferred+0x29) [0x8067679]
ruby() [0x8164e35]
ruby() [0x8151a8f]
ruby(rb
funcall+0x9a) [0x815264a]
ruby(rbhasharef+0x5d) [0x806cb1d]
ruby() [0x81a8dbb]
ruby(rbrealpathinternal+0x179) [0x81a9999]
ruby() [0x814929e]
ruby(rbiseqnewwithopt+0x7b) [0x814b5bb]
ruby() [0x8139a91]
ruby() [0x813daf4]
ruby() [0x813b1cb]
ruby(rbiseqcompilenode+0x85c) [0x81438fc]
ruby(rb
iseqnewwithopt+0x8a) [0x814b5ca]
ruby() [0x8139a91]
ruby() [0x813e276]
ruby() [0x813b1cb]
ruby(rb
iseqcompilenode+0x85c) [0x81438fc]
ruby(rbiseqnewwithopt+0x8a) [0x814b5ca]
ruby() [0x8139a91]
ruby() [0x813e276]
ruby() [0x813b1cb]
ruby(rbiseqcompilenode+0x68e) [0x814372e]
ruby() [0x814af82]
ruby(rb
iseqnewtop+0x41) [0x814b1c1]
ruby() [0x81a2705]
ruby(rbrequiresafe+0x54a) [0x81a3d9a]
ruby() [0x8158181]
ruby() [0x815a528]
ruby() [0x815df06]
ruby() [0x815f09d]
ruby(rbcatchobj+0x9f) [0x814c86f]
ruby() [0x814da96]
ruby() [0x814ccc5]
ruby() [0x8158181]
ruby() [0x815a528]
ruby() [0x815df06]
ruby(rbiseqevalmain+0x1c7) [0x815e2d7]
ruby() [0x805e492]
ruby(ruby
runnode+0x32) [0x805fcb2]
ruby(main+0x5a) [0x805d6ca]
/lib/tls/i686/cmov/libc.so.6(
libcstart_main+0xe6) [0x3d4bd6]
ruby() [0x805d5d1]

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

zsh: abort ruby SEGV.rb

rmagickのバージョンは2.13.1、nokogiriは1.4.3.1です。
--disable-sharedでないと再現しません。
=end


Related issues

Duplicated by Backport92 - Backport #3951: Seg Fault with Rails 3 and Unicorn Closed 10/16/2010
Duplicated by Backport92 - Backport #3959: Ruby 1.9.2p0 Segmentation fault under Linux x64 with rvm Closed 10/18/2010
Duplicated by ruby-trunk - Bug #3973: Unexpected error and segmentation fault without close Closed 10/21/2010
Duplicated by Backport92 - Backport #4003: Segmentation fault Closed 10/29/2010
Duplicates ruby-trunk - Bug #4048: Segmentation Fault Closed 11/13/2010
Duplicated by ruby-trunk - Bug #3941: Segmentation fault ruby 1.9.2p0 [x86_64-linux] Closed 10/13/2010
Duplicated by ruby-trunk - Bug #4162: C segfault in TCPSocket CFUNC :read Closed 12/15/2010
Duplicated by Backport92 - Backport #4240: segment fault on ruby on rails project Closed 01/06/2011
Duplicated by ruby-trunk - Bug #5107: Segmentation fault Closed 07/27/2011

Associated revisions

Revision 29564
Added by Yuki Sonoda over 3 years ago

merges r29415 from trunk into ruby19_2. fixes #3910 #3951 and #3959.

  • io.c (fptrfinalize): writemutex might have been destroyed already in finalization phase, as the order of finalizers is not guaranteed. rbmutext should be used in place of Mutex object in the future.

History

#1 Updated by Shota Fukumori over 3 years ago

=begin
sora_hです。
外部ライブラリ依存を外してみましたが、今度はC level tracktraceが出力されなくなりましたね。

#-- coding: utf-8 --
require 'open-uri'

def create
io = open("/dev/null","w")
io.print "hoge"
end

create

doc = open("http://www.google.co.jp/")

--

internal:lib/rubygems/custom_require:29: [BUG] Segmentation fault
ruby 1.9.2p0 (2010-08-18) [x86_64-darwin10.4.0]

-- control frame ----------
c:0014 p:---- s:0087 b:0087 l:000086 d:000086 CFUNC :require
c:0013 p:0013 s:0083 b:0083 l:000082 d:000082 METHOD internal:lib/rubygems/custom_require:29
c:0012 p:0132 s:0078 b:0078 l:000077 d:000077 METHOD /Users/sorah/git/ruby/core/lib/open-uri.rb:260
c:0011 p:0024 s:0058 b:0058 l:000057 d:000057 METHOD /Users/sorah/git/ruby/core/lib/open-uri.rb:769
c:0010 p:0047 s:0052 b:0052 l:002290 d:000051 BLOCK /Users/sorah/git/ruby/core/lib/open-uri.rb:203
c:0009 p:---- s:0050 b:0050 l:000049 d:000049 FINISH
c:0008 p:---- s:0048 b:0048 l:000047 d:000047 CFUNC :catch
c:0007 p:0491 s:0044 b:0044 l:002290 d:002290 METHOD /Users/sorah/git/ruby/core/lib/open-uri.rb:201
c:0006 p:0328 s:0030 b:0030 l:000029 d:000029 METHOD /Users/sorah/git/ruby/core/lib/open-uri.rb:146
c:0005 p:0022 s:0019 b:0019 l:000018 d:000018 METHOD /Users/sorah/git/ruby/core/lib/open-uri.rb:671
c:0004 p:0096 s:0014 b:0014 l:000013 d:000013 METHOD /Users/sorah/git/ruby/core/lib/open-uri.rb:33
c:0003 p:0050 s:0007 b:0007 l:001598 d:0018a0 EVAL test.rb:11
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:001598 d:001598 TOP


-- Ruby level backtrace information ----------------------------------------
test.rb:11:in <main>'
/Users/sorah/git/ruby/core/lib/open-uri.rb:33:in
open'
/Users/sorah/git/ruby/core/lib/open-uri.rb:671:in open'
/Users/sorah/git/ruby/core/lib/open-uri.rb:146:in
openuri'
/Users/sorah/git/ruby/core/lib/open-uri.rb:201:in open_loop'
/Users/sorah/git/ruby/core/lib/open-uri.rb:201:in
catch'
/Users/sorah/git/ruby/core/lib/open-uri.rb:203:in block in open_loop'
/Users/sorah/git/ruby/core/lib/open-uri.rb:769:in
buffer
open'
/Users/sorah/git/ruby/core/lib/open-uri.rb:260:in open_http'
<internal:lib/rubygems/custom_require>:29:in
require'
internal:lib/rubygems/custom_require:29:in `require'

-- C level backtrace information -------------------------------------------

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

=end

#2 Updated by Nobuyoshi Nakada over 3 years ago

  • Status changed from Open to Closed

=begin
This issue was solved with changeset r29415.
Masaki, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

#3 Updated by Nobuyoshi Nakada over 3 years ago

  • Status changed from Closed to Assigned
  • Assignee set to Yuki Sonoda

=begin

=end

#4 Updated by Nobuyoshi Nakada over 3 years ago

  • Category set to core

=begin

=end

#5 Updated by Yui NARUSE over 3 years ago

  • Status changed from Assigned to Closed

=begin

=end

Also available in: Atom PDF