Bug#580464: ruby1.8: hangs under some circumstances on GNU/kFreeBSD

2010-05-06 Thread Petr Salinger

Package: ruby1.8
Version: 1.8.7.249-3
Severity: important
Tags: patch
User: debian-...@lists.debian.org
Usertags: kfreebsd


Hi,

the current version have on GNU/kFreeBSD the same problem
as described in

http://redmine.ruby-lang.org/issues/show/2739

Please replace 100312_timeout-fix.dpatch by attached version.

It would also be nice if you can ask upstream
to include these || defined(__GLIBC__)
and  !defined(__GLIBC__) changes.

Thanks in advance

Petr

#! /bin/sh /usr/share/dpatch/dpatch-run
## timeout-fix.dpatch by Lucas Nussbaum lu...@lucas-nussbaum.net
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Fix problem with threads+timeouts.
## DP: Backports from upstream. See 
http://redmine.ruby-lang.org/issues/show/2739, 
https://bugs.launchpad.net/ubuntu/lucid/+source/eglibc/+bug/520715, 
Debian#539987

@DPATCH@
diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' 
'--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' 
ruby1.8-1.8.7.249~/ChangeLog ruby1.8-1.8.7.249/ChangeLog
--- ruby1.8-1.8.7.249~/ChangeLog2010-01-10 11:30:06.0 +0100
+++ ruby1.8-1.8.7.249/ChangeLog 2010-03-12 07:07:47.0 +0100
@@ -1,3 +1,18 @@
+Fri Jan 22 01:22:27 2010  NAKAMURA Usaku  u...@ruby-lang.org
+
+   * eval.c (thread_timer, rb_thread_stop_timer): check the timing of
+ stopping timer.  patch from KOSAKI Motohiro kosaki.motohiro _AT_
+ jp.fujitsu.com
+
+   * eval.c (rb_thread_start_timer): NetBSD5 seems to be hung when calling
+ pthread_create() from pthread_atfork()'s parent handler.
+
+   * io.c (pipe_open): workaround for NetBSD5. stop timer thread before
+ fork(), and start it if needed.
+
+   * process.c (rb_f_fork, rb_f_system): ditto.
+ fixed [ruby-dev:40074]
+
 Sun Jan 10 19:00:31 2010  Nobuyoshi Nakada  n...@ruby-lang.org
 
* lib/webrick/accesslog.rb : Escape needed.
diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' 
'--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' ruby1.8-1.8.7.249~/eval.c 
ruby1.8-1.8.7.249/eval.c
--- ruby1.8-1.8.7.249~/eval.c   2009-12-21 09:11:42.0 +0100
+++ ruby1.8-1.8.7.249/eval.c2010-03-12 07:07:49.0 +0100
@@ -12292,6 +12292,8 @@
 pthread_t thread;
 } time_thread = {PTHREAD_COND_INITIALIZER, PTHREAD_MUTEX_INITIALIZER};
 
+static int timer_stopping;
+
 #define safe_mutex_lock(lock) \
 pthread_mutex_lock(lock); \
 pthread_cleanup_push((void (*)_((void *)))pthread_mutex_unlock, lock)
@@ -12316,6 +12318,9 @@
 #define WAIT_FOR_10MS() \
 pthread_cond_timedwait(running-cond, running-lock, get_ts(to, 
PER_NANO/100))
 while ((err = WAIT_FOR_10MS()) == EINTR || err == ETIMEDOUT) {
+   if (timer_stopping)
+   break;
+
if (!rb_thread_critical) {
rb_thread_pending = 1;
if (rb_trap_immediate) {
@@ -12343,7 +12348,9 @@
 safe_mutex_lock(time_thread.lock);
 if (pthread_create(time_thread.thread, 0, thread_timer, args) == 0) {
thread_init = 1;
+#if !defined(__NetBSD__)  !defined(linux)  !defined(__GLIBC__)
pthread_atfork(0, 0, rb_thread_stop_timer);
+#endif
pthread_cond_wait(start, time_thread.lock);
 }
 pthread_cleanup_pop(1);
@@ -12354,10 +12361,12 @@
 {
 if (!thread_init) return;
 safe_mutex_lock(time_thread.lock);
+timer_stopping = 1;
 pthread_cond_signal(time_thread.cond);
 thread_init = 0;
 pthread_cleanup_pop(1);
 pthread_join(time_thread.thread, NULL);
+timer_stopping = 0;
 }
 #elif defined(HAVE_SETITIMER)
 static void
diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' 
'--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' ruby1.8-1.8.7.249~/io.c 
ruby1.8-1.8.7.249/io.c
--- ruby1.8-1.8.7.249~/io.c 2009-11-25 09:45:13.0 +0100
+++ ruby1.8-1.8.7.249/io.c  2010-03-12 07:07:49.0 +0100
@@ -3245,6 +3245,9 @@
 }
 
   retry:
+#if defined(__NetBSD__) || defined(linux) || defined(__GLIBC__)
+rb_thread_stop_timer();
+#endif
 switch ((pid = fork())) {
   case 0:  /* child */
if (modef  FMODE_READABLE) {
@@ -3272,11 +3275,17 @@
ruby_sourcefile, ruby_sourceline, pname);
_exit(127);
}
+#if defined(__NetBSD__) || defined(linux) || defined(__GLIBC__)
+   rb_thread_start_timer();
+#endif
rb_io_synchronized(RFILE(orig_stdout)-fptr);
rb_io_synchronized(RFILE(orig_stderr)-fptr);
return Qnil;
 
   case -1: /* fork failed */
+#if defined(__NetBSD__) || defined(linux) || defined(__GLIBC__)
+   rb_thread_start_timer();
+#endif
if (errno == EAGAIN) {
rb_thread_sleep(1);
goto retry;
@@ -3297,6 +3306,9 @@
break;
 
   default: /* parent */
+#if defined(__NetBSD__) || defined(linux) || defined(__GLIBC__)
+   rb_thread_start_timer();
+#endif

Bug#580464: ruby1.8: hangs under some circumstances on GNU/kFreeBSD

2010-05-06 Thread Lucas Nussbaum
On 06/05/10 at 11:55 +0200, Petr Salinger wrote:
 Package: ruby1.8
 Version: 1.8.7.249-3
 Severity: important
 Tags: patch
 User: debian-...@lists.debian.org
 Usertags: kfreebsd
 
 
 Hi,
 
 the current version have on GNU/kFreeBSD the same problem
 as described in
 
 http://redmine.ruby-lang.org/issues/show/2739
 
 Please replace 100312_timeout-fix.dpatch by attached version.
 
 It would also be nice if you can ask upstream
 to include these || defined(__GLIBC__)
 and  !defined(__GLIBC__) changes.

Hi Petr,

Thanks for the patch!

Shouldn't the recommendation to upstream fix to drop the #if completely?
-- 
| Lucas Nussbaum
| lu...@lucas-nussbaum.net   http://www.lucas-nussbaum.net/ |
| jabber: lu...@nussbaum.fr GPG: 1024D/023B3F4F |



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#580464: ruby1.8: hangs under some circumstances on GNU/kFreeBSD

2010-05-06 Thread Petr Salinger

It would also be nice if you can ask upstream
to include these || defined(__GLIBC__)
and  !defined(__GLIBC__) changes.



Shouldn't the recommendation to upstream fix to drop the #if completely?


I would say yes, but obviously, I cannot
test whether it broke other platforms.

Petr



--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org