Project

General

Profile

Bug #9699

Cannot require .so file on Windows if the file path is unicode (Includes patch)

Added by BugraB (Bugra Barin) over 5 years ago. Updated about 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
cruby-windows
Target version:
ruby -v:
2.0.0 and later
[ruby-core:61845]

Description

It doesn't seem possible to load a C extension that is inside a non-ascii path.
To reproduce:

  • Extract the attached zip file (with a decent unzip program such as 7-zip, that preserves unicode paths)
  • cd to where you extracted
  • launch irb
  • require './foo.rb' (All this does is require a simple so file inside the folder 'てすと')
  • You'll see a failure

The culprit is in function dln_load, it uses the ANSI version of LoadLibrary and passes in the char* path given to the function. My patch converts it to wide char and uses LoadLibraryW. I have assumed that the given path is UTF-8 encoded, which seems to work but I am not sure if this is a safe assumption.

I hope the patch is in the right format, I wasn't sure. Thanks for your time!
Bugra


Files

require_so_bug_win32.zip (16.3 KB) require_so_bug_win32.zip rb and so file to reproduce the issue BugraB (Bugra Barin), 04/03/2014 08:39 PM
dln_load.patch (1.41 KB) dln_load.patch BugraB (Bugra Barin), 04/03/2014 08:41 PM

Related issues

Related to Ruby master - Bug #8676: ruby 2.0 can not require or load the source file with non-ascii path nameClosed07/24/2013Actions

Associated revisions

Revision a237db5c
Added by nobu (Nobuyoshi Nakada) over 5 years ago

dln.c: non-ascii path on Windows

  • dln.c (dln_load): use wchar version to load a library in non-ascii path on Windows. based on the patch by Bugra Barin in [ruby-core:61845]. [Bug #9699]

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

Revision 45523
Added by nobu (Nobuyoshi Nakada) over 5 years ago

dln.c: non-ascii path on Windows

  • dln.c (dln_load): use wchar version to load a library in non-ascii path on Windows. based on the patch by Bugra Barin in [ruby-core:61845]. [Bug #9699]

Revision 45523
Added by nobu (Nobuyoshi Nakada) over 5 years ago

dln.c: non-ascii path on Windows

  • dln.c (dln_load): use wchar version to load a library in non-ascii path on Windows. based on the patch by Bugra Barin in [ruby-core:61845]. [Bug #9699]

Revision 45523
Added by nobu (Nobuyoshi Nakada) over 5 years ago

dln.c: non-ascii path on Windows

  • dln.c (dln_load): use wchar version to load a library in non-ascii path on Windows. based on the patch by Bugra Barin in [ruby-core:61845]. [Bug #9699]

Revision 45523
Added by nobu (Nobuyoshi Nakada) over 5 years ago

dln.c: non-ascii path on Windows

  • dln.c (dln_load): use wchar version to load a library in non-ascii path on Windows. based on the patch by Bugra Barin in [ruby-core:61845]. [Bug #9699]

Revision 45523
Added by nobu (Nobuyoshi Nakada) over 5 years ago

dln.c: non-ascii path on Windows

  • dln.c (dln_load): use wchar version to load a library in non-ascii path on Windows. based on the patch by Bugra Barin in [ruby-core:61845]. [Bug #9699]

Revision 45523
Added by nobu (Nobuyoshi Nakada) over 5 years ago

dln.c: non-ascii path on Windows

  • dln.c (dln_load): use wchar version to load a library in non-ascii path on Windows. based on the patch by Bugra Barin in [ruby-core:61845]. [Bug #9699]

Revision 12285fc1
Added by nagachika (Tomoyuki Chikanaga) about 5 years ago

merge revision(s) r45521,r45523,r45551: [Backport #9699]

    win32.c: wchar conversion

    * win32/win32.c (rb_w32_wstr_to_mbstr, rb_w32_mbstr_to_wstr): make

WCHAR/mb conversion functions public.
* dln.c (dln_load): use wchar version to load a library in
non-ascii path on Windows. based on the patch by Bugra Barin
in [ruby-core:61845]. [Bug #9699]

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

Revision 46450
Added by nagachika (Tomoyuki Chikanaga) about 5 years ago

merge revision(s) r45521,r45523,r45551: [Backport #9699]

win32.c: wchar conversion

* win32/win32.c (rb_w32_wstr_to_mbstr, rb_w32_mbstr_to_wstr): make

WCHAR/mb conversion functions public.
* dln.c (dln_load): use wchar version to load a library in
non-ascii path on Windows. based on the patch by Bugra Barin
in [ruby-core:61845]. [Bug #9699]

History

Updated by nobu (Nobuyoshi Nakada) over 5 years ago

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

Applied in changeset r45523.


dln.c: non-ascii path on Windows

  • dln.c (dln_load): use wchar version to load a library in non-ascii path on Windows. based on the patch by Bugra Barin in [ruby-core:61845]. [Bug #9699]

Updated by thomthom (Thomas Thomassen) over 5 years ago

Can this patch be back ported to Ruby 2.1 or 2.0?

Updated by nagachika (Tomoyuki Chikanaga) over 5 years ago

  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN to 2.0.0: REQUIRED, 2.1: REQUIRED

[for branch maintainers]
r45523 depends on a new function introduced at r45521.
And test script was fixed at r45551.

Updated by nagachika (Tomoyuki Chikanaga) about 5 years ago

  • Backport changed from 2.0.0: REQUIRED, 2.1: REQUIRED to 2.0.0: REQUIRED, 2.1: DONE

r45521, r45523 and r45551 were backported into ruby_2_1 at r46450.

Updated by usa (Usaku NAKAMURA) about 5 years ago

  • Related to Bug #8676: ruby 2.0 can not require or load the source file with non-ascii path name added

Updated by usa (Usaku NAKAMURA) about 5 years ago

memo:
this fix requires at least r42183 (see #8676) for ruby_2_0_0.

Also available in: Atom PDF