[Win32utils-devel] [ win32utils-Bugs-10589 ] Bug in win32-mmap
noreply at rubyforge.org
noreply at rubyforge.org
Wed May 16 12:58:31 EDT 2007
Bugs item #10589, was opened at 2007-05-04 12:01
You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=411&aid=10589&group_id=85
Category: win32-mmap
Group: Code
>Status: Closed
>Resolution: Accepted
Priority: 3
Submitted By: Daniel Berger (djberg96)
Assigned to: Daniel Berger (djberg96)
Summary: Bug in win32-mmap
Initial Comment:
Ruby 1.8.6
win32-mmap 0.2.1
Assigning the value 0 to a dynamic setter causes the corresponding getter to fail. This small script demonstrates the problem:
require 'win32/mmap'
include Win32
mm = MMap.new(:size => 1024, :name => 'test')
mm.gvalue = 0
p mm.gvalue
mm.close
The result is:
C:/ruby/lib/ruby/gems/1.8/gems/win32-mmap-0.2.0/lib/win32/mmap.rb:335:in `load': marshal data too short (ArgumentError)
from C:/ruby/lib/ruby/gems/1.8/gems/win32-mmap-0.2.0/lib/win32/mmap.rb:335:in `method_missing'
from mmap_test.rb:6
----------------------------------------------------------------------
>Comment By: Daniel Berger (djberg96)
Date: 2007-05-16 09:58
Message:
Thanks, that was it!
Dan
----------------------------------------------------------------------
Comment By: Park Heesob (phasis68)
Date: 2007-05-16 09:03
Message:
I wish this is the right solution:
marshal = memcpy(buf, @address, @size)
should be
memcpy(buf, @address, @size)
marshal = buf
Regards,
Park Heesob
----------------------------------------------------------------------
Comment By: Daniel Berger (djberg96)
Date: 2007-05-16 00:58
Message:
I added the explicit "\0" in CVS, but then I noticed that it fails elsewhere:
mm = Win32::MMap.new(:size => 24, :name => 'test')
mm.bar = 7
mm.baz = 0
p mm.bar # Boom!
p mm.baz
mm.close
mmap.rb:336:in `load': marshal data too short (ArgumentError)
from mmap.rb:336:in `method_missing'
from mmap.rb:399
----------------------------------------------------------------------
Comment By: Park Heesob (phasis68)
Date: 2007-05-10 08:57
Message:
It's because the return type of the MemcpyXXX is 'P'.
Quick and dirty solution is like this:
marshal = memcpy(buf, @address, @size) + "\0"
Regards,
Park Heesob
----------------------------------------------------------------------
Comment By: Daniel Berger (djberg96)
Date: 2007-05-07 20:47
Message:
(FYI to myself)
This is caused by memcpy() truncating marshalled data that ends with "\000" because it treats it as a null. One solution might be to use wmemcpy() instead, but I'm not sure how to get at that function, since msvcrt doesn't appear to export it.
----------------------------------------------------------------------
You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=411&aid=10589&group_id=85
More information about the win32utils-devel
mailing list