Forum: Ruby-core [ruby-trunk - Bug #7721][Open] test_too_long_path2(TestProcess) fails on mingw32

Posted by Heesob Park (phasis)
on 2013-01-22 02:35
(Received via mailing list)
Issue #7721 has been reported by phasis68 (Heesob Park).

----------------------------------------
Bug #7721: test_too_long_path2(TestProcess) fails on mingw32
https://bugs.ruby-lang.org/issues/7721

Author: phasis68 (Heesob Park)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 2.0.0dev (2013-01-21 trunk 38892) [i386-mingw32]


[ 6319/11317] TestProcess#test_too_long_path2Microsoft Windows [Version 
6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\work\snapshot-mg32>exit
 = 8.03 s
 33) Failure:
test_too_long_path2(TestProcess) 
[C:/work/snapshot-mg32/test/ruby/test_process.rb:1393]:
[ruby-core:34833].
[Errno::ENOENT, Errno::E2BIG] expected but nothing was raised.

This failure is also mentioned at 
https://bugs.ruby-lang.org/issues/7710#note-3
Posted by Heesob Park (phasis)
on 2013-01-22 02:51
(Received via mailing list)
Issue #7721 has been updated by phasis68 (Heesob Park).


After some inspections, I found this failure occurs not on a very long 
path but on a sufficiently long path with many preloaded test sets.

On such a condition, acp_to_wstr or mbstr_to_wstr function returns NULL 
with the failure of malloc.

Here is a workaround patch:
diff --git a/win32.c b/win32.c.new
index 3b82766..4822f63 100644
--- a/win32.c
+++ b/win32.c.new
@@ -1126,7 +1126,7 @@ CreateChild(const WCHAR *cmd, const WCHAR *prog, 
SECURITY_ATTRIBUTES *psa,

     dwCreationFlags |= NORMAL_PRIORITY_CLASS;

-    if (lstrlenW(cmd) > 32767) {
+    if (cmd==NULL || lstrlenW(cmd) > 32767) {
   child->pid = 0;    /* release the slot */
   errno = E2BIG;
   return NULL;

----------------------------------------
Bug #7721: test_too_long_path2(TestProcess) fails on mingw32
https://bugs.ruby-lang.org/issues/7721#change-35521

Author: phasis68 (Heesob Park)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 2.0.0dev (2013-01-21 trunk 38892) [i386-mingw32]


[ 6319/11317] TestProcess#test_too_long_path2Microsoft Windows [Version 
6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\work\snapshot-mg32>exit
 = 8.03 s
 33) Failure:
test_too_long_path2(TestProcess) 
[C:/work/snapshot-mg32/test/ruby/test_process.rb:1393]:
[ruby-core:34833].
[Errno::ENOENT, Errno::E2BIG] expected but nothing was raised.

This failure is also mentioned at 
https://bugs.ruby-lang.org/issues/7710#note-3
Posted by jonforums (Jon Forums) (Guest)
on 2013-01-22 18:54
(Received via mailing list)
Issue #7721 has been updated by jonforums (Jon Forums).


Nice `Process.spawn` spelunking.

The patch also works for me on Win7 32bit with mingw-w64 4.7.2 on `ruby 
2.0.0dev (2013-01-22 trunk 38896) [i386-mingw32]`
----------------------------------------
Bug #7721: test_too_long_path2(TestProcess) fails on mingw32
https://bugs.ruby-lang.org/issues/7721#change-35530

Author: phasis68 (Heesob Park)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 2.0.0dev (2013-01-21 trunk 38892) [i386-mingw32]


[ 6319/11317] TestProcess#test_too_long_path2Microsoft Windows [Version 
6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\work\snapshot-mg32>exit
 = 8.03 s
 33) Failure:
test_too_long_path2(TestProcess) 
[C:/work/snapshot-mg32/test/ruby/test_process.rb:1393]:
[ruby-core:34833].
[Errno::ENOENT, Errno::E2BIG] expected but nothing was raised.

This failure is also mentioned at 
https://bugs.ruby-lang.org/issues/7710#note-3
Posted by Heesob Park (phasis)
on 2013-01-23 07:16
(Received via mailing list)
Issue #7721 has been updated by phasis68 (Heesob Park).


This bug is not solved with changeset r38904.

There are some warnings.

compiling win32/win32.c
win32/win32.c: In function 'rb_w32_aspawn_flags':
win32/win32.c:1296:14: warning: 'ret' may be used uninitialized in this 
function

win32/win32.c: In function 'rb_w32_spawn':
win32/win32.c:1187:14: warning: 'ret' may be used uninitialized in this 
function

win32/win32.c: In function 'rb_w32_aspawn_flags.clone.8':
win32/win32.c:1296:14: warning: 'ret' may be used uninitialized in this 
function


And the test still fails.

 19) Failure:
test_too_long_path2(TestProcess) 
[C:/work/snapshot-mg32/test/ruby/test_process.rb:1393]:
[ruby-core:34833].
[Errno::ENOENT, Errno::E2BIG] expected but nothing was raised.

Here is a patch:
diff --git a/win32.c b/win32.c.new
index 8b577ea..984e03b 100644
--- a/win32.c
+++ b/win32.c.new
@@ -1184,7 +1184,7 @@ rb_w32_spawn(int mode, const char *cmd, const char 
*prog)
     const char *shell = NULL;
     WCHAR *wcmd = NULL, *wshell = NULL;
     int e = 0;
-    rb_pid_t ret;
+    rb_pid_t ret = -1;
     VALUE v = 0;
     VALUE v2 = 0;

@@ -1293,7 +1293,7 @@ rb_w32_aspawn_flags(int mode, const char *prog, 
char *const *argv, DWORD flags)
     char *cmd, fbuf[MAXPATHLEN];
     WCHAR *wcmd = NULL, *wprog = NULL;
     int e = 0;
-    rb_pid_t ret;
+    rb_pid_t ret = -1;
     VALUE v = 0;

     if (check_spawn_mode(mode)) return -1;

----------------------------------------
Backport #7721: test_too_long_path2(TestProcess) fails on mingw32
https://bugs.ruby-lang.org/issues/7721#change-35539

Author: phasis68 (Heesob Park)
Status: Assigned
Priority: Normal
Assignee: usa (Usaku NAKAMURA)
Category:
Target version:


[ 6319/11317] TestProcess#test_too_long_path2Microsoft Windows [Version 
6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\work\snapshot-mg32>exit
 = 8.03 s
 33) Failure:
test_too_long_path2(TestProcess) 
[C:/work/snapshot-mg32/test/ruby/test_process.rb:1393]:
[ruby-core:34833].
[Errno::ENOENT, Errno::E2BIG] expected but nothing was raised.

This failure is also mentioned at 
https://bugs.ruby-lang.org/issues/7710#note-3
Posted by Luis Lavena (luislavena)
on 2013-01-23 11:52
(Received via mailing list)
Issue #7721 has been updated by luislavena (Luis Lavena).

Assignee changed from usa (Usaku NAKAMURA) to nobu (Nobuyoshi Nakada)
% Done changed from 100 to 50

I can confirm, test still fails:

http://ci.rubyinstaller.org/job/ruby-trunk-x86-tes...

test_too_long_path2(TestProcess) 
[C:/Users/Worker/Jenkins/workspace/ruby-trunk-x86-build/test/ruby/test_process.rb:1393]:
[ruby-core:34833].
[Errno::ENOENT, Errno::E2BIG] exception expected, not
Class: <NoMemoryError>
Message: <"failed to allocate memory">
---Backtrace---
C:/Users/Worker/Jenkins/workspace/ruby-trunk-x86-build/test/ruby/test_process.rb:1393:in 
`initialize'
C:/Users/Worker/Jenkins/workspace/ruby-trunk-x86-build/test/ruby/test_process.rb:1393:in 
`spawn'
C:/Users/Worker/Jenkins/workspace/ruby-trunk-x86-build/test/ruby/test_process.rb:1393:in 
`block in test_too_long_path2'
---------------

----------------------------------------
Backport #7721: test_too_long_path2(TestProcess) fails on mingw32
https://bugs.ruby-lang.org/issues/7721#change-35548

Author: phasis68 (Heesob Park)
Status: Assigned
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category:
Target version:


[ 6319/11317] TestProcess#test_too_long_path2Microsoft Windows [Version 
6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\work\snapshot-mg32>exit
 = 8.03 s
 33) Failure:
test_too_long_path2(TestProcess) 
[C:/work/snapshot-mg32/test/ruby/test_process.rb:1393]:
[ruby-core:34833].
[Errno::ENOENT, Errno::E2BIG] expected but nothing was raised.

This failure is also mentioned at 
https://bugs.ruby-lang.org/issues/7710#note-3
Posted by Heesob Park (phasis)
on 2013-01-24 08:40
(Received via mailing list)
Issue #7721 has been updated by phasis68 (Heesob Park).


The NoMemoryError is raised from rb_syserr_new_str call in 
make_errno_exc_str function with too long path string.

Here is a patch:
diff --git a/error.c b/error.c.new
index 481c117..c26feff 100644
--- a/error.c
+++ b/error.c.new
@@ -1859,6 +1859,9 @@ make_errno_exc_str(VALUE mesg)
 {
     int n = errno;

+#ifdef E2BIG
+    if (n == E2BIG) mesg = Qnil;
+#endif
     errno = 0;
     if (!mesg) mesg = Qnil;
     if (n == 0) {

----------------------------------------
Bug #7721: test_too_long_path2(TestProcess) fails on mingw32
https://bugs.ruby-lang.org/issues/7721#change-35574

Author: phasis68 (Heesob Park)
Status: Assigned
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category:
Target version:
ruby -v:


[ 6319/11317] TestProcess#test_too_long_path2Microsoft Windows [Version 
6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\work\snapshot-mg32>exit
 = 8.03 s
 33) Failure:
test_too_long_path2(TestProcess) 
[C:/work/snapshot-mg32/test/ruby/test_process.rb:1393]:
[ruby-core:34833].
[Errno::ENOENT, Errno::E2BIG] expected but nothing was raised.

This failure is also mentioned at 
https://bugs.ruby-lang.org/issues/7710#note-3
Posted by Nobuyoshi Nakada (nobu)
on 2013-01-25 03:42
(Received via mailing list)
Issue #7721 has been updated by nobu (Nobuyoshi Nakada).

File 0001-error.c-defer-error-message.patch added
ruby -v set to 38934

NoMemoryError could occur at many places, almostly everywhere creating
a new object, adding a new instance variable, growing up a container
object, etc.  It's just rare in normal cases.

r30682 reduced the sizes from 100MB to 10MB because NoMemoryError is
not intended, but test_too_long_path2 is still consuming double of
test_too_long_path.

I fix these tests instead for the time being.

Another strategy is, similar to NameError::message, keeping the given
parameters untouched and defer generating the message until to_s is
called.  But it's complex considering Marshal.

----------------------------------------
Bug #7721: test_too_long_path2(TestProcess) fails on mingw32
https://bugs.ruby-lang.org/issues/7721#change-35587

Author: phasis68 (Heesob Park)
Status: Closed
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category:
Target version:
ruby -v: 38934


[ 6319/11317] TestProcess#test_too_long_path2Microsoft Windows [Version 
6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\work\snapshot-mg32>exit
 = 8.03 s
 33) Failure:
test_too_long_path2(TestProcess) 
[C:/work/snapshot-mg32/test/ruby/test_process.rb:1393]:
[ruby-core:34833].
[Errno::ENOENT, Errno::E2BIG] expected but nothing was raised.

This failure is also mentioned at 
https://bugs.ruby-lang.org/issues/7710#note-3
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.