https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112013-01-22T10:51:04ZRuby Issue Tracking SystemRuby master - Bug #7721: test_too_long_path2(TestProcess) fails on mingw32https://bugs.ruby-lang.org/issues/7721?journal_id=355212013-01-22T10:51:04Zphasis68 (Heesob Park)phasis@gmail.com
<ul></ul><p>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.</p>
<p>On such a condition, acp_to_wstr or mbstr_to_wstr function returns NULL with the failure of malloc.</p>
<p>Here is a workaround patch:<br>
diff --git a/win32.c b/win32.c.new<br>
index 3b82766..4822f63 100644<br>
--- a/win32.c<br>
+++ b/win32.c.new<br>
@@ -1126,7 +1126,7 @@ CreateChild(const WCHAR *cmd, const WCHAR *prog, SECURITY_ATTRIBUTES *psa,</p>
<pre><code> dwCreationFlags |= NORMAL_PRIORITY_CLASS;
</code></pre>
<ul>
<li>if (lstrlenW(cmd) > 32767) {</li>
</ul>
<ul>
<li>if (cmd==NULL || lstrlenW(cmd) > 32767) {<br>
child->pid = 0; /* release the slot */<br>
errno = E2BIG;<br>
return NULL;</li>
</ul> Ruby master - Bug #7721: test_too_long_path2(TestProcess) fails on mingw32https://bugs.ruby-lang.org/issues/7721?journal_id=355302013-01-23T02:53:50Zjonforums (Jon Forums)
<ul></ul><p>Nice <code>Process.spawn</code> spelunking.</p>
<p>The patch also works for me on Win7 32bit with mingw-w64 4.7.2 on <code>ruby 2.0.0dev (2013-01-22 trunk 38896) [i386-mingw32]</code></p> Ruby master - Bug #7721: test_too_long_path2(TestProcess) fails on mingw32https://bugs.ruby-lang.org/issues/7721?journal_id=355362013-01-23T12:28:31Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li></ul><p>This issue was solved with changeset r38904.<br>
Heesob, thank you for reporting this issue.<br>
Your contribution to Ruby is greatly appreciated.<br>
May Ruby be with you.</p>
<hr>
<p>win32.c: acp_to_wstr results check</p>
<ul>
<li>win32/win32.c (rb_w32_spawn, rb_w32_aspawn_flags): check the results<br>
of acp_to_wstr() which can return NULL. <a href="/issues/7721">[ruby-core:51557]</a> [Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: test_too_long_path2(TestProcess) fails on mingw32 (Closed)" href="https://bugs.ruby-lang.org/issues/7721">#7721</a>]</li>
</ul> Ruby master - Bug #7721: test_too_long_path2(TestProcess) fails on mingw32https://bugs.ruby-lang.org/issues/7721?journal_id=355372013-01-23T12:29:35Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Tracker</strong> changed from <i>Bug</i> to <i>Backport</i></li><li><strong>Project</strong> changed from <i>Ruby master</i> to <i>Backport193</i></li><li><strong>Status</strong> changed from <i>Closed</i> to <i>Assigned</i></li><li><strong>Assignee</strong> set to <i>usa (Usaku NAKAMURA)</i></li></ul> Ruby master - Bug #7721: test_too_long_path2(TestProcess) fails on mingw32https://bugs.ruby-lang.org/issues/7721?journal_id=355392013-01-23T15:16:16Zphasis68 (Heesob Park)phasis@gmail.com
<ul></ul><p>This bug is not solved with changeset r38904.</p>
<p>There are some warnings.</p>
<p>compiling win32/win32.c<br>
win32/win32.c: In function 'rb_w32_aspawn_flags':<br>
win32/win32.c:1296:14: warning: 'ret' may be used uninitialized in this function</p>
<p>win32/win32.c: In function 'rb_w32_spawn':<br>
win32/win32.c:1187:14: warning: 'ret' may be used uninitialized in this function</p>
<p>win32/win32.c: In function 'rb_w32_aspawn_flags.clone.8':<br>
win32/win32.c:1296:14: warning: 'ret' may be used uninitialized in this function</p>
<p>And the test still fails.</p>
<ol start="19">
<li>Failure:<br>
test_too_long_path2(TestProcess) [C:/work/snapshot-mg32/test/ruby/test_process.rb:1393]:<br>
<a href="/issues/4315">[ruby-core:34833]</a>.<br>
[Errno::ENOENT, Errno::E2BIG] expected but nothing was raised.</li>
</ol>
<p>Here is a patch:<br>
diff --git a/win32.c b/win32.c.new<br>
index 8b577ea..984e03b 100644<br>
--- a/win32.c<br>
+++ b/win32.c.new<br>
@@ -1184,7 +1184,7 @@ rb_w32_spawn(int mode, const char *cmd, const char *prog)<br>
const char *shell = NULL;<br>
WCHAR *wcmd = NULL, *wshell = NULL;<br>
int e = 0;</p>
<ul>
<li>rb_pid_t ret;</li>
</ul>
<ul>
<li>rb_pid_t ret = -1;<br>
VALUE v = 0;<br>
VALUE v2 = 0;</li>
</ul>
<p>@@ -1293,7 +1293,7 @@ rb_w32_aspawn_flags(int mode, const char *prog, char *const *argv, DWORD flags)<br>
char *cmd, fbuf[MAXPATHLEN];<br>
WCHAR *wcmd = NULL, *wprog = NULL;<br>
int e = 0;</p>
<ul>
<li>rb_pid_t ret;</li>
</ul>
<ul>
<li>
<p>rb_pid_t ret = -1;<br>
VALUE v = 0;</p>
<p>if (check_spawn_mode(mode)) return -1;</p>
</li>
</ul> Ruby master - Bug #7721: test_too_long_path2(TestProcess) fails on mingw32https://bugs.ruby-lang.org/issues/7721?journal_id=355482013-01-23T19:52:15Zluislavena (Luis Lavena)luislavena@gmail.com
<ul><li><strong>Assignee</strong> changed from <i>usa (Usaku NAKAMURA)</i> to <i>nobu (Nobuyoshi Nakada)</i></li><li><strong>% Done</strong> changed from <i>100</i> to <i>50</i></li></ul><p>I can confirm, test still fails:</p>
<p><a href="http://ci.rubyinstaller.org/job/ruby-trunk-x86-test-all/703/console" class="external">http://ci.rubyinstaller.org/job/ruby-trunk-x86-test-all/703/console</a></p>
<h2>test_too_long_path2(TestProcess) [C:/Users/Worker/Jenkins/workspace/ruby-trunk-x86-build/test/ruby/test_process.rb:1393]:<br>
<a href="/issues/4315">[ruby-core:34833]</a>.<br>
[Errno::ENOENT, Errno::E2BIG] exception expected, not<br>
Class: <br>
Message: <"failed to allocate memory"><br>
---Backtrace---<br>
C:/Users/Worker/Jenkins/workspace/ruby-trunk-x86-build/test/ruby/test_process.rb:1393:in <code>initialize' C:/Users/Worker/Jenkins/workspace/ruby-trunk-x86-build/test/ruby/test_process.rb:1393:in </code>spawn'<br>
C:/Users/Worker/Jenkins/workspace/ruby-trunk-x86-build/test/ruby/test_process.rb:1393:in `block in test_too_long_path2'</h2> Ruby master - Bug #7721: test_too_long_path2(TestProcess) fails on mingw32https://bugs.ruby-lang.org/issues/7721?journal_id=355492013-01-23T19:52:42Zluislavena (Luis Lavena)luislavena@gmail.com
<ul><li><strong>Tracker</strong> changed from <i>Backport</i> to <i>Bug</i></li><li><strong>Project</strong> changed from <i>Backport193</i> to <i>Ruby master</i></li></ul> Ruby master - Bug #7721: test_too_long_path2(TestProcess) fails on mingw32https://bugs.ruby-lang.org/issues/7721?journal_id=355742013-01-24T16:40:18Zphasis68 (Heesob Park)phasis@gmail.com
<ul></ul><p>The NoMemoryError is raised from rb_syserr_new_str call in make_errno_exc_str function with too long path string.</p>
<p>Here is a patch:<br>
diff --git a/error.c b/error.c.new<br>
index 481c117..c26feff 100644<br>
--- a/error.c<br>
+++ b/error.c.new<br>
@@ -1859,6 +1859,9 @@ make_errno_exc_str(VALUE mesg)<br>
{<br>
int n = errno;</p>
<p>+#ifdef E2BIG</p>
<ul>
<li>if (n == E2BIG) mesg = Qnil;<br>
+#endif<br>
errno = 0;<br>
if (!mesg) mesg = Qnil;<br>
if (n == 0) {</li>
</ul> Ruby master - Bug #7721: test_too_long_path2(TestProcess) fails on mingw32https://bugs.ruby-lang.org/issues/7721?journal_id=355862013-01-25T10:37:35Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Closed</i></li><li><strong>% Done</strong> changed from <i>50</i> to <i>100</i></li></ul><p>This issue was solved with changeset r38934.<br>
Heesob, thank you for reporting this issue.<br>
Your contribution to Ruby is greatly appreciated.<br>
May Ruby be with you.</p>
<hr>
<p>test_process.rb: reduce command string size</p>
<ul>
<li>test/ruby/test_process.rb (test_spawn_too_long_path),<br>
(test_aspawn_too_long_path): reduce command string size until<br>
intended exception occurs. <a href="/issues/7721">[ruby-core:51592]</a> [Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: test_too_long_path2(TestProcess) fails on mingw32 (Closed)" href="https://bugs.ruby-lang.org/issues/7721">#7721</a>]</li>
</ul> Ruby master - Bug #7721: test_too_long_path2(TestProcess) fails on mingw32https://bugs.ruby-lang.org/issues/7721?journal_id=355872013-01-25T11:42:10Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>File</strong> <a href="/attachments/3449">0001-error.c-defer-error-message.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/3449/0001-error.c-defer-error-message.patch">0001-error.c-defer-error-message.patch</a> added</li><li><strong>ruby -v</strong> set to <i>38934</i></li></ul><p>NoMemoryError could occur at many places, almostly everywhere creating<br>
a new object, adding a new instance variable, growing up a container<br>
object, etc. It's just rare in normal cases.</p>
<p>r30682 reduced the sizes from 100MB to 10MB because NoMemoryError is<br>
not intended, but test_too_long_path2 is still consuming double of<br>
test_too_long_path.</p>
<p>I fix these tests instead for the time being.</p>
<p>Another strategy is, similar to NameError::message, keeping the given<br>
parameters untouched and defer generating the message until to_s is<br>
called. But it's complex considering Marshal.</p>