Description:
|
JVM exits with an error after doing a series of malloc & free calls.
This program illustrates the problem.
require 'rubygems'
require 'ffi'
module LibC
extend FFI::Library
library = ffi_lib(FFI::Library::LIBC).first
attach_function :malloc, [:size_t], :pointer
attach_function :free, [:pointer], :void
end # module LibC
def blowup(string)
pointer = LibC.malloc(string.size)
pointer.write_string(string)
- call to #free causes jvm to exit
LibC.free(pointer)
end
1_000.times do |i|
string = 'a' * i
print "#{i}, "
blowup(string)
end
jruby z.rb
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, java(28463,0x100601000) malloc: *** error for object 0x101a2b320: incorrect checksum for freed object - object was probably modified after being freed.
-
-
- set a breakpoint in malloc_error_break to debug
Abort trap
|