ConnorAtherton / rb-readline

Pure-Ruby Readline Implementation
BSD 3-Clause "New" or "Revised" License
248 stars 54 forks source link

Segfaults on Win64 #99

Open gix opened 10 years ago

gix commented 10 years ago

With a 64-bit Windows build of Ruby (ruby 2.1.0p0 (2013-12-25 revision 44422) [x64-mswin64_120]), just starting irb segfaults when calling GetConsoleScreenBufferInfo.

The Fiddle signatures for winapi calls are wrong. They treat pointers and handles as 32-bit values: Parameters are declared using "L" (long) but should be "P", and an "S" parameter pointer is unpacked using "l!" but should use "q!".

luislavena commented 10 years ago

I personally don't have a mswin build, can you reproduce this with mingw-w64 one?

Patches to correct this are welcome :-)

Sorry for top posting. Sent from mobile. On Jan 10, 2014 12:13 PM, "Nico Rieck" notifications@github.com wrote:

With a 64-bit Windows build of Ruby (ruby 2.1.0p0 (2013-12-25 revision 44422) [x64-mswin64_120]), just starting irb segfaults when calling GetConsoleScreenBufferInfo.

The Fiddle signatures for winapi calls are wrong. They treat pointers and handles as 32-bit values: Parameters are declared using "L" (long) but should be "P", and an "S" parameter pointer is unpacked using "l!" but should use "q!".

— Reply to this email directly or view it on GitHubhttps://github.com/luislavena/rb-readline/issues/99 .

phasis68 commented 10 years ago

This is Windows 8 and x64-mswin64 specific issue. You should use DL::PackInfo::PACK_MAP[DL::TYPE_VOIDP] instead of "l!" Refer to https://bugs.ruby-lang.org/issues/7492

gix commented 10 years ago

I couldn't reproduce it fully with a 64-bit RubyInstaller, but it was only 2.0.0.

I've fixed it in #100 and the test suite completes with my above mentioned ruby and "ruby 2.0.0p353 (2013-11-22) [x64-mingw32]".