Glibc detected *** ruby: malloc(): memory corruption:

hello

I have been experiencing some problems with my rails site, especially
eith rmagick.

My images uploaded are wrong, so I thought I would test my rmagick app
with a bit of ruby code

#!/usr/bin/env ruby -wKU

    # Test if rmagick is working properly or not.
    # When run, this file creates a image file 'path.gif' in the same
directory.

    # the sample code is from
http://rmagick.rubyforge.org/portfolio3.html

    require 'rubygems'
    require 'RMagick'

    canvas = Magick::Image.new(240, 300,
                  Magick::HatchFill.new('white','lightcyan2'))
    gc = Magick::Draw.new

    gc.fill('red')
    gc.stroke('blue')
    gc.stroke_width(2)
    gc.path('M120,150 h-75 a75,75 0 1, 0 75,-75 z')
    gc.fill('yellow')
    gc.path('M108.5,138.5 v-75 a75,75 0 0,0 -75,75 z')
    gc.draw(canvas)

    canvas.write('path.gif')

which should generate a nice little gif.

but when I run it i get an error: any ideas? i have’t seen anything like
this before…

*** glibc detected *** ruby: malloc(): memory corruption:
0x000000000099d890 ***
======= Backtrace: =========
/lib64/libc.so.6[0x7fd9b3e28fec]
/lib64/libc.so.6[0x7fd9b3e29b6b]
/lib64/libc.so.6(__libc_memalign+0xa2)[0x7fd9b3e2ab02]
/lib64/libc.so.6(posix_memalign+0x61)[0x7fd9b3e2acb1]
/usr/local/lib/libMagickCore.so.2(AcquireAlignedMemory+0x43)[0x7fd9b23abc43]
/usr/local/lib/libMagickCore.so.2(AllocateSemaphoreInfo+0x22)[0x7fd9b23f0a92]
/usr/local/lib/libMagickCore.so.2(AcquireSemaphoreInfo+0x91)[0x7fd9b23f0ca1]
/usr/local/lib/libMagickCore.so.2(DestroyExceptionInfo+0x2d)[0x7fd9b2380ced]
/home/steverp/.gem/ruby/1.8/gems/rmagick-2.12.2/lib/RMagick2.so(Image_store_pixels+0x2aa)[0x7fd9b2bc264a]
ruby[0x41b5ab]
ruby[0x41c2c8]
ruby[0x416ed5]
ruby[0x41a305]
ruby[0x440926]
ruby[0x41b5ab]
ruby[0x41c2c8]
ruby[0x416ed5]
ruby[0x419022]
ruby[0x41be10]
ruby[0x41c2c8]
ruby[0x41c868]
ruby(rb_funcall+0x83)[0x41caf3]
/home/steverp/.gem/ruby/1.8/gems/rmagick-2.12.2/lib/RMagick2.so(Image_initialize+0x13c)[0x7fd9b2bbd2e7]
ruby[0x41b5ab]
ruby[0x41c2c8]
ruby(rb_funcall2+0x32)[0x41c4e2]
ruby(rb_obj_call_init+0x54)[0x41c584]
ruby(rb_class_new_instance+0x32)[0x444032]
ruby[0x41b5ab]
ruby[0x41c2c8]
ruby[0x416ed5]
ruby[0x4162ac]
ruby[0x427bb9]
ruby(ruby_exec+0x15)[0x427c05]
ruby(ruby_run+0x1f)[0x427c2f]
ruby[0x40ddd3]
/lib64/libc.so.6(__libc_start_main+0xf4)[0x7fd9b3dd4074]
ruby[0x40dce9]
======= Memory map: ========
00400000-004cf000 r-xp 00000000 08:01 151910
/usr/local/bin/ruby
006ce000-006d0000 rw-p 000ce000 08:01 151910
/usr/local/bin/ruby
006d0000-009e2000 rw-p 006d0000 00:00 0
[heap]
7fd9a4000000-7fd9a4021000 rw-p 7fd9a4000000 00:00 0
7fd9a4021000-7fd9a8000000 —p 7fd9a4021000 00:00 0
7fd9ab595000-7fd9ab5a2000 r-xp 00000000 08:01 49381
/lib64/libgcc_s-4.1.2-20070925.so.1
7fd9ab5a2000-7fd9ab7a2000 —p 0000d000 08:01 49381
/lib64/libgcc_s-4.1.2-20070925.so.1
7fd9ab7a2000-7fd9ab7a3000 rw-p 0000d000 08:01 49381
/lib64/libgcc_s-4.1.2-20070925.so.1
7fd9ab7a3000-7fd9b01fd000 r–p 00000000 08:01 84745
/usr/lib/locale/locale-archive
7fd9b01fd000-7fd9b0202000 r-xp 00000000 08:01 175076
/usr/lib64/libXdmcp.so.6.0.0
7fd9b0202000-7fd9b0401000 —p 00005000 08:01 175076
/usr/lib64/libXdmcp.so.6.0.0
7fd9b0401000-7fd9b0402000 rw-p 00004000 08:01 175076
/usr/lib64/libXdmcp.so.6.0.0
7fd9b0402000-7fd9b041c000 r-xp 00000000 08:01 175804
/usr/lib64/libxcb.so.1.0.0
7fd9b041c000-7fd9b061c000 —p 0001a000 08:01 175804
/usr/lib64/libxcb.so.1.0.0
7fd9b061c000-7fd9b061d000 rw-p 0001a000 08:01 175804
/usr/lib64/libxcb.so.1.0.0
7fd9b061d000-7fd9b061e000 r-xp 00000000 08:01 175599
/usr/lib64/libxcb-xlib.so.0.0.0
7fd9b061e000-7fd9b081d000 —p 00001000 08:01 175599
/usr/lib64/libxcb-xlib.so.0.0.0
7fd9b081d000-7fd9b081e000 rw-p 00000000 08:01 175599
/usr/lib64/libxcb-xlib.so.0.0.0
7fd9b081e000-7fd9b0820000 r-xp 00000000 08:01 175643
/usr/lib64/libXau.so.6.0.0
7fd9b0820000-7fd9b0a1f000 —p 00002000 08:01 175643
/usr/lib64/libXau.so.6.0.0
7fd9b0a1f000-7fd9b0a20000 rw-p 00001000 08:01 175643
/usr/lib64/libXau.so.6.0.0
7fd9b0a20000-7fd9b0a41000 r-xp 00000000 08:01 175950
/usr/lib64/libjpeg.so.62.0.0
7fd9b0a41000-7fd9b0c40000 —p 00021000 08:01 175950
/usr/lib64/libjpeg.so.62.0.0
7fd9b0c40000-7fd9b0c41000 rw-p 00020000 08:01 175950
/usr/lib64/libjpeg.so.62.0.0
7fd9b0c41000-7fd9b0c48000 r-xp 00000000 08:01 175645
/usr/lib64/libgomp.so.1.0.0
7fd9b0c48000-7fd9b0e48000 —p 00007000 08:01 175645
/usr/lib64/libgomp.so.1.0.0
7fd9b0e48000-7fd9b0e49000 rw-p 00007000 08:01 175645
/usr/lib64/libgomp.so.1.0.0
7fd9b0e49000-7fd9b0e58000 r-xp 00000000 08:01 49211
/lib64/libbz2.so.1.0.4
7fd9b0e58000-7fd9b1057000 —p 0000f000 08:01 49211
/lib64/libbz2.so.1.0.4
7fd9b1057000-7fd9b1059000 rw-p 0000e000 08:01 49211
/lib64/libbz2.so.1.0.4
7fd9b1059000-7fd9b10b4000 r-xp 00000000 08:01 175925
/usr/lib64/libXt.so.6.0.0
7fd9b10b4000-7fd9b12b3000 —p 0005b000 08:01 175925
/usr/lib64/libXt.so.6.0.0
7fd9b12b3000-7fd9b12b9000 rw-p 0005a000 08:01 175925
/usr/lib64/libXt.so.6.0.0
7fd9b12b9000-7fd9b12ba000 rw-p 7fd9b12b9000 00:00 0
7fd9b12ba000-7fd9b13b8000 r-xp 00000000 08:01 175503
/usr/lib64/libX11.so.6.2.0
7fd9b13b8000-7fd9b15b8000 —p 000fe000 08:01 175503
/usr/lib64/libX11.so.6.2.0
7fd9b15b8000-7fd9b15be000 rw-p 000fe000 08:01 175503
/usr/lib64/libX11.so.6.2.0
7fd9b15be000-7fd9b15d5000 r-xp 00000000 08:01 175670
/usr/lib64/libICE.so.6.3.0
7fd9b15d5000-7fd9b17d4000 —p 00017000 08:01 175670
/usr/lib64/libICE.so.6.3.0
7fd9b17d4000-7fd9b17d5000 rw-p 00016000 08:01 175670
/usr/lib64/libICE.so.6.3.0
7fd9b17d5000-7fd9b17d9000 rw-p 7fd9b17d5000 00:00 0
7fd9b17d9000-7fd9b17e2000 r-xp 00000000 08:01 175889
/usr/lib64/libSM.so.6.0.0
7fd9b17e2000-7fd9b19e2000 —p 00009000 08:01 175889
/usr/lib64/libSM.so.6.0.0
7fd9b19e2000-7fd9b19e3000 rw-p 00009000 08:01 175889
/usr/lib64/libSM.so.6.0.0
7fd9b19e3000-7fd9b19f3000 r-xp 00000000 08:01 175521
/usr/lib64/libXext.so.6.4.0
7fd9b19f3000-7fd9b1bf3000 —p 00010000 08:01 175521
/usr/lib64/libXext.so.6.4.0
7fd9b1bf3000-7fd9b1bf4000 rw-p 00010000 08:01 175521
/usr/lib64/libXext.so.6.4.0
7fd9b1bf4000-7fd9b1c29000 r-xp 00000000 08:01 153356
/usr/local/lib/libjpeg.so.7.0.0
7fd9b1c29000-7fd9b1e28000 —p 00035000 08:01 153356
/usr/local/lib/libjpeg.so.7.0.0
7fd9b1e28000-7fd9b1e29000 rw-p 00034000 08:01 153356
/usr/local/lib/libjpeg.so.7.0.0
7fd9b1e29000-7fd9b1e80000 r-xp 00000000 08:01 175509
/usr/lib64/libtiff.so.3.8.2
7fd9b1e80000-7fd9b207f000 —p 00057000 08:01 175509
/usr/lib64/libtiff.so.3.8.2
7fd9b207f000-7fd9b2082000 rw-p 00056000 08:01 175509
/usr/lib64/libtiff.so.3.8.2
7fd9b2082000-7fd9b20b3000 r-xp 00000000 08:01 175647
/usr/lib64/liblcms.so.1.0.16
7fd9b20b3000-7fd9b22b3000 —p 00031000 08:01 175647
/usr/lib64/liblcms.so.1.0.16
7fd9b22b3000-7fd9b22b5000 rw-p 00031000 08:01 175647
/usr/lib64/liblcms.so.1.0.16
7fd9b22b5000-7fd9b22b7000 rw-p 7fd9b22b5000 00:00 0
7fd9b22b7000-7fd9b248c000 r-xp 00000000 08:01 153296
/usr/local/lib/libMagickCore.so.2.0.0
7fd9b248c000-7fd9b268c000 —p 001d5000 08:01 153296
/usr/local/lib/libMagickCore.so.2.0.0
7fd9b268c000-7fd9b26de000 rw-p 001d5000 08:01 153296
/usr/local/lib/libMagickCore.so.2.0.0
7fd9b26de000-7fd9b26f6000 rw-p 7fd9b26de000 00:00 0
7fd9b26f6000-7fd9b270a000 r-xp 00000000 08:01 49400
/lib64/libz.so.1.2.3
7fd9b270a000-7fd9b2909000 —p 00014000 08:01 49400
/lib64/libz.so.1.2.3
7fd9b2909000-7fd9b290a000 rw-p 00013000 08:01 49400
/lib64/libz.so.1.2.3
7fd9b290a000-7fd9b2987000 r-xp 00000000 08:01 153632
/usr/local/lib/libfreetype.so.6.3.22
7fd9b2987000-7fd9b2b86000 —p 0007d000 08:01 153632
/usr/local/lib/libfreetype.so.6.3.22
7fd9b2b86000-7fd9b2b8c000 rw-p 0007c000 08:01 153632
/usr/local/lib/libfreetype.so.6.3.22
7fd9b2b8c000-7fd9b2bee000 r-xp 00000000 08:01 513823
/home/steverp/.gem/ruby/1.8/gems/rmagick-2.12.2/lib/RMagick2.so
7fd9b2bee000-7fd9b2dee000 —p 00062000 08:01 513823
/home/steverp/.gem/ruby/1.8/gems/rmagick-2.12.2/lib/RMagick2.so
7fd9b2dee000-7fd9b2df1000 rw-p 00062000 08:01 513823
/home/steverp/.gem/ruby/1.8/gems/rmagick-2.12.2/lib/RMagick2.so
7fd9b2df1000-7fd9b302b000 rw-p 7fd9b2df1000 00:00 0
7fd9b302b000-7fd9b3035000 r-xp 00000000 08:01 49379
/lib64/libnss_files-2.7.so
7fd9b3035000-7fd9b3234000 —p 0000a000 08:01 49379
/lib64/libnss_files-2.7.so
7fd9b3234000-7fd9b3235000 r–p 00009000 08:01 49379
/lib64/libnss_files-2.7.so
7fd9b3235000-7fd9b3236000 rw-p 0000a000 08:01 49379
/lib64/libnss_files-2.7.so
7fd9b3236000-7fd9b3373000 rw-p 7fd9b3236000 00:00 0
7fd9b3373000-7fd9b338f000 r-xp 00000000 08:01 152532
/usr/local/lib/ruby/1.8/x86_64-linux/syck.so
7fd9b338f000-7fd9b358e000 —p 0001c000 08:01 152532
/usr/local/lib/ruby/1.8/x86_64-linux/syck.so
7fd9b358e000-7fd9b358f000 rw-p 0001b000 08:01 152532
/usr/local/lib/ruby/1.8/x86_64-linux/syck.so
7fd9b358f000-7fd9b3590000 rw-p 7fd9b358f000 00:00 0
7fd9b3590000-7fd9b3595000 r-xp 00000000 08:01 152527
/usr/local/lib/ruby/1.8/x86_64-linux/stringio.so
7fd9b3595000-7fd9b3794000 —p 00005000 08:01 152527
/usr/local/lib/ruby/1.8/x86_64-linux/stringio.so
7fd9b3794000-7fd9b3795000 rw-p 00004000 08:01 152527
/usr/local/lib/ruby/1.8/x86_64-linux/stringio.so
7fd9b3795000-7fd9b3797000 r-xp 00000000 08:01 152526
/usr/local/lib/ruby/1.8/x86_64-linux/etc.so
7fd9b3797000-7fd9b3996000 —p 00002000 08:01 152526
/usr/local/lib/ruby/1.8/x86_64-linux/etc.so
7fd9b3996000-7fd9b3997000 rw-p 00001000 08:01 152526
/usr/local/lib/ruby/1.8/x86_64-linux/etc.so
7fd9b3997000-7fd9b399b000 r-xp 00000000 08:01 152544
/usr/local/lib/ruby/1.8/x86_64-linux/thread.so
7fd9b399b000-7fd9b3b9a000 —p 00004000 08:01 152544
/usr/local/lib/ruby/1.8/x86_64-linux/thread.so
7fd9b3b9a000-7fd9b3b9b000 rw-p 00003000 08:01 152544
/usr/local/lib/ruby/1.8/x86_64-linux/thread.so
7fd9b3b9b000-7fd9b3bb1000 r-xp 00000000 08:01 49419
/lib64/libpthread-2.7.so
7fd9b3bb1000-7fd9b3db0000 —p 00016000 08:01 49419
/lib64/libpthread-2.7.so
7fd9b3db0000-7fd9b3db1000 r–p 00015000 08:01 49419
/lib64/libpthread-2.7.so
7fd9b3db1000-7fd9b3db2000 rw-p 00016000 08:01 49419
/lib64/libpthread-2.7.so
7fd9b3db2000-7fd9b3db6000 rw-p 7fd9b3db2000 00:00 0
7fd9b3db6000-7fd9b3f03000 r-xp 00000000 08:01 49377
/lib64/libc-2.7.so
7fd9b3f03000-7fd9b4103000 —p 0014d000 08:01 49377
/lib64/libc-2.7.so
7fd9b4103000-7fd9b4107000 r–p 0014d000 08:01 49377
/lib64/libc-2.7.so
7fd9b4107000-7fd9b4108000 rw-p 00151000 08:01 49377
/lib64/libc-2.7.so
7fd9b4108000-7fd9b410d000 rw-p 7fd9b4108000 00:00 0
7fd9b410d000-7fd9b418f000 r-xp 00000000 08:01 49403
/lib64/libm-2.7.so
7fd9b418f000-7fd9b438e000 —p 00082000 08:01 49403
/lib64/libm-2.7.so
7fd9b438e000-7fd9b438f000 r–p 00081000 08:01 49403
/lib64/libm-2.7.so
7fd9b438f000-7fd9b4390000 rw-p 00082000 08:01 49403
/lib64/libm-2.7.so
7fd9b4390000-7fd9b4399000 r-xp 00000000 08:01 49406
/lib64/libcrypt-2.7.so
7fd9b4399000-7fd9b4598000 —p 00009000 08:01 49406
/lib64/libcrypt-2.7.so
7fd9b4598000-7fd9b4599000 r–p 00008000 08:01 49406
/lib64/libcrypt-2.7.so
7fd9b4599000-7fd9b459a000 rw-p 00009000 08:01 49406
/lib64/libcrypt-2.7.so
7fd9b459a000-7fd9b45c8000 rw-p 7fd9b459a000 00:00 0
7fd9b45c8000-7fd9b45ca000 r-xp 00000000 08:01 49367
/lib64/libdl-2.7.so
7fd9b45ca000-7fd9b47ca000 —p 00002000 08:01 49367
/lib64/libdl-2.7.so
7fd9b47ca000-7fd9b47cb000 r–p 00002000 08:01 49367
/lib64/libdl-2.7.so
7fd9b47cb000-7fd9b47cc000 rw-p 00003000 08:01 49367
/lib64/libdl-2.7.so
7fd9b47cc000-7fd9b47d4000 r-xp 00000000 08:01 49422
/lib64/librt-2.7.so
7fd9b47d4000-7fd9b49d3000 —p 00008000 08:01 49422
/lib64/librt-2.7.so
7fd9b49d3000-7fd9b49d4000 r–p 00007000 08:01 49422
/lib64/librt-2.7.so
7fd9b49d4000-7fd9b49d5000 rw-p 00008000 08:01 49422
/lib64/librt-2.7.so
7fd9b49d5000-7fd9b49f0000 r-xp 00000000 08:01 49185
/lib64/ld-2.7.so
7fd9b4a7b000-7fd9b4bd8000 rw-p 7fd9b4a7b000 00:00 0
7fd9b4bed000-7fd9b4bef000 rw-p 7fd9b4bed000 00:00 0
7fd9b4bef000-7fd9b4bf0000 r–p 0001a000 08:01 49185
/lib64/ld-2.7.so
7fd9b4bf0000-7fd9b4bf1000 rw-p 0001b000 08:01 49185
/lib64/ld-2.7.so
7fffbcbda000-7fffbcbf0000 rw-p 7ffffffe9000 00:00 0
[stack]
7fffbcbfe000-7fffbcc00000 r-xp 7fffbcbfe000 00:00 0
[vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0
[vsyscall]
Aborted

On 2009-10-16, Steven P. [email protected] wrote:

but when I run it i get an error: any ideas? i have’t seen anything like
this before…

*** glibc detected *** ruby: malloc(): memory corruption:
0x000000000099d890 ***

This means that there is a bug somewhere in some code (probably, but
not necessarily, in libMagicCore.so.2) which is corrupting allocated
space in some way – writing past the end or beginning of an allocated
block, trying to free something that wasn’t a pointer provided by
malloc,
or whatever.

Note that the point of detection is not necessarily the point at which
the corruption was initiated.

The last time I had something similar to this, I did an experiment: I
disabled the garbage collector during a small hunk of code, and the
problem
went away. That was enough to let me track down a bug in a ruby gem
which could result in access to previously-garbage collected hunks of
memory.

-s

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs