Project

General

Profile

Backport #7379

Unexpected result of Kernel#gets on Windows 8

Added by phasis68 (Heesob Park) almost 7 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
[ruby-core:49479]

Description

I found Kernel#gets returns invalid result for multi-byte string on Windows 8.

C:\Users\phasis>ruby -ve 'p gets'
ruby 2.0.0dev (2012-11-17 trunk 37691) [i386-mswin32_110]
한글
"\xC7\x00\xB1\x00\n"

After some debugging,I noticed that the previous ReadFile bug on console was fixed on Windows 8.
So the workaround code should be skipped on Windows 8.

Here is a patch:
cf. The OS version number of Windows 8 and Windows Server 2012 is 6.2.

diff --git a/win32.c b/win32.c.new
index 3446728..5635058 100644
--- a/win32.c
+++ b/win32.c.new
@@ -5902,7 +5902,7 @@ rb_w32_read(int fd, void *buf, size_t size)
}

 ret = 0;
  • isconsole = is_console(_osfhnd(fd));
  • isconsole = is_console(_osfhnd(fd)) && !(osver.dwMajorVersion==6 && osver.dwMinorVersion==2); if (isconsole) { DWORD mode; GetConsoleMode((HANDLE)_osfhnd(fd),&mode);

Associated revisions

Revision 0c3d9675
Added by usa (Usaku NAKAMURA) almost 7 years ago

  • win32/win32.c (rb_w32_read): Windows 8 fixed one of a bug of console API. based on the patch by Heesob Park at [ruby-core:49479] [Bug #7379]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 37743
Added by usa (Usaku NAKAMURA) almost 7 years ago

  • win32/win32.c (rb_w32_read): Windows 8 fixed one of a bug of console API. based on the patch by Heesob Park at [ruby-core:49479] [Bug #7379]

Revision 37743
Added by usa (Usaku NAKAMURA) almost 7 years ago

  • win32/win32.c (rb_w32_read): Windows 8 fixed one of a bug of console API. based on the patch by Heesob Park at [ruby-core:49479] [Bug #7379]

Revision 37743
Added by usa (Usaku NAKAMURA) almost 7 years ago

  • win32/win32.c (rb_w32_read): Windows 8 fixed one of a bug of console API. based on the patch by Heesob Park at [ruby-core:49479] [Bug #7379]

Revision 37743
Added by usa (Usaku NAKAMURA) almost 7 years ago

  • win32/win32.c (rb_w32_read): Windows 8 fixed one of a bug of console API. based on the patch by Heesob Park at [ruby-core:49479] [Bug #7379]

Revision 37743
Added by usa (Usaku NAKAMURA) almost 7 years ago

  • win32/win32.c (rb_w32_read): Windows 8 fixed one of a bug of console API. based on the patch by Heesob Park at [ruby-core:49479] [Bug #7379]

Revision 37743
Added by usa (Usaku NAKAMURA) almost 7 years ago

  • win32/win32.c (rb_w32_read): Windows 8 fixed one of a bug of console API. based on the patch by Heesob Park at [ruby-core:49479] [Bug #7379]

Revision dbe75ed4
Added by usa (Usaku NAKAMURA) over 6 years ago

merge revision(s) 37743: [Backport #7379]

    * win32/win32.c (rb_w32_read): Windows 8 fixed one of a bug of console
      API.
      based on the patch by Heesob Park at [ruby-core:49479] [Bug #7379]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@40051 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 40051
Added by usa (Usaku NAKAMURA) over 6 years ago

merge revision(s) 37743: [Backport #7379]

* win32/win32.c (rb_w32_read): Windows 8 fixed one of a bug of console
  API.
  based on the patch by Heesob Park at [ruby-core:49479] [Bug #7379]

History

Updated by luislavena (Luis Lavena) almost 7 years ago

  • Category set to core
  • Status changed from Open to Assigned
  • Assignee set to usa (Usaku NAKAMURA)
  • Target version set to 2.0.0

Hello Park,

I don't have Windows 8 right now to test, but is great to hear this got fixed (finally).

I'm assigning to Nakamura-san for approval.

Thank you.

Updated by usa (Usaku NAKAMURA) almost 7 years ago

I don't have Win8, too.
But, I rely Park-san.

Haven't you be a committer yet, Park-san?

Updated by phasis68 (Heesob Park) almost 7 years ago

Is there anybody who has Windows 8 among committers?

As I mentioned at http://bugs.ruby-lang.org/issues/7352,
I don't want to be a committer.

Updated by luislavena (Luis Lavena) almost 7 years ago

On Mon, Nov 19, 2012 at 9:56 AM, phasis68 (Heesob Park)
phasis@gmail.com wrote:

Issue #7379 has been updated by phasis68 (Heesob Park).

Is there anybody who has Windows 8 among committers?

I don't have Windows 8 final right now to test, but I do have a
previous version, which I'm setting up in a VM.

Will take a look later today.

As I mentioned at http://bugs.ruby-lang.org/issues/7352,
I don't want to be a committer.


Bug #7379: Unexpected result of Kernel#gets on Windows 8
https://bugs.ruby-lang.org/issues/7379#change-33096

Author: phasis68 (Heesob Park)
Status: Assigned
Priority: Normal
Assignee: usa (Usaku NAKAMURA)
Category: core
Target version: 2.0.0
ruby -v: ruby 2.0.0dev (2012-11-17 trunk 37691) [i386-mswin32_110]

I found Kernel#gets returns invalid result for multi-byte string on Windows 8.

C:\Users\phasis>ruby -ve 'p gets'
ruby 2.0.0dev (2012-11-17 trunk 37691) [i386-mswin32_110]
한글
"\xC7\x00\xB1\x00\n"

After some debugging,I noticed that the previous ReadFile bug on console was fixed on Windows 8.
So the workaround code should be skipped on Windows 8.

Here is a patch:
cf. The OS version number of Windows 8 and Windows Server 2012 is 6.2.

diff --git a/win32.c b/win32.c.new
index 3446728..5635058 100644
--- a/win32.c
+++ b/win32.c.new
@@ -5902,7 +5902,7 @@ rb_w32_read(int fd, void *buf, size_t size)
}

 ret = 0;
  • isconsole = is_console(_osfhnd(fd));
  • isconsole = is_console(_osfhnd(fd)) && !(osver.dwMajorVersion==6 && osver.dwMinorVersion==2); if (isconsole) { DWORD mode; GetConsoleMode((HANDLE)_osfhnd(fd),&mode);

--
http://bugs.ruby-lang.org/

--
Luis Lavena
AREA 17
-
Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry

Updated by usa (Usaku NAKAMURA) almost 7 years ago

The priority of Windows8 was not so high for me.
However, it seems that it is necessary to change the priority.
I did not expect that Microsoft corrected the bug of console API now :)

#6

Updated by usa (Usaku NAKAMURA) almost 7 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r37743.
Heesob, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • win32/win32.c (rb_w32_read): Windows 8 fixed one of a bug of console API. based on the patch by Heesob Park at [ruby-core:49479] [Bug #7379]
#7

Updated by usa (Usaku NAKAMURA) over 6 years ago

  • Tracker changed from Bug to Backport
  • Project changed from Ruby master to Backport193
  • Category deleted (core)
  • Status changed from Closed to Assigned
  • Target version deleted (2.0.0)

See [ruby-list:49247]

#8

Updated by usa (Usaku NAKAMURA) over 6 years ago

  • Status changed from Assigned to Closed

This issue was solved with changeset r40051.
Heesob, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


merge revision(s) 37743: [Backport #7379]

* win32/win32.c (rb_w32_read): Windows 8 fixed one of a bug of console
  API.
  based on the patch by Heesob Park at [ruby-core:49479] [Bug #7379]

Also available in: Atom PDF