Re: Problem with Ruby 1.8.6-p110 on DragonFly (was [PATCH] Problem with ruby 1.8.6-p36 (and p39) on

e$B$3$s$P$s$O!#e(B

DragonFly BSDe$B>e$Ge(BRuby 1.8.6
p110e$B$r!"$=$N$^$^:n@.$7$h$&$H$9$k$H!"e(B

% sh configure --enable-pthread --enable-shared

% make
ar rcu libruby-static.a array.o bignum.o class.o compar.o dir.o
dln.o enum.o error.o eval.o file.o gc.o hash.o inits.o io.o
marshal.o math.o numeric.o object.o pack.o parse.o process.o
prec.o random.o range.o re.o regex.o ruby.o signal.o sprintf.o
st.o string.o struct.o time.o util.o variable.o version.o isnan.o
isinf.o dmyext.o
gcc -g -O2 -fPIC -DRUBY_EXPORT -I. -I. -c main.c
gcc -g -O2 -fPIC -DRUBY_EXPORT -L. -rdynamic main.o
libruby-static.a -lcrypt -lm -o miniruby
libruby-static.a(eval.o)(.text+0x15002): In function
rb_thread_start_0': /var/tmp/ruby-1.8.6-p110/eval.c:11945: undefined reference to pthread_create’
libruby-static.a(eval.o)(.text+0x1501e):/var/tmp/ruby-1.8.6-p110/eval.c:11947:
undefined reference to `pthread_atfork’
*** Error code 1

Stop in /var/tmp/ruby-1.8.6-p110.

e$B$H!"$J$j$^$9!#e(Bpthreade$B$J%i%$%V%i%j$Oe(Blibc_r.{a,so}e$B$K4^$^$l$F$$$k$h$&$G$9!#e(B

e$B0lJ}!“e(Bpkgsrce$B$JOHAH$_$NCf$G$O!”>e5-$NLdBj$OLLE]8+$F$/$l$F$$$k$N$G$9$,!"e(B
e$B:#EY$Oe(Bminirubye$B$N%j%s%/;~$K!"e(Bpthread_atfork()e$B$,L$Dj5A$H$J$j$^$9!#e(B

pthread_atfork()e$B$Oe(B /usr/lib/libthread_xu.so
e$B$H$$$C$?$“$?$j$K$”$k$h$&$G!"e(B
e$B:G=E$K$Oe(Blibc_r.soe$B$rCV$-49$($k$h$&$J0LCVIU$1$N%i%$%V%i%j$N$h$&$G$9!#e(B
(e$B$7$+$7!"e(B1.10.1e$B$H$$$C$?:G?7$N%j%j!<%90J30$G$O!"40A4$G$O$J$$$h$&$G$9!#e(B)

pkgsrce$B$Oe(B 2007Q3 e$B$N%V%i%s%A$,6a$$$?$a!"e(B

$NetBSD: patch-ad,v 1.7 2007/10/02 15:59:23 taca Exp $

— eval.c.orig 2007-09-23 09:01:50.000000000 +0900
+++ eval.c
@@ -11944,7 +11944,9 @@ rb_thread_start_0(fn, arg, th)
#ifdef _THREAD_SAFE
pthread_create(&time_thread, 0, thread_timer, 0);
time_thread_alive_p = 1;
+#ifndef DragonFly
pthread_atfork(0, 0, rb_child_atfork);
+#endif
#else
rb_thread_start_timer();
#endif

e$B$H!"$$$C$?%Q%C%A$G$*Cc$rBy$7$F$$$^$9!#e(B

[ruby-dev:31253]
In message [email protected]
on Wed, 18 Jul 2007 21:49:39 +0900,
“Vincent I.” [email protected] wrote:

e$B$3$N%a!<%k$K>.$5$$!Je(Bpthread_atforke$B$r;H$C$F$k!K%Q%C%A$rE:IU$7$?$s$G$9!#e(B
e$B$G$b$3$N%Q%C%A$OK\Ev$K@5$7$$D>$7J}$G$“$k$+$I$&$+!D$o$+$i$J$$$G$9!#e(B
e$B$*$=$i$/e(Bpthread_atfork()e$B$,MQ0U$5$l$F$$$J$$4D6-$b$”$k$H$$$&$3$H$G!#e(B


e$B?@8Me(B e$BN4Gne(B / Takahiro K.

P.S.
e$B;d<+?H$Oe(Bpkgsrce$B$NLLE]$r8+$F$kN)>l$G=q$$$F$$$^$9$,!“e(BDragonFly
BSDe$B$r>oF|:“e(B
e$B;HMQ$7$F$$$k$o$1$G$O$”$j$^$;$s$,!”$I$J$?$+F0:n3NG’$J$I$O$5$l$F$$$k$N$Ge(B
e$B$7$g$&$+e(B? (make
test-alle$B$H$+$9$k$H!"e(B3e$B$D$/$i$$0z$C3]$+$k$h$&$G$9!#e(B)

In message [email protected]
on Wed, 3 Oct 2007 01:14:32 +0900,
Takahiro K. [email protected] wrote:

DragonFly BSDe$B>e$Ge(BRuby 1.8.6 p110e$B$r!"$=$N$^$^:n@.$7$h$&$H$9$k$H!"e(B

e$B2?$b1~Ez$,$J$$$H$$$&$3$H$O!"e(B

o DragonFly
BSDe$B$G$OI8=$N%Q%C%1!<%8!&%7%9%F%$G$"$ke(Bpkgsrce$B$Ge(BRubye$B$r;H$C$F$k!#e(B
o DragonFly
BSDe$B$G%Q%C%1!<%8!&%7%9%F%`$J$7$Ge(BRubye$B$r;H$C$F$k?M$O$$$J$$!#e(B

e$B$H!"$$$&$3$H$J$s$G$7$g$&$+e(B…?

e$B$J$+$@$G$9!#e(B

At Wed, 3 Oct 2007 01:14:32 +0900,
Takahiro K. wrote in [ruby-dev:31927]:

gcc -g -O2 -fPIC -DRUBY_EXPORT -L. -rdynamic main.o libruby-static.a -lcrypt -lm -o miniruby
libruby-static.a(eval.o)(.text+0x15002): In function rb_thread_start_0': /var/tmp/ruby-1.8.6-p110/eval.c:11945: undefined reference topthread_create’
libruby-static.a(eval.o)(.text+0x1501e):/var/tmp/ruby-1.8.6-p110/eval.c:11947: undefined reference to `pthread_atfork’
*** Error code 1

Stop in /var/tmp/ruby-1.8.6-p110.

e$B$H!"$J$j$^$9!#e(Bpthreade$B$J%i%$%V%i%j$Oe(Blibc_r.{a,so}e$B$K4^$^$l$F$$$k$h$&$G$9!#e(B

pthreade$B%i%$%V%i%j$Oe(B pthread pthreads c c_r
e$B$N=g$KC5$7$F$$$k$N$G!“e(B
e$B8+IU$+$k$O$:$@$H;W$&$N$G$9$,!”$R$g$C$H$7$F!"e(BDragonFly
BSDe$B$G$Oe(B
-pthreade$B$rIU$1$F$be(Blibc_re$B$O%j%s%/$5$l$J$$$N$G$7$g$&$+!#e(B

e$B0lJ}!“e(Bpkgsrce$B$JOHAH$_$NCf$G$O!”>e5-$NLdBj$OLLE]8+$F$/$l$F$$$k$N$G$9$,!"e(B
e$B:#EY$Oe(Bminirubye$B$N%j%s%/;~$K!"e(Bpthread_atfork()e$B$,L$Dj5A$H$J$j$^$9!#e(B

pthread_atfork()e$B$Oe(B /usr/lib/libthread_xu.so e$B$H$$$C$?$"$?$j$K$"$k$h$&$G!"e(B
e$B:G=E$K$Oe(Blibc_r.soe$B$rCV$-49$($k$h$&$J0LCVIU$1$N%i%$%V%i%j$N$h$&$G$9!#e(B
(e$B$7$+$7!"e(B1.10.1e$B$H$$$C$?:G?7$N%j%j!<%90J30$G$O!"40A4$G$O$J$$$h$&$G$9!#e(B)

e$BM%@h=g0L$H$7$F$Oe(Blibce$B$h$j$b@h$G$9$+e(B?

+#ifndef DragonFly
pthread_atfork(0, 0, rb_child_atfork);
+#endif

HAVE_PTHREAD_ATFORKe$B$r;H$&$[$&$,$$$$$G$7$g$&$M!#e(B

Index: configure.in

— configure.in (revision 13643)
+++ configure.in (working copy)
@@ -861,5 +861,5 @@ AC_DEFINE_UNQUOTED(STACK_GROW_DIRECTION,

if test x"$enable_pthread" = xyes; then

  • for pthread_lib in pthread pthreads c c_r; do
  • for pthread_lib in pthread pthreads thread_xu c c_r; do
    AC_CHECK_LIB($pthread_lib, pthread_kill,
    rb_with_pthread=yes, rb_with_pthread=no)
    @@ -883,5 +883,5 @@ if test x"$enable_pthread" = xyes; then
    AC_MSG_WARN(“Don’t know how to find pthread library on your system –
    thread support disabled”)
    fi
  • AC_CHECK_FUNCS(nanosleep)
  • AC_CHECK_FUNCS(nanosleep pthread_atfork)
    if test x"$ac_cv_func_nanosleep" = xno; then
    AC_CHECK_LIB(rt, nanosleep)

In message [email protected]
on Tue, 9 Oct 2007 06:12:24 +0900,
Nobuyoshi N. [email protected] wrote:

e$B$H!"$J$j$^$9!#e(Bpthreade$B$J%i%$%V%i%j$Oe(Blibc_r.{a,so}e$B$K4^$^$l$F$$$k$h$&$G$9!#e(B

pthreade$B%i%$%V%i%j$Oe(B pthread pthreads c c_r e$B$N=g$KC5$7$F$$$k$N$G!“e(B
e$B8+IU$+$k$O$:$@$H;W$&$N$G$9$,!”$R$g$C$H$7$F!“e(BDragonFly BSDe$B$G$Oe(B
-pthreade$B$rIU$1$F$be(Blibc_re$B$O%j%s%/$5$l$J$$$N$G$7$g$&$+!#e(B
e$B:#!”<B5!$K%"%/%;%9$G$-$J$$$N$G$9$,!"N.@P$Ke(B -pthread
e$BIU$1$?$H$-$Oe(B
libc_re$B$r%j%s%/$7$F$$$?$H5-21$7$F$$$^$9!#e(B

e$BM%@h=g0L$H$7$F$Oe(Blibce$B$h$j$b@h$G$9$+e(B?
e$B$I$&$b!"$3$NJU$j$O$h$/$o$+$i$J$$$N$G$9$,!"e(BDragonFly
1.10.1e$B$N%j%j!<%9!&e(B
e$B%N!<%H$K$O!"e(B

DragonFly’s Light Weight Process abstraction is now finished and
working via libthread_xu but the default threading library is not
quite ready to be changed from libc_r yet. All threaded programs now
link against an actual ‘libpthread’ which is a softlink to libc_r or
libthread_xu, allowing the new threading library to be tested more
fully.

e$B$H!“$$$C$?5-=R$,$”$j$^$9!#e(Blibc_re$B$He(Blibthread_xue$B$OJBNs!&GSB>Aj8_E*$Je(B
e$BB8:_$N$h$&$G$9$,!"e(B1.10.1e$B$h$j$b8E$$%j%j!<%9$G$Oe(Blibthread_xue$B$OI]$/$F;H$(e(B
e$B$J$$$H$$$&2DG=@-$b9b$$$H8@$($^$9!#e(B

+#ifndef DragonFly
pthread_atfork(0, 0, rb_child_atfork);
+#endif

HAVE_PTHREAD_ATFORKe$B$r;H$&$[$&$,$$$$$G$7$g$&$M!#e(B
e$B$b$A$m$s!“$=$&$G$9!#$”$/$^$G;CDjE*$J=$@5$G$7$?$N$G!#e(B:-)