https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112009-04-01T07:45:33ZRuby Issue Tracking SystemRuby master - Bug #1342: signal handling on HP-UXhttps://redmine.ruby-lang.org/issues/1342?journal_id=36742009-04-01T07:45:33Zgraza (Graham Agnew)graham.agnew@gmail.com
<ul></ul><p>=begin<br>
I've been looking through the Ruby source code, specifically the Itanium specific code wrapped in "#ifdef __ia64" guards and within the assembly file ia64.s. While I can follow the references to the Intel documentation, it seems that the Itanium code is there to find the position of the register stack. There's also rb_ia64_flushrs in conjunction with setjmp() inside the function rb_gc_save_machine_context.</p>
<p>However looking at the HP documentation, it seems that setjmp an longjmp are not suitable for saving context. Instead getcontext and setontext should be used:</p>
<p><a href="http://h21007.www2.hp.com/portal/site/dspp/menuitem.863c3e4cbcdc3f3515b49c108973a801?ciid=09083a7373f021103a7373f02110275d6e10RCRD" class="external">http://h21007.www2.hp.com/portal/site/dspp/menuitem.863c3e4cbcdc3f3515b49c108973a801?ciid=09083a7373f021103a7373f02110275d6e10RCRD</a></p>
<p>According to the referenced documents, this only applies when performing longjmp across threads, and I can't find any cases in the code where this is happening. At the same time, since setcontext and getcontext seem to be fairly widely available, shouldn't the source code be switched to use those? They seem to be more appropriate for managing context.<br>
=end</p> Ruby master - Bug #1342: signal handling on HP-UXhttps://redmine.ruby-lang.org/issues/1342?journal_id=36752009-04-01T08:14:29Zdaz (Dave B)
<ul></ul><p>=begin<br>
"... since setcontext and getcontext seem to be fairly widely available, shouldn't the source code be switched to use those?"</p>
<p><a href="http://en.wikipedia.org/wiki/Setcontext" class="external">http://en.wikipedia.org/wiki/Setcontext</a></p>
<p>Unknown to Windows (not found in SDK docs).</p>
<p>=end</p> Ruby master - Bug #1342: signal handling on HP-UXhttps://redmine.ruby-lang.org/issues/1342?journal_id=36762009-04-01T08:47:54Zgraza (Graham Agnew)graham.agnew@gmail.com
<ul></ul><p>=begin<br>
Hi Dave,</p>
<p>Granted this won't be available everywhere, however it remains that, setjmp and longjmp are not necessarily appropriate in HP-UX. The man page for setjmp/longjmp on HP-UX has the following:</p>
<blockquote>
<p>The effect of a call to longjmp() where the initialization of the jmp_buf argument was not performed in the calling thread is undefined.</p>
</blockquote>
<p>So where available, shouldn't the getcontext / setcontext routines be used?</p>
<p>Cheers,<br>
Gra.<br>
=end</p> Ruby master - Bug #1342: signal handling on HP-UXhttps://redmine.ruby-lang.org/issues/1342?journal_id=36852009-04-02T04:17:36Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul></ul><p>=begin<br>
Hi,</p>
<p>At Wed, 1 Apr 2009 07:45:15 +0900,<br>
Graham Agnew wrote in <a href="https://blade.ruby-lang.org/ruby-core/23086">[ruby-core:23086]</a>:</p>
<blockquote>
<p>I've been looking through the Ruby source code, specifically<br>
the Itanium specific code wrapped in "#ifdef __ia64" guards<br>
and within the assembly file ia64.s. While I can follow the<br>
references to the Intel documentation, it seems that the<br>
Itanium code is there to find the position of the register<br>
stack. There's also rb_ia64_flushrs in conjunction with<br>
setjmp() inside the function rb_gc_save_machine_context.</p>
</blockquote>
<p>Is it an ia64 specific issue?</p>
<blockquote>
<p>According to the referenced documents, this only applies when<br>
performing longjmp across threads, and I can't find any cases<br>
in the code where this is happening. At the same time, since<br>
setcontext and getcontext seem to be fairly widely available,<br>
shouldn't the source code be switched to use those? They<br>
seem to be more appropriate for managing context.</p>
</blockquote>
<p>It shouldn't jump across threads. And getcontext/setcontext<br>
has significant performance penalty than setjmp/longjmp.</p>
<p>If it is ia64 specific, getcontext/setcontext should be used on<br>
such platforms.</p>
<p>--<br>
Nobu Nakada</p>
<p>=end</p> Ruby master - Bug #1342: signal handling on HP-UXhttps://redmine.ruby-lang.org/issues/1342?journal_id=36872009-04-02T08:15:21Zgraza (Graham Agnew)graham.agnew@gmail.com
<ul></ul><p>=begin<br>
Hi Nakada-san,</p>
<p>The only other environment I've tried so far is AIX and I haven't seen this issue there at all. (But you probably knew that since you responded to my other issue on the Ruby forum. :) ) This problem only happens on HP-UX/Itanium, not AIX.</p>
<p>Just as a bit of background, I am looking to integrate Ruby with a product sold by my company, so eventually I will also be compiling for HP-UX/PA-RISC and Solaris/SPARC. The product is 64-bit only on the Unix server side and 32-bit on the Windows client side. Hopefully I won't see this issue there.</p>
<p>In the HP-UX articles referenced above, The following comment is made in the second paper with regard to the assembly code included in the first paper:</p>
<blockquote>
<p>While the assembly code is useful for performance sensitive implementations, it is not portable to<br>
other architectures and requires a significant understanding of the Itanium calling conventions. This<br>
document extends the previous paper and the man pages by providing example HP-UX C-level source<br>
code to implement user level thread switching with the context library routines. These routines are<br>
more portable among releases of HP-UX and can be employed by software engineers.</p>
</blockquote>
<p>If performance is an issue, then perhaps the assembly from the first paper is useful. Otherwise, getcontext/setcontext would seem more portable.</p>
<p>Cheers,<br>
Gra.<br>
=end</p> Ruby master - Bug #1342: signal handling on HP-UXhttps://redmine.ruby-lang.org/issues/1342?journal_id=36882009-04-02T08:25:28Zgraza (Graham Agnew)graham.agnew@gmail.com
<ul></ul><p>=begin<br>
Hi Nakada-san,</p>
<p>I should also say that this problem is worse on HP-UX 11i v3 (version 11.31). When running "make test" it doesn't even get past the sample/test.rb:signal tests; ruby core dumps with the same problem of establishing context.</p>
<p>Cheers,<br>
Gra.<br>
=end</p> Ruby master - Bug #1342: signal handling on HP-UXhttps://redmine.ruby-lang.org/issues/1342?journal_id=36992009-04-04T11:15:01Zgraza (Graham Agnew)graham.agnew@gmail.com
<ul></ul><p>=begin<br>
Hi Nakada-san,</p>
<p>I have modified my 1.9.1-p0 such that getcontext/setcontext would be used, but it hasn't helped. Basically this was done by running configure as normal and then changing the generated .ext/include/ia64-hpux11.23/ruby/config.h to have the following:</p>
<blockquote>
<p>#define RUBY_SETJMP(env) ( env->value = 0, getcontext(&env->context), env->value )<br>
#define RUBY_LONGJMP(env,val) ( env->value = val, setcontext(&env->context) )<br>
typedef struct {<br>
ucontext_t context;<br>
int value;<br>
} RUBY_JMP_BUF[1];</p>
</blockquote>
<p>I had tp change one or two other places to get it to compile but after that everything compiles OK, and I think the context is being successfully saved and restored. However I'm still getting the same sort of errors as above. So it looks like this isn't the answer.</p>
<p>I've googled this error and the only other meaningful reference to this is that there was a bug in the Java VM for HP-UX. I don't know how to diagnose this problem further or what to try next.</p>
<p>Cheers,<br>
Gra.<br>
=end</p> Ruby master - Bug #1342: signal handling on HP-UXhttps://redmine.ruby-lang.org/issues/1342?journal_id=37262009-04-08T20:59:09Zgraza (Graham Agnew)graham.agnew@gmail.com
<ul></ul><p>=begin<br>
Some progress on this:</p>
<p>In the HP-UX documentation it says that on Itanium, PTHREAD_STACK_MIN is 256KB. But when I tracked the actual value doen in (limits.h), I found that it was only 4KB. Increasing this has solved the problem described in this ticket, however the test suite is now getting quite a few segmentation violation faults (SIGSEGV).</p>
<p>So it's not solved just yet.<br>
=end</p> Ruby master - Bug #1342: signal handling on HP-UXhttps://redmine.ruby-lang.org/issues/1342?journal_id=37272009-04-08T21:59:51Zgraza (Graham Agnew)graham.agnew@gmail.com
<ul></ul><p>=begin<br>
OK, so the problem with Segmentation faults was related to the previous changes I had made to use getcontext/setcontext instead of setjmp/lonjmp; it was causing Fibers to fail for one thing, and who knows what else. Once I reverted back to setjmp/lonjmp all but one of the tests pass. The failing test is as per ticket <a class="issue tracker-1 status-6 priority-4 priority-default closed" title="Bug: pthread_cond_timedwait failing in 1.9.1-p0 thread tests on HP-UX 11i v2 (Rejected)" href="https://redmine.ruby-lang.org/issues/1341">#1341</a> - I haven't looked into that much just yet...</p>
<p>*** orig/ruby-1.9.1-p0/thread_pthread.c Tue Jan 20 09:53:14 2009<br>
--- ruby-1.9.1-p0/thread_pthread.c Wed Apr 8 13:53:08 2009</p>
<hr>
<p>*** 17,22 ****<br>
--- 17,27 ----<br>
#include <sys/resource.h><br>
#endif</p>
<ul>
<li>#ifdef __hpux</li>
<li>#undef PTHREAD_STACK_MIN</li>
<li>#define PTHREAD_STACK_MIN 0x80000</li>
<li>#endif</li>
<li>static void native_mutex_lock(pthread_mutex_t *lock);<br>
static void native_mutex_unlock(pthread_mutex_t *lock);<br>
static int native_mutex_trylock(pthread_mutex_t *lock);</li>
</ul>
<p>=end</p> Ruby master - Bug #1342: signal handling on HP-UXhttps://redmine.ruby-lang.org/issues/1342?journal_id=46832009-07-14T00:25:12Zyugui (Yuki Sonoda)yugui@yugui.jp
<ul><li><strong>Priority</strong> changed from <i>Normal</i> to <i>3</i></li></ul><p>=begin</p>
<p>=end</p> Ruby master - Bug #1342: signal handling on HP-UXhttps://redmine.ruby-lang.org/issues/1342?journal_id=63632009-10-21T20:33:09Znaruse (Yui NARUSE)naruse@airemix.jp
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Assigned</i></li><li><strong>Assignee</strong> set to <i>kanemoto (Yutaka Kanemoto)</i></li></ul><p>=begin</p>
<p>=end</p> Ruby master - Bug #1342: signal handling on HP-UXhttps://redmine.ruby-lang.org/issues/1342?journal_id=63642009-10-21T20:33:54Znaruse (Yui NARUSE)naruse@airemix.jp
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Open</i></li><li><strong>Assignee</strong> deleted (<del><i>kanemoto (Yutaka Kanemoto)</i></del>)</li></ul><p>=begin<br>
Sorry wrong assignment.<br>
=end</p> Ruby master - Bug #1342: signal handling on HP-UXhttps://redmine.ruby-lang.org/issues/1342?journal_id=112312010-05-25T19:23:41Znaruse (Yui NARUSE)naruse@airemix.jp
<ul><li><strong>Target version</strong> changed from <i>1.9.1</i> to <i>2.0.0</i></li></ul><p>=begin</p>
<p>=end</p> Ruby master - Bug #1342: signal handling on HP-UXhttps://redmine.ruby-lang.org/issues/1342?journal_id=182742011-06-26T14:24:31Znaruse (Yui NARUSE)naruse@airemix.jp
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Feedback</i></li><li><strong>Assignee</strong> set to <i>naruse (Yui NARUSE)</i></li></ul><p>Graham, the patch is still available?<br>
If so, I'll merge it.</p> Ruby master - Bug #1342: signal handling on HP-UXhttps://redmine.ruby-lang.org/issues/1342?journal_id=364992013-02-18T21:06:20Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Feedback</i> to <i>Rejected</i></li><li><strong>Target version</strong> changed from <i>2.0.0</i> to <i>2.6</i></li></ul><p>Marking as rejected due to no feedback from OP.</p>
<p>--<br>
Yusuke Endoh <a href="mailto:mame@tsg.ne.jp" class="email">mame@tsg.ne.jp</a></p>