[Win32utils-devel] win32-dir, unicode

Heesob Park phasis at gmail.com
Sun May 28 03:50:33 EDT 2006


2006/5/28, Daniel Berger <djberg96 at gmail.com>:
> Heesob Park wrote:
> > Hi,
> Thanks Heesob, but I'm getting some weird segfaults with wide character
> functions and buffers over 245 characters.  I posted about this to
> ruby-talk as well.  Here's some sample code that demonstrates the problem:
> require 'Win32API'
> GetFullPathNameW = Win32API.new('kernel32', 'GetFullPathNameW', 'PLPP', 'L')
> path = "C:\\test"
> buf  = 0.chr * 260 # 245 or less works ok
> if GetFullPathNameW.call(path, buf.size, buf, 0) == 0
>    puts "Failed"
>    exit
> end
> p buf.split("\0\0").first # BOOM!
> I'm not sure what the significance of 245 or less is.  I can inspect
> 'buf', copy and paste it to a separate editor as a string and run ops on
> it with no problem, so I'm very curious as to what's making Ruby segfault.
I'm very curious too.

Your sample code don't segfault.
But I came across segfaults several times in modifing create_junction method.
It's behaviour is very unstable, as I insert p method,it sometimes runs OK.
It's location was mainly split method or get_last_error method.

I guess it's not related with 245 or 260, but it seems to underlying C
pointer memory access failure problem.
Can you give me a sample stable segfault generating code?


Park Heesob

More information about the win32utils-devel mailing list