From: "U.Nakamura" Date: 2012-04-27T13:00:06+09:00 Subject: [ruby-core:44674] Re: [ruby-trunk - Bug #6364] Segmentation fault happend when running test_cptr.rb Hello, In message "[ruby-core:44651] [ruby-trunk - Bug #6364] Segmentation fault happend when running test_cptr.rb" on Apr.26,2012 23:41:32, wrote: > Here is the log. I wrote a small C to invoke the fread within msvcrt.dll via libffi, but it works fine. Thank you! I've finally gotten the solution of this problem. There are many traps. 1st, yes, DL is replaced when fiddle is available, but it is not so about DL::CPtr and DL::CFunc. 2nd, with MSVCR100.dll, this problem did not occur. I tested with x64-mswin64_100, so I could not reproduce. So I thought that this is peculiar to mingw, but it was because the difference between versions of MSVCRT. The cause was passing a wrong value as the file pointer. On most platforms Ruby supports, a pointer has same width as unsigned long. It is known well that the almost only one exception is Win64. When DL::CFunc converts DL::CPtr to C pointer, DL::CFunc used rb_big2ulong_pack(). On Win64 it means ommiting higher 32bits. But since Win64 mostly uses the domain of 32 bits, this problem did not actualize. Regards, -- U.Nakamura