[Win32utils-devel] win32-dir, unicode

Daniel Berger djberg96 at gmail.com
Sun May 28 09:39:52 EDT 2006

Heesob Park wrote:
> Hi,
> 2006/5/28, Daniel Berger <djberg96 at gmail.com>:
>> Heesob Park wrote:
>>> Hi,
> <snip>
>> 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?

To add even more mystery to this problem, that code isn't segfaulting 
for me at the moment, though it was regularly last night (I still have 
the console window open that shows the segfaults to prove it to myself).

I saw the same behavior you mentioned - inserting a 'puts' would 
sometimes cause code that was previously segfaulting to suddenly work.

Well, let's put the Unicode stuff on hold for now.  Perhaps deep 
inspection of string.c some day will reveal what the potential problem is.

Many thanks,


More information about the win32utils-devel mailing list