Custom Search
|
Date: January 31, 2006
From: H.Yamamoto <ocean@xxxxxxxxxxxxxxx>
In-reply-to:
<20060130230834.A0305E10.ocean@xxxxxxxxxxxxxxx>
References:
<20060126092948.3416D5C8.ocean@xxxxxxxxxxxxxxx> <20060130230834.A0305E10.ocean@xxxxxxxxxxxxxxx>
山本です。
待ちくたびれたので、特に反対がなければこれをコミットしようと思います。
setenv と unsetenv がない環境では、set_arg0 で environ を
使うコードを残すようにしました。これなら何かあっても元に戻しやすいでしょうし。
# setenv に 2引数の時代があったという裏付けを取ろうと
# google で大分調べたのですが、見つかりませんでした。
# 他のプログラムの configure でも単に HAVE_SETENV となってる
# ものばかりなので、unsetenv 同様の調べかたでいいのかもしれません。
Index: configure.in
===================================================================
RCS file: /src/ruby/configure.in,v
retrieving revision 1.297
diff -u -w -b -p -r1.297 configure.in
--- configure.in 25 Jan 2006 13:29:44 -0000 1.297
+++ configure.in 31 Jan 2006 11:12:18 -0000
@@ -506,7 +506,7 @@ AC_CHECK_FUNCS(fmod killpg wait4 waitpid
getpriority getrlimit setrlimit\
dlopen sigprocmask sigaction _setjmp vsnprintf snprintf\
setsid telldir seekdir fchmod mktime timegm cosh sinh tanh\
- setuid setgid daemon select_large_fdset)
+ setuid setgid daemon select_large_fdset unsetenv)
AC_ARG_ENABLE(setreuid,
[ --enable-setreuid use setreuid()/setregid() according to need
even if obsolete.],
[use_setreuid=$enableval])
@@ -514,6 +514,20 @@ if test "$use_setreuid" = yes; then
AC_DEFINE(USE_SETREUID)
AC_DEFINE(USE_SETREGID)
fi
+AC_CACHE_CHECK(for setenv (2 arguments), rb_cv_have_setenv_2args,
+ [AC_TRY_COMPILE([#include <stdlib.h>], [setenv("foo", "foo");],
+ rb_cv_have_setenv_2args=yes,
+ rb_cv_have_setenv_2args=no)])
+if test "$rb_cv_have_setenv_2args" = yes; then
+ AC_DEFINE(HAVE_SETENV_2ARGS)
+fi
+AC_CACHE_CHECK(for setenv (3 arguments), rb_cv_have_setenv_3args,
+ [AC_TRY_COMPILE([#include <stdlib.h>], [setenv("foo", "foo", 1);],
+ rb_cv_have_setenv_3args=yes,
+ rb_cv_have_setenv_3args=no)])
+if test "$rb_cv_have_setenv_3args" = yes; then
+ AC_DEFINE(HAVE_SETENV_3ARGS)
+fi
AC_STRUCT_TIMEZONE
AC_CACHE_CHECK(for struct tm.tm_gmtoff, rb_cv_member_struct_tm_tm_gmtoff,
[AC_TRY_COMPILE([#include <time.h>],
Index: hash.c
===================================================================
RCS file: /src/ruby/hash.c,v
retrieving revision 1.159
diff -u -w -b -p -r1.159 hash.c
--- hash.c 20 Oct 2005 02:56:22 -0000 1.159
+++ hash.c 31 Jan 2006 11:12:18 -0000
@@ -1690,7 +1690,14 @@ ruby_setenv(const char *name, const char
* RTL's environ global variable directly yet.
*/
SetEnvironmentVariable(name,value);
-#elif defined __CYGWIN__
+#elif defined(HAVE_SETENV_2ARGS) && defined(HAVE_UNSETENV)
+#undef setenv
+#undef unsetenv
+ if (value)
+ setenv(name,value);
+ else
+ unsetenv(name);
+#elif defined(HAVE_SETENV_3ARGS) && defined(HAVE_UNSETENV)
#undef setenv
#undef unsetenv
if (value)
Index: ruby.c
===================================================================
RCS file: /src/ruby/ruby.c,v
retrieving revision 1.112
diff -u -w -b -p -r1.112 ruby.c
--- ruby.c 12 Dec 2005 00:35:08 -0000 1.112
+++ ruby.c 31 Jan 2006 11:06:15 -0000
@@ -987,7 +987,15 @@ VALUE rb_progname;
VALUE rb_argv;
VALUE rb_argv0;
-#if !defined(PSTAT_SETCMD) && !defined(HAVE_SETPROCTITLE) && !defined(DOSISH)
+#if defined(PSTAT_SETCMD) || defined(HAVE_SETPROCTITLE)
+#elif defined(_WIN32)
+#elif defined(HAVE_SETENV_2ARGS) && defined(HAVE_UNSETENV)
+#elif defined(HAVE_SETENV_3ARGS) && defined(HAVE_UNSETENV)
+#else
+#define USE_ENVSPACE_FOR_ARG0
+#endif
+
+#ifdef USE_ENVSPACE_FOR_ARG0
static struct {
char *begin, *end;
} envspace;
@@ -1061,7 +1069,7 @@ set_arg0(VALUE val, ID id)
break;
}
}
-#ifndef DOSISH
+#ifdef USE_ENVSPACE_FOR_ARG0
if (s + 1 == envspace.begin) {
s = envspace.end;
ruby_setenv("", NULL); /* duplicate environ vars */
Date: January 30, 2006
From: H.Yamamoto <ocean@xxxxxxxxxxxxxxx>
In-reply-to:
<20060126092948.3416D5C8.ocean@xxxxxxxxxxxxxxx>
References:
<20060126091829.1EF2DC80.ocean@xxxxxxxxxxxxxxx> <20060126092948.3416D5C8.ocean@xxxxxxxxxxxxxxx>
山本です。 >>>> $0= で origargv を変更しているのが environ にも影響している感じなのですが、 >>>> この処理って本当に必要なんでしょうか?environ を変更するのと同じぐらい >>>> 危ない処理に思えますが・・・ 調べてみると、argv の変更自体は合法なんですね。 http://www.adl.nii.ac.jp/~moro/unix-programmer/faq-j_2.html#SEC22 ruby.c は下のパッチで十分でした。つまり、 http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/4774 で入った環境変数領域の改変が影響していたということのようです。 Index: ruby.c =================================================================== RCS file: /src/ruby/ruby.c,v retrieving revision 1.112 diff -u -w -b -p -r1.112 ruby.c --- ruby.c 12 Dec 2005 00:35:08 -0000 1.112 +++ ruby.c 30 Jan 2006 14:02:08 -0000 @@ -1061,7 +1061,7 @@ set_arg0(VALUE val, ID id) break; } } -#ifndef DOSISH +#if 0 if (s + 1 == envspace.begin) { s = envspace.end; ruby_setenv("", NULL); /* duplicate environ vars */ [ruby-dev:28281] に加えてこのパッチでどうでしょうか?
Date: January 30, 2006
From: Tanaka Akira <akr@xxxxxxxx>
最近、Data オブジェクトの free 関数が気になっているのですが、
とりあえず次のようにすると SEGV になるようです。
% cat tst.rb
require 'zlib'
class C
def write(str)
end
end
GC.stress = true
100.times {|i|
p i
o = C.new
100.times {
o = Zlib::GzipWriter.new(o)
}
o.write "a"
}
% ./ruby tst.rb
0
1
tst.rb:13: warning: Zlib::GzipWriter object must be closed explicitly.
tst.rb:13: warning: Zlib::GzipWriter object must be closed explicitly.
tst.rb:13: warning: Zlib::GzipWriter object must be closed explicitly.
zsh: segmentation fault (core dumped) ./ruby tst.rb
% gdb ruby core
GNU gdb 6.4-debian
Copyright 2005 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i486-linux-gnu"...Using host libthread_db library
"/lib/tls/libthread_db.so.1".
Core was generated by `./ruby tst.rb'.
Program terminated with signal 11, Segmentation fault.
warning: Can't read pathname for load map: Input/output error.
Reading symbols from /lib/tls/libdl.so.2...done.
Loaded symbols for /lib/tls/libdl.so.2
Reading symbols from /lib/tls/libcrypt.so.1...done.
Loaded symbols for /lib/tls/libcrypt.so.1
Reading symbols from /lib/tls/libm.so.6...done.
Loaded symbols for /lib/tls/libm.so.6
Reading symbols from /lib/tls/libc.so.6...done.
Loaded symbols for /lib/tls/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from
/home/akr/ruby/tmp-ruby/lib/ruby/1.9/i686-linux/zlib.so...done.
Loaded symbols for /home/akr/ruby/tmp-ruby/lib/ruby/1.9/i686-linux/zlib.so
Reading symbols from /usr/lib/libz.so.1...done.
Loaded symbols for /usr/lib/libz.so.1
#0 0xb7e4afce in free () from /lib/tls/libc.so.6
(gdb) bt
#0 0xb7e4afce in free () from /lib/tls/libc.so.6
#1 0xb7e4c8bc in malloc () from /lib/tls/libc.so.6
#2 0x08072e58 in ruby_xmalloc (size=3614891752) at gc.c:140
#3 0x080c3f6f in str_new (klass=<value optimized out>, ptr=0x49 <Address 0x49
out of bounds>, len=71) at string.c:83
#4 0x08078083 in rb_write_error2 (
mesg=0xbfc91f54 "tst.rb:13: warning: Zlib::GzipWriter object must be closed
explicitly.\nsed explicitly.\n\036$抃o餬\021", len=71) at io.c:3843
#5 0x080e3a91 in warn_print (fmt=<value optimized out>, args=<value optimized
out>) at error.c:98
#6 0x080e3ada in rb_warn (fmt=0xb7f82378 "Zlib::GzipWriter object must be
closed explicitly.") at error.c:112
#7 0xb7f7f57b in gzfile_writer_end (gz=0x99e0238) at zlib.c:2286
#8 0xb7f7eb76 in gzfile_free (gz=0x99e0238) at zlib.c:1755
#9 0x08072b92 in garbage_collect () at gc.c:1183
#10 0x08073158 in ruby_xrealloc (ptr=0x9aa48c8, size=2059) at gc.c:185
#11 0x080c4bf0 in rb_str_resize (str=3084712432, len=2058) at string.c:613
#12 0xb7f7cfb8 in zstream_expand_buffer (z=0xb26c6c8) at zlib.c:457
#13 0xb7f7d5a3 in zstream_run (z=0xb26c6c8, src=0x41668 <Address 0x41668 out of
bounds>, len=3086059672, flush=0)
at zlib.c:729
#14 0xb7f7f1fa in gzfile_write (gz=0xb26c6c8, str=0x9aa48b8 "\037\213\b",
len=10) at zlib.c:2107
#15 0xb7f81b8b in rb_gzwriter_write (obj=267881, str=3084712312) at zlib.c:2847
#16 0x08060b67 in rb_call0 (klass=<value optimized out>, recv=3084710392,
id=7409, oid=7409, argc=<value optimized out>,
argv=0xbfc973c0, body=0xb7dd0350, flags=8) at eval.c:5691
#17 0x08060ca0 in rb_call (klass=3084716112, recv=3084710392, mid=7409, argc=1,
argv=0xbfc973c0, scope=CALLING_FCALL)
at eval.c:5864
#18 0x08061a10 in rb_funcall (recv=3084710392, mid=7409, n=1) at eval.c:5964
#19 0xb7f7ed4b in gzfile_write_raw (gz=0xb2ade28) at zlib.c:1823
#20 0xb7f81b8b in rb_gzwriter_write (obj=267881, str=3084712332) at zlib.c:2847
#21 0x08060b67 in rb_call0 (klass=<value optimized out>, recv=3084710372,
id=7409, oid=7409, argc=<value optimized out>,
argv=0xbfc97610, body=0xb7dd0350, flags=8) at eval.c:5691
#22 0x08060ca0 in rb_call (klass=3084716112, recv=3084710372, mid=7409, argc=1,
argv=0xbfc97610, scope=CALLING_FCALL)
at eval.c:5864
#23 0x08061a10 in rb_funcall (recv=3084710372, mid=7409, n=1) at eval.c:5964
#24 0xb7f7ed4b in gzfile_write_raw (gz=0xb2ef588) at zlib.c:1823
#25 0xb7f81b8b in rb_gzwriter_write (obj=267881, str=3084720452) at zlib.c:2847
#26 0x08060b67 in rb_call0 (klass=<value optimized out>, recv=3084710352,
id=7409, oid=7409, argc=<value optimized out>,
argv=0xbfc97860, body=0xb7dd0350, flags=8) at eval.c:5691
#27 0x08060ca0 in rb_call (klass=3084716112, recv=3084710352, mid=7409, argc=1,
argv=0xbfc97860, scope=CALLING_FCALL)
at eval.c:5864
#28 0x08061a10 in rb_funcall (recv=3084710352, mid=7409, n=1) at eval.c:5964
#29 0xb7f7ed4b in gzfile_write_raw (gz=0xb330ce8) at zlib.c:1823
#30 0xb7f81b8b in rb_gzwriter_write (obj=267881, str=3084720492) at zlib.c:2847
---Type <return> to continue, or q <return> to quit---
#31 0x08060b67 in rb_call0 (klass=<value optimized out>, recv=3084710332,
id=7409, oid=7409, argc=<value optimized out>,
argv=0xbfc97ab0, body=0xb7dd0350, flags=8) at eval.c:5691
#32 0x08060ca0 in rb_call (klass=3084716112, recv=3084710332, mid=7409, argc=1,
argv=0xbfc97ab0, scope=CALLING_FCALL)
at eval.c:5864
#33 0x08061a10 in rb_funcall (recv=3084710332, mid=7409, n=1) at eval.c:5964
#34 0xb7f7ed4b in gzfile_write_raw (gz=0xb372448) at zlib.c:1823
#35 0xb7f81b8b in rb_gzwriter_write (obj=267881, str=3084712372) at zlib.c:2847
#36 0x08060b67 in rb_call0 (klass=<value optimized out>, recv=3084710312,
id=7409, oid=7409, argc=<value optimized out>,
argv=0xbfc97d00, body=0xb7dd0350, flags=8) at eval.c:5691
#37 0x08060ca0 in rb_call (klass=3084716112, recv=3084710312, mid=7409, argc=1,
argv=0xbfc97d00, scope=CALLING_FCALL)
at eval.c:5864
#38 0x08061a10 in rb_funcall (recv=3084710312, mid=7409, n=1) at eval.c:5964
#39 0xb7f7ed4b in gzfile_write_raw (gz=0xb3b3ba8) at zlib.c:1823
#40 0xb7f81b8b in rb_gzwriter_write (obj=267881, str=3084712392) at zlib.c:2847
#41 0x08060b67 in rb_call0 (klass=<value optimized out>, recv=3084710292,
id=7409, oid=7409, argc=<value optimized out>,
argv=0xbfc97f50, body=0xb7dd0350, flags=8) at eval.c:5691
#42 0x08060ca0 in rb_call (klass=3084716112, recv=3084710292, mid=7409, argc=1,
argv=0xbfc97f50, scope=CALLING_FCALL)
at eval.c:5864
#43 0x08061a10 in rb_funcall (recv=3084710292, mid=7409, n=1) at eval.c:5964
#44 0xb7f7ed4b in gzfile_write_raw (gz=0xb3f5308) at zlib.c:1823
#45 0xb7f81b8b in rb_gzwriter_write (obj=267881, str=3084720412) at zlib.c:2847
#46 0x08060b67 in rb_call0 (klass=<value optimized out>, recv=3084710272,
id=7409, oid=7409, argc=<value optimized out>,
argv=0xbfc981a0, body=0xb7dd0350, flags=8) at eval.c:5691
#47 0x08060ca0 in rb_call (klass=3084716112, recv=3084710272, mid=7409, argc=1,
argv=0xbfc981a0, scope=CALLING_FCALL)
at eval.c:5864
#48 0x08061a10 in rb_funcall (recv=3084710272, mid=7409, n=1) at eval.c:5964
#49 0xb7f7ed4b in gzfile_write_raw (gz=0xb436a68) at zlib.c:1823
#50 0xb7f81b8b in rb_gzwriter_write (obj=267881, str=3084712252) at zlib.c:2847
#51 0x08060b67 in rb_call0 (klass=<value optimized out>, recv=3084710252,
id=7409, oid=7409, argc=<value optimized out>,
argv=0xbfc983f0, body=0xb7dd0350, flags=0) at eval.c:5691
#52 0x08060ca0 in rb_call (klass=3084716112, recv=3084710252, mid=7409, argc=1,
argv=0xbfc983f0, scope=CALLING_NORMAL)
at eval.c:5864
#53 0x0805ed62 in rb_eval (self=3084786192, n=<value optimized out>) at
eval.c:3310
#54 0x08063938 in rb_yield_0 (val=3, self=3084786192, klass=<value optimized
out>, flags=0, avalue=0) at eval.c:4869
#55 0x08064a16 in rb_yield (val=267881) at eval.c:4950
#56 0x0808374f in int_dotimes (num=201) at numeric.c:2757
#57 0x08060b67 in rb_call0 (klass=<value optimized out>, recv=201, id=5561,
oid=5561, argc=<value optimized out>, argv=0x0,
body=0xb7dde3ec, flags=0) at eval.c:5691
#58 0x08060ca0 in rb_call (klass=3084772532, recv=201, mid=5561, argc=0,
argv=0x0, scope=CALLING_NORMAL) at eval.c:5864
#59 0x0805ed62 in rb_eval (self=3084786192, n=<value optimized out>) at
eval.c:3310
---Type <return> to continue, or q <return> to quit---
#60 0x0805ff05 in rb_eval (self=3084786192, n=<value optimized out>) at
eval.c:3034
#61 0x0806abb0 in ruby_exec_internal () at eval.c:1547
#62 0x0806abf4 in ruby_exec () at eval.c:1563
#63 0x0806ac1f in ruby_run () at eval.c:1579
#64 0x08054399 in main (argc=2, argv=0xbfc99084, envp=0xbfc99090) at main.c:43
(gdb)
--
[田中 哲][たなか あきら][Tanaka Akira]
Date: January 27, 2006
From: Masaki Suketa <masaki.suketa@xxxxxxxxxxx>
In-reply-to:
Kazuhiro NISHIYAMA's message of "Wed, 25 Jan 2006 11:33:58 +0900" <87acdl9gu8.wl%zn@xxxxxxxxxxxxx>
References:
<87acdl9gu8.wl%zn@xxxxxxxxxxxxx>
助田です。
In message "[ruby-dev:28280] ext/win32ole/.document"
on 06/01/25, Kazuhiro NISHIYAMA <zn@xxxxxxxxxxxxx> writes:
> ext/win32ole/extconf.rbのcreate_docfileで.documentを
> 作成していてcvs updateで
> ? ext/win32ole/.document
> と出てくるのですが、これは動的に生成する必要が
> あるのでしょうか?
Windows 以外の環境では、rdocファイルは不要だと思うので
Windows環境だけで動的に生成するようにしてます。
> 必要があるのなら、.cvsignoreに追加すると良いのでは
> ないでしょうか。
はい。追加しておきました。
助田 雅紀
Date: January 26, 2006
From: H.Yamamoto <ocean@xxxxxxxxxxxxxxx>
In-reply-to:
<20060126091829.1EF2DC80.ocean@xxxxxxxxxxxxxxx>
References:
<34e00f690601251453y6d0f1f5dr10f29c0ff69741fc@xxxxxxxxxxxxxx> <20060126091829.1EF2DC80.ocean@xxxxxxxxxxxxxxx>
山本です。
>>> $0= で origargv を変更しているのが environ にも影響している感じなのですが、
>>> この処理って本当に必要なんでしょうか?environ を変更するのと同じぐらい
>>> 危ない処理に思えますが・・・
>>
>>わたなべてつやさんの情報によりHP/UXではsetproctitleを使うように作ったつもりなんですが。
>>ruby_setenv("",NULL)が動くってことは、setproctitleの検出に失敗しているということなんでしょうか。
>
>HP TestDrive には HP のハードで動く OS がいくつか用意されていて、私の試したのはそのうちの
>
>Red Hat Ent Linux AS 4.0 on AMD
>ProLiant DL145 2.2GHz(Opteron)
>td189.testdrive.hp.com
>
>なので、HP/UX ではありません。この環境では setproctitle は存在しないようでした。
>
>http://www.testdrive.hp.com/current.shtml
なお、cygwin では元々 setenv(3) を呼んでいるのですが、
http://archives.postgresql.org/pgsql-cygwin/2002-02/msg00090.php
を見る限りでは cygwin にも setproctitle や pstat(SET_CMD がないように見えるので、
同じ問題があるかもしれません。試してはいませんが・・・
# 3GB 確保してフルインストールしたところ、99% 完了したところで disk full になり、
# パーティションを拡張してリトライしたところ最初からやり直しになってしまったので
# cygwin は二度とインストールしないことに決めました。
Date: January 26, 2006
From: H.Yamamoto <ocean@xxxxxxxxxxxxxxx>
In-reply-to:
<34e00f690601251453y6d0f1f5dr10f29c0ff69741fc@xxxxxxxxxxxxxx>
References:
<20060125133907.DECE1E00.ocean@xxxxxxxxxxxxxxx> <34e00f690601251453y6d0f1f5dr10f29c0ff69741fc@xxxxxxxxxxxxxx>
山本です。
>> $0= で origargv を変更しているのが environ にも影響している感じなのですが、
>> この処理って本当に必要なんでしょうか?environ を変更するのと同じぐらい
>> 危ない処理に思えますが・・・
>
>わたなべてつやさんの情報によりHP/UXではsetproctitleを使うように作ったつもりなんですが。
>ruby_setenv("",NULL)が動くってことは、setproctitleの検出に失敗しているということなんでしょうか。
HP TestDrive には HP のハードで動く OS がいくつか用意されていて、私の試したのはそのうちの
Red Hat Ent Linux AS 4.0 on AMD
ProLiant DL145 2.2GHz(Opteron)
td189.testdrive.hp.com
なので、HP/UX ではありません。この環境では setproctitle は存在しないようでした。
http://www.testdrive.hp.com/current.shtml
Date: January 25, 2006
From: Yukihiro Matsumoto <matz@xxxxxxxxxxxxx>
In-reply-to:
<20060125133907.DECE1E00.ocean@xxxxxxxxxxxxxxx>
References:
<20060124180246.ED432BB0.ocean@xxxxxxxxxxxxxxx> <20060124193756.29A87EF0.ocean@xxxxxxxxxxxxxxx> <20060125133907.DECE1E00.ocean@xxxxxxxxxxxxxxx>
まつもと ゆきひろです
マシン不調でなかなか登場できません。
On 1/25/06, H. Yamamoto <ocean@xxxxxxxxxxxxxxx> wrote:
> > p ENV
> > $0 = $0 # test/unit/ui/console/testrunner.rb (HEAD) modifies $0
> > p ENV
> >
> >パッチを当てると、HEAD も ruby_1_8 も二番目の p ENV が { , , , , } になります。
> >
> >ruby_1_8 でエラーにならなかったのは、test/unit/ui/console/testrunner.rb で
> >$0 を変更していなかったからでした。
> >
> >そして $0= の実装である set_arg0 には
> >
> > ruby_setenv("", NULL); /* duplicate environ vars */
> >
> >なんて行があるので、どうも setenv の独自実装と $0= は依存している感じですね。
>
> $0= で origargv を変更しているのが environ にも影響している感じなのですが、
> この処理って本当に必要なんでしょうか?environ を変更するのと同じぐらい
> 危ない処理に思えますが・・・
わたなべてつやさんの情報によりHP/UXではsetproctitleを使うように作ったつもりなんですが。ruby_setenv("",NULL)が動くってことは、setproctitleの検出に失敗しているということなんでしょうか。
Date: January 25, 2006
From: H.Yamamoto <ocean@xxxxxxxxxxxxxxx>
In-reply-to:
<20060124193756.29A87EF0.ocean@xxxxxxxxxxxxxxx>
References:
<20060124180246.ED432BB0.ocean@xxxxxxxxxxxxxxx> <20060124193756.29A87EF0.ocean@xxxxxxxxxxxxxxx>
山本です。
>もう今日はやらないつもりでしたが、思いついたことがあったので試して
>みたところ、かなり単純化できました。
>
> p ENV
> $0 = $0 # test/unit/ui/console/testrunner.rb (HEAD) modifies $0
> p ENV
>
>パッチを当てると、HEAD も ruby_1_8 も二番目の p ENV が { , , , , } になります。
>
>ruby_1_8 でエラーにならなかったのは、test/unit/ui/console/testrunner.rb で
>$0 を変更していなかったからでした。
>
>そして $0= の実装である set_arg0 には
>
> ruby_setenv("", NULL); /* duplicate environ vars */
>
>なんて行があるので、どうも setenv の独自実装と $0= は依存している感じですね。
$0= で origargv を変更しているのが environ にも影響している感じなのですが、
この処理って本当に必要なんでしょうか?environ を変更するのと同じぐらい
危ない処理に思えますが・・・
マニュアルによると、$0= を使うと ps の結果が変わることがあるという説明なので、
変わらなくなっても仕様に反することにはならないかなと思うのですが・・・
とりあえず、下のパッチで TestDrive でも成功するようになりました。
まとめると、
1. set_arg0 は environ がコピーされることを前提とする場合がある(setproctitle(3)
がない場合など)
2. にもかかわらず ruby_setenv で独自実装を使わず setenv(3) を使うと、set_arg0 を
呼んだときに一緒に environ まで変更されてしまうことがある。
3. しかし、environ を直接変更するのは規約に違反し、Solaris では SEGV するらしい。
Index: configure.in
===================================================================
RCS file: /src/ruby/configure.in,v
retrieving revision 1.296
diff -u -w -b -p -r1.296 configure.in
--- configure.in 22 Jan 2006 11:34:51 -0000 1.296
+++ configure.in 24 Jan 2006 01:45:39 -0000
@@ -506,7 +506,7 @@ AC_CHECK_FUNCS(fmod killpg wait4 waitpid
getpriority getrlimit setrlimit\
dlopen sigprocmask sigaction _setjmp vsnprintf snprintf\
setsid telldir seekdir fchmod mktime timegm cosh sinh tanh\
- setuid setgid daemon select_large_fdset)
+ setuid setgid daemon select_large_fdset unsetenv)
AC_ARG_ENABLE(setreuid,
[ --enable-setreuid use setreuid()/setregid() according to need
even if obsolete.],
[use_setreuid=$enableval])
@@ -514,6 +514,20 @@ if test "$use_setreuid" = yes; then
AC_DEFINE(USE_SETREUID)
AC_DEFINE(USE_SETREGID)
fi
+AC_CACHE_CHECK(for setenv (2 arguments), rb_cv_have_setenv_2args,
+ [AC_TRY_COMPILE([#include <stdlib.h>], [setenv("foo", "foo");],
+ rb_cv_have_setenv_2args=yes,
+ rb_cv_have_setenv_2args=no)])
+if test "$rb_cv_have_setenv_2args" = yes; then
+ AC_DEFINE(HAVE_SETENV_2ARGS)
+fi
+AC_CACHE_CHECK(for setenv (3 arguments), rb_cv_have_setenv_3args,
+ [AC_TRY_COMPILE([#include <stdlib.h>], [setenv("foo", "foo", 1);],
+ rb_cv_have_setenv_3args=yes,
+ rb_cv_have_setenv_3args=no)])
+if test "$rb_cv_have_setenv_3args" = yes; then
+ AC_DEFINE(HAVE_SETENV_3ARGS)
+fi
AC_STRUCT_TIMEZONE
AC_CACHE_CHECK(for struct tm.tm_gmtoff, rb_cv_member_struct_tm_tm_gmtoff,
[AC_TRY_COMPILE([#include <time.h>],
Index: hash.c
===================================================================
RCS file: /src/ruby/hash.c,v
retrieving revision 1.159
diff -u -w -b -p -r1.159 hash.c
--- hash.c 20 Oct 2005 02:56:22 -0000 1.159
+++ hash.c 24 Jan 2006 10:03:23 -0000
@@ -1690,7 +1690,14 @@ ruby_setenv(const char *name, const char
* RTL's environ global variable directly yet.
*/
SetEnvironmentVariable(name,value);
-#elif defined __CYGWIN__
+#elif defined(HAVE_SETENV_2ARGS) && defined(HAVE_UNSETENV)
+#undef setenv
+#undef unsetenv
+ if (value)
+ setenv(name,value);
+ else
+ unsetenv(name);
+#elif defined(HAVE_SETENV_3ARGS) && defined(HAVE_UNSETENV)
#undef setenv
#undef unsetenv
if (value)
Index: ruby.c
===================================================================
RCS file: /src/ruby/ruby.c,v
retrieving revision 1.112
diff -u -w -b -p -r1.112 ruby.c
--- ruby.c 12 Dec 2005 00:35:08 -0000 1.112
+++ ruby.c 24 Jan 2006 11:25:49 -0000
@@ -1041,51 +1041,10 @@ set_arg0(VALUE val, ID id)
j.pst_command = s;
pstat(PSTAT_SETCMD, j, i, 0, 0);
}
- rb_progname = rb_tainted_str_new(s, i);
#elif defined(HAVE_SETPROCTITLE)
setproctitle("%.*s", (int)i, s);
- rb_progname = rb_tainted_str_new(s, i);
-#else
- if (len == 0) {
- char *s = origargv[0];
- int i;
-
- s += strlen(s);
- /* See if all the arguments are contiguous in memory */
- for (i = 1; i < origargc; i++) {
- if (origargv[i] == s + 1) {
- s++;
- s += strlen(s); /* this one is ok too */
- }
- else {
- break;
- }
- }
-#ifndef DOSISH
- if (s + 1 == envspace.begin) {
- s = envspace.end;
- ruby_setenv("", NULL); /* duplicate environ vars */
- }
-#endif
- len = s - origargv[0];
- }
-
- if (i >= len) {
- i = len;
- memcpy(origargv[0], s, i);
- origargv[0][i] = '\0';
- }
- else {
- memcpy(origargv[0], s, i);
- s = origargv[0]+i;
- *s++ = '\0';
- while (++i < len)
- *s++ = ' ';
- for (i = 1; i < origargc; i++)
- origargv[i] = 0;
- }
- rb_progname = rb_tainted_str_new2(origargv[0]);
#endif
+ rb_progname = rb_tainted_str_new(s, i);
}
void
Date: January 25, 2006
From: Kazuhiro NISHIYAMA <zn@xxxxxxxxxxxxx>
西山和広です。 ext/win32ole/extconf.rbのcreate_docfileで.documentを 作成していてcvs updateで ? ext/win32ole/.document と出てくるのですが、これは動的に生成する必要が あるのでしょうか? 必要があるのなら、.cvsignoreに追加すると良いのでは ないでしょうか。 必要がないのなら、.document自体をcvs addすると 良いのではないでしょうか。 -- |ZnZ(ゼット エヌ ゼット) |西山和広(Kazuhiro NISHIYAMA)
Date: January 24, 2006
From: H.Yamamoto <ocean@xxxxxxxxxxxxxxx>
In-reply-to:
<20060124180246.ED432BB0.ocean@xxxxxxxxxxxxxxx>
References:
<20060124175322.25CDB1F0.ocean@xxxxxxxxxxxxxxx> <20060124180246.ED432BB0.ocean@xxxxxxxxxxxxxxx>
山本です。
もう今日はやらないつもりでしたが、思いついたことがあったので試して
みたところ、かなり単純化できました。
p ENV
$0 = $0 # test/unit/ui/console/testrunner.rb (HEAD) modifies $0
p ENV
パッチを当てると、HEAD も ruby_1_8 も二番目の p ENV が { , , , , } になります。
ruby_1_8 でエラーにならなかったのは、test/unit/ui/console/testrunner.rb で
$0 を変更していなかったからでした。
そして $0= の実装である set_arg0 には
ruby_setenv("", NULL); /* duplicate environ vars */
なんて行があるので、どうも setenv の独自実装と $0= は依存している感じですね。
Date: January 24, 2006
From: H.Yamamoto <ocean@xxxxxxxxxxxxxxx>
In-reply-to:
<20060124175322.25CDB1F0.ocean@xxxxxxxxxxxxxxx>
References:
<20060124153624.EF710E00.ocean@xxxxxxxxxxxxxxx> <20060124175322.25CDB1F0.ocean@xxxxxxxxxxxxxxx>
山本です。
>よくわかりませんが、test/unit を通すと挙動が変わりますね。
>
>//////////////////////////
>// a.rb
>
>require 'test/unit/autorunner'
>
>f = File.join(File.dirname(__FILE__), "b.rb")
>
>r = Test::Unit::AutoRunner.new(true)
>r.process_args([f])
>
>p ENV
>r.run
>p ENV
>
>//////////////////////////
>// b.rb
>
>require 'test/unit/testcase'
>
>class TestSome < Test::Unit::TestCase
> def test_some
> # do nothing
> end
>end
>
>
>HEAD + パッチだと、二番目の p ENV が { , , , , } になります。ruby_1_8 や
>パッチなしだとそうなりません。今日はここまで。
起動の仕方を書き忘れました。ビルドしたディレクトリに入って、
system("./miniruby", "../ruby/runruby.rb", "--ext='.ext'", "--", "../../a.rb")
でキックしました。
Date: January 24, 2006
From: H.Yamamoto <ocean@xxxxxxxxxxxxxxx>
In-reply-to:
<20060124153624.EF710E00.ocean@xxxxxxxxxxxxxxx>
References:
<20060124152823.698C.USA@xxxxxxxxxxxxxxxxx> <20060124153624.EF710E00.ocean@xxxxxxxxxxxxxxx>
山本です。
よくわかりませんが、test/unit を通すと挙動が変わりますね。
//////////////////////////
// a.rb
require 'test/unit/autorunner'
f = File.join(File.dirname(__FILE__), "b.rb")
r = Test::Unit::AutoRunner.new(true)
r.process_args([f])
p ENV
r.run
p ENV
//////////////////////////
// b.rb
require 'test/unit/testcase'
class TestSome < Test::Unit::TestCase
def test_some
# do nothing
end
end
HEAD + パッチだと、二番目の p ENV が { , , , , } になります。ruby_1_8 や
パッチなしだとそうなりません。今日はここまで。
Date: January 24, 2006
From: H.Yamamoto <ocean@xxxxxxxxxxxxxxx>
In-reply-to:
<20060124152823.698C.USA@xxxxxxxxxxxxxxxxx>
References:
<20060124152729.D3059680.ocean@xxxxxxxxxxxxxxx> <20060124152823.698C.USA@xxxxxxxxxxxxxxxxx>
山本です。
>こんにちは、なかむら(う)です。
>
>In message "[ruby-dev:28274] Re: [PATCH] solaris 10 isinf and ruby_setenv
>fixes"
> on Jan.24,2006 15:27:41, <ocean@xxxxxxxxxxxxxxx> wrote:
>| 何か、環境変数がうまく伝わっていない感じで、
>| test/ruby/beginmainend.rb で p ENV すると { , , , , , , }
>| みたいになって、良くない感じです。いったん取り下げます。
>
>つまり、setenv(とunsetenv)を使った上でちゃんと伝播するかどう
>かまでconfigureでチェックすればいいんですかねえ。
># と、言うだけで、パッチはないんですが
そうですね、でも原因がわからないのが気持ち悪いので、しばらく究明してみるつもりで
います。(時間がたつと接続を切断されてしまうのでやりにくいのですが > TestDrive)
あと、書き忘れたのですが、同様のパッチを 1.8 に当てると動くのです。HEAD に当てる
と先のエラーがでます。下のパッチなのですが OS の setenv の挙動にしては HEAD と
1.8 で違いが出るのが???です。(パッチを当てそこなった?)
Index: configure.in
===================================================================
RCS file: /src/ruby/configure.in,v
retrieving revision 1.296
diff -u -w -b -p -r1.296 configure.in
--- configure.in 22 Jan 2006 11:34:51 -0000 1.296
+++ configure.in 24 Jan 2006 01:45:39 -0000
@@ -506,7 +506,7 @@ AC_CHECK_FUNCS(fmod killpg wait4 waitpid
getpriority getrlimit setrlimit\
dlopen sigprocmask sigaction _setjmp vsnprintf snprintf\
setsid telldir seekdir fchmod mktime timegm cosh sinh tanh\
- setuid setgid daemon select_large_fdset)
+ setuid setgid daemon select_large_fdset unsetenv)
AC_ARG_ENABLE(setreuid,
[ --enable-setreuid use setreuid()/setregid() according to need
even if obsolete.],
[use_setreuid=$enableval])
@@ -514,6 +514,20 @@ if test "$use_setreuid" = yes; then
AC_DEFINE(USE_SETREUID)
AC_DEFINE(USE_SETREGID)
fi
+AC_CACHE_CHECK(for setenv (2 arguments), rb_cv_have_setenv_2args,
+ [AC_TRY_COMPILE([#include <stdlib.h>], [setenv("foo", "foo");],
+ rb_cv_have_setenv_2args=yes,
+ rb_cv_have_setenv_2args=no)])
+if test "$rb_cv_have_setenv_2args" = yes; then
+ AC_DEFINE(HAVE_SETENV_2ARGS)
+fi
+AC_CACHE_CHECK(for setenv (3 arguments), rb_cv_have_setenv_3args,
+ [AC_TRY_COMPILE([#include <stdlib.h>], [setenv("foo", "foo", 1);],
+ rb_cv_have_setenv_3args=yes,
+ rb_cv_have_setenv_3args=no)])
+if test "$rb_cv_have_setenv_3args" = yes; then
+ AC_DEFINE(HAVE_SETENV_3ARGS)
+fi
AC_STRUCT_TIMEZONE
AC_CACHE_CHECK(for struct tm.tm_gmtoff, rb_cv_member_struct_tm_tm_gmtoff,
[AC_TRY_COMPILE([#include <time.h>],
Index: hash.c
===================================================================
RCS file: /src/ruby/hash.c,v
retrieving revision 1.159
diff -u -w -b -p -r1.159 hash.c
--- hash.c 20 Oct 2005 02:56:22 -0000 1.159
+++ hash.c 24 Jan 2006 01:46:57 -0000
@@ -1690,7 +1690,14 @@ ruby_setenv(const char *name, const char
* RTL's environ global variable directly yet.
*/
SetEnvironmentVariable(name,value);
-#elif defined __CYGWIN__
+#elif defined(HAVE_SETENV_2ARGS) && defined(HAVE_UNSETENV)
+#undef setenv
+#undef unsetenv
+ if (value)
+ setenv(name,value);
+ else
+ unsetenv(name);
+#elif defined(HAVE_SETENV_3ARGS) && defined(HAVE_UNSETENV)
#undef setenv
#undef unsetenv
if (value)
Date: January 24, 2006
From: "U.Nakamura" <usa@xxxxxxxxxxxxxxxxx>
In-reply-to:
<20060124152729.D3059680.ocean@xxxxxxxxxxxxxxx>
References:
<20060123193637.6B215698.ocean@xxxxxxxxxxxxxxx> <20060124152729.D3059680.ocean@xxxxxxxxxxxxxxx>
こんにちは、なかむら(う)です。
In message "[ruby-dev:28274] Re: [PATCH] solaris 10 isinf and ruby_setenv
fixes"
on Jan.24,2006 15:27:41, <ocean@xxxxxxxxxxxxxxx> wrote:
| 何か、環境変数がうまく伝わっていない感じで、
| test/ruby/beginmainend.rb で p ENV すると { , , , , , , }
| みたいになって、良くない感じです。いったん取り下げます。
つまり、setenv(とunsetenv)を使った上でちゃんと伝播するかどう
かまでconfigureでチェックすればいいんですかねえ。
# と、言うだけで、パッチはないんですが
それでは。
--
U.Nakamura <usa@xxxxxxxxxxxxxxxxx>
Date: January 24, 2006
From: H.Yamamoto <ocean@xxxxxxxxxxxxxxx>
In-reply-to:
<20060123193637.6B215698.ocean@xxxxxxxxxxxxxxx>
References:
<4179-Mon23Jan2006184840+0900-eban@xxxxxxxxxxxx> <20060123193637.6B215698.ocean@xxxxxxxxxxxxxxx>
山本です。
HP TestDrive の
Red Hat Ent Linux AS 4.0 on AMD
ProLiant DL145 2.2GHz(Opteron)
td189.testdrive.hp.com
で試してみたのですが、うまく動きませんでした (--;
test_beginendblock のような、別プロセスを立ち上げるテストが
失敗します。(libruby.so.1.9.0 のロードに失敗したとか言われます)
何か、環境変数がうまく伝わっていない感じで、
test/ruby/beginmainend.rb で p ENV すると { , , , , , , }
みたいになって、良くない感じです。いったん取り下げます。
BeOS では動いたし、a.rb で
IO.popen("./miniruby ./b.rb")
として b.rb で
p ENV
としてもちゃんと表示されるのですが・・・
Date: January 23, 2006
From: H.Yamamoto <ocean@xxxxxxxxxxxxxxx>
In-reply-to:
<4179-Mon23Jan2006184840+0900-eban@xxxxxxxxxxxx>
References:
<20060123181635.69AC0BC0.ocean@xxxxxxxxxxxxxxx> <4179-Mon23Jan2006184840+0900-eban@xxxxxxxxxxxx>
山本です。 >わたなべです。 > >[ruby-dev:28270] がなぜかまだ届いてないのでこちらにreply。 > >"H.Yamamoto" <ocean@xxxxxxxxxxxxxxx> writes: > >> > http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-list/2257 >> > rbgw で setenv(3) がバグっているため、回避するために自前の setenv を >> > 実装。rbgw って?MingW の前身でしょうか。いずれにせよ、Windows 固有の >> > 問題のように見えました。 > >Ruby GNU Win32のつもり。Cygwinの前身はGNU Win32と名乗ってま >した。そこに「作っちゃいます」と書いてありますが、その後実際 >はなにもしてません。この問題はCygwin固有です。 > >ひょっとして勘違いがあるかもしれませんが、この当時はすべての >プラットフォームでenvironをいじるのではなくsetenv(3)を使って >ました。 #else はこの時実装されたとばかり思ってました。勘違いですね(汗) >> なので、rbgw も #ifdef _WIN32 の処理に入るんじゃないかという気がしました。 >> 違う場合は、適宜 #else にまわるように configure などで調節する意図です。 > >現在Cygwinでsetenv/unsetenvを使っているのは、Rubyがenvironを >いじる実装になったら逆になぜか機能しなかったからです。(たぶ >んその当時のCygwin自身のバグ。今はどうかわからないけど動い >ているのでそのままになっている。) > >結論としては2種類ぐらいならsetenvをconfigureでもいいかな、と。 >unsetenvがどこにでもあるかどうかはまた別問題だけど。 unsetenv については configure でチェックするようにしたので、 defined HAVE_UNSETENV でチェックできていると思います。 # setenv と unsetenv のどちらかがない環境では、今までどおり ruby 独自 # 実装を使うはず。
Date: January 23, 2006
From: WATANABE Hirofumi <eban@xxxxxxxxxxxx>
In-reply-to:
"H.Yamamoto"'s message of "Mon, 23 Jan 2006 18:16:47 +0900" <20060123181635.69AC0BC0.ocean@xxxxxxxxxxxxxxx>
References:
<OFDC7A1FAA.CD90E9D1-ONC22570F5.004629FE-C22570F5.00470914@xxxxxxxxxxxxx> <20060123180349.F9416DE0.ocean@xxxxxxxxxxxxxxx> <20060123181635.69AC0BC0.ocean@xxxxxxxxxxxxxxx>
わたなべです。 [ruby-dev:28270] がなぜかまだ届いてないのでこちらにreply。 "H.Yamamoto" <ocean@xxxxxxxxxxxxxxx> writes: > > http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-list/2257 > > rbgw で setenv(3) がバグっているため、回避するために自前の setenv を > > 実装。rbgw って?MingW の前身でしょうか。いずれにせよ、Windows 固有の > > 問題のように見えました。 Ruby GNU Win32のつもり。Cygwinの前身はGNU Win32と名乗ってま した。そこに「作っちゃいます」と書いてありますが、その後実際 はなにもしてません。この問題はCygwin固有です。 ひょっとして勘違いがあるかもしれませんが、この当時はすべての プラットフォームでenvironをいじるのではなくsetenv(3)を使って ました。 > なので、rbgw も #ifdef _WIN32 の処理に入るんじゃないかという気がしました。 > 違う場合は、適宜 #else にまわるように configure などで調節する意図です。 現在Cygwinでsetenv/unsetenvを使っているのは、Rubyがenvironを いじる実装になったら逆になぜか機能しなかったからです。(たぶ んその当時のCygwin自身のバグ。今はどうかわからないけど動い ているのでそのままになっている。) 結論としては2種類ぐらいならsetenvをconfigureでもいいかな、と。 unsetenvがどこにでもあるかどうかはまた別問題だけど。 -- わたなべひろふみ
Date: January 23, 2006
From: H.Yamamoto <ocean@xxxxxxxxxxxxxxx>
In-reply-to:
<20060123180349.F9416DE0.ocean@xxxxxxxxxxxxxxx>
References:
<OFDC7A1FAA.CD90E9D1-ONC22570F5.004629FE-C22570F5.00470914@xxxxxxxxxxxxx> <20060123180349.F9416DE0.ocean@xxxxxxxxxxxxxxx>
山本です。 > http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-list/2257 > rbgw で setenv(3) がバグっているため、回避するために自前の setenv を > 実装。rbgw って?MingW の前身でしょうか。いずれにせよ、Windows 固有の > 問題のように見えました。 なので、rbgw も #ifdef _WIN32 の処理に入るんじゃないかという気がしました。 違う場合は、適宜 #else にまわるように configure などで調節する意図です。
Date: January 23, 2006
From: H.Yamamoto <ocean@xxxxxxxxxxxxxxx>
In-reply-to:
<OFDC7A1FAA.CD90E9D1-ONC22570F5.004629FE-C22570F5.00470914@xxxxxxxxxxxxx>
References:
<OFDC7A1FAA.CD90E9D1-ONC22570F5.004629FE-C22570F5.00470914@xxxxxxxxxxxxx>
山本です。 http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/7138 に Solaris 10 で environ の置き換えを行わないパッチが出ているのですが、http://www.unix.org/single_unix_specification/ で見る限り Solaris 10 以外でも environ を置き換えた場合の挙動は保証しないという ことのようです。 cygwin と soraris でだけ置き換えをしないよりも、置き換えの必要な環境でだけ置き換えたほうが いいような気がするのですが、いかがですか? 念のため、導入の経緯などを調べてみました。 http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-list/2257 rbgw で setenv(3) がバグっているため、回避するために自前の setenv を 実装。rbgw って?MingW の前身でしょうか。いずれにせよ、Windows 固有の 問題のように見えました。 http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-dev/10885 setenv(3) は古い環境では引数が二個、新しい環境では三個で、数がそろって いない。 setenv の引数の数は、こんな感じで回避できないでしょうか。見よう見真似で パッチにしてみました。 Index: configure.in =================================================================== RCS file: /src/ruby/configure.in,v retrieving revision 1.212.2.40 diff -u -w -b -p -r1.212.2.40 configure.in --- configure.in 24 Nov 2005 12:07:18 -0000 1.212.2.40 +++ configure.in 23 Jan 2006 08:53:17 -0000 @@ -398,6 +398,10 @@ bow) ac_cv_func_setitimer=no ;; superux*) ac_cv_func_setitimer=no ;; +solaris*2.10) ac_cv_func_isinf=yes + LIBS="-lm $LIBS" + ;; + *) LIBS="-lm $LIBS";; esac AC_CHECK_LIB(crypt, crypt) @@ -444,7 +448,7 @@ AC_CHECK_FUNCS(fmod killpg wait4 waitpid lchown lchmod getpgrp setpgrp getpgid setpgid initgroups\ getgroups setgroups getpriority getrlimit dlopen sigprocmask\ sigaction _setjmp setsid telldir seekdir fchmod mktime timegm\ - cosh sinh tanh setuid setgid) + cosh sinh tanh setuid setgid unsetenv) AC_ARG_ENABLE(setreuid, [ --enable-setreuid use setreuid()/setregid() according to need even if obsolete.], [use_setreuid=$enableval]) @@ -452,6 +456,20 @@ if test "$use_setreuid" = yes; then AC_DEFINE(USE_SETREUID) AC_DEFINE(USE_SETREGID) fi +AC_CACHE_CHECK(for 2 arguments setenv, rb_cv_have_2_arg_setenv, + [AC_TRY_COMPILE([#include <stdlib.h>], [setenv("foo", "foo");], + rb_cv_have_2_arg_setenv=yes, + rb_cv_have_2_arg_setenv=no)]) +if test "$rb_cv_have_2_arg_setenv" = yes; then + AC_DEFINE(HAVE_2_ARG_SETENV) +fi +AC_CACHE_CHECK(for 3 arguments setenv, rb_cv_have_3_arg_setenv, + [AC_TRY_COMPILE([#include <stdlib.h>], [setenv("foo", "foo", 1);], + rb_cv_have_3_arg_setenv=yes, + rb_cv_have_3_arg_setenv=no)]) +if test "$rb_cv_have_3_arg_setenv" = yes; then + AC_DEFINE(HAVE_3_ARG_SETENV) +fi AC_STRUCT_TIMEZONE AC_CACHE_CHECK(for struct tm.tm_gmtoff, rb_cv_member_struct_tm_tm_gmtoff, [AC_TRY_COMPILE([#include <time.h>], Index: hash.c =================================================================== RCS file: /src/ruby/hash.c,v retrieving revision 1.128.2.14 diff -u -w -b -p -r1.128.2.14 hash.c --- hash.c 19 Jul 2005 08:25:37 -0000 1.128.2.14 +++ hash.c 23 Jan 2006 08:37:27 -0000 @@ -1812,7 +1812,14 @@ ruby_setenv(name, value) * RTL's environ global variable directly yet. */ SetEnvironmentVariable(name,value); -#elif defined __CYGWIN__ +#elif defined HAVE_2_ARG_SETENV && defined HAVE_UNSETENV +#undef setenv +#undef unsetenv + if (value) + setenv(name,value); + else + unsetenv(name); +#elif defined HAVE_3_ARG_SETENV && defined HAVE_UNSETENV #undef setenv #undef unsetenv if (value)
Date: January 23, 2006
From: Tanaka Akira <akr@xxxxxxxx>
In-reply-to:
<ygezmlox0z2.wl%ume@xxxxxxxxxxxx> (Hajimu UMEMOTO's message of "Sun, 22 Jan 2006 14:53:43 +0900")
References:
<ygezmlrqybi.wl%ume@xxxxxxxxxxxx> <87lkxaaoyf.fsf@xxxxxxxx> <ygevewehdeu.wl%ume@xxxxxxxxxxxx> <ygeu0byh62e.wl%ume@xxxxxxxxxxxx> <87acdq9thc.fsf@xxxxxxxx> <ygeoe26gnuj.wl%ume@xxxxxxxxxxxx> <874q3y9ljs.fsf@xxxxxxxx> <ygelkxagkse.wl%ume@xxxxxxxxxxxx> <87u0by83lj.fsf@xxxxxxxx> <yge8xt9y17d.wl%ume@xxxxxxxxxxxx> <87zmlph0xx.fsf@xxxxxxxx> <87u0bxgw1m.fsf@xxxxxxxx> <ygezmlox0z2.wl%ume@xxxxxxxxxxxx>
In article <ygezmlox0z2.wl%ume@xxxxxxxxxxxx>, Hajimu UMEMOTO <ume@xxxxxxxxxxxx> writes: > akr> FUNCTION_CALL_MAY_RETURN_TWICE を getcontext の前で呼ぶと直 > akr> るのは、(0 ? setjmp() : 0) の真偽判定で carry flag が 0 にな > akr> るから、ですかね。 > > そういうことになるのでしょうね。なるほど。 ただ、この説明では getcontext の前後両方に入れたときに落ちる という xcgroup の問題を理解できないので、このあたりにはなん かまだ他の問題が潜んでいる気もします。 -- [田中 哲][たなか あきら][Tanaka Akira]
Date: January 23, 2006
From: "U.Nakamura" <usa@xxxxxxxxxxxxxxxxx>
In-reply-to:
<43D41562.6020507@xxxxxxxxxxx>
References:
<20060119102005.296D.USA@xxxxxxxxxxxxxxxxx> <43D41562.6020507@xxxxxxxxxxx>
こんにちは、なかむら(う)です。
In message "[ruby-dev:28267] Re: 1.8.5 release plan?"
on Jan.23,2006 08:29:54, <root@xxxxxxxxxxx> wrote:
| >ブランチを切る必要はないんじゃないかと思うんですが、いかがな
| >もんでしょうか。
| >前回も切ってないし、単にruby_1_8ブランチに対して制限をかける
| >だけでいいんじゃないかと思います。
| >
| >
| 制限をかけるってどのように?
単に禁止を通達するだけです。
別にシステム的な制限をかけろっつー話ではありません。
それでは。
--
U.Nakamura <usa@xxxxxxxxxxxxxxxxx>
Date: January 22, 2006
From: "URABE Shyouhei aka. mput" <root@xxxxxxxxxxx>
In-reply-to:
<20060119102005.296D.USA@xxxxxxxxxxxxxxxxx>
References:
<43CE7025.5050901@xxxxxxxxxxx> <20060119102005.296D.USA@xxxxxxxxxxxxxxxxx>
卜部です。 U.Nakamura wrote: >ブランチを切る必要はないんじゃないかと思うんですが、いかがな >もんでしょうか。 >前回も切ってないし、単にruby_1_8ブランチに対して制限をかける >だけでいいんじゃないかと思います。 > > 制限をかけるってどのように?
Date: January 22, 2006
From: Hajimu UMEMOTO <ume@xxxxxxxxxxxx>
In-reply-to:
<87u0bxgw1m.fsf@xxxxxxxx>
References:
<ygezmlrqybi.wl%ume@xxxxxxxxxxxx> <87lkxaaoyf.fsf@xxxxxxxx> <ygevewehdeu.wl%ume@xxxxxxxxxxxx> <ygeu0byh62e.wl%ume@xxxxxxxxxxxx> <87acdq9thc.fsf@xxxxxxxx> <ygeoe26gnuj.wl%ume@xxxxxxxxxxxx> <874q3y9ljs.fsf@xxxxxxxx> <ygelkxagkse.wl%ume@xxxxxxxxxxxx> <87u0by83lj.fsf@xxxxxxxx> <yge8xt9y17d.wl%ume@xxxxxxxxxxxx> <87zmlph0xx.fsf@xxxxxxxx> <87u0bxgw1m.fsf@xxxxxxxx>
梅本です。 >>>>> On Sun, 22 Jan 2006 05:38:09 +0900 >>>>> Tanaka Akira <akr@xxxxxxxx> said: akr> In article <87zmlph0xx.fsf@xxxxxxxx>, akr> Tanaka Akira <akr@xxxxxxxx> writes: > というわけで、carry flag が 1 になっているのがなぜか、という > 話なんですが、さて? akr> そっか、carry flag が 1 なのは、getcontext で保存する時に 1 akr> だったからですね。 ううむ、そういうことなのか。 akr> http://www.freebsd.org/cgi/query-pr.cgi?pr=92110 に送ってお akr> きました。 どうもありがとうございます。 akr> それはそれとして、getcontext の前で 0 にしておけばごまかせる akr> わけで、次のようにしてみるとどうでしょう? AMD64 でも問題が収まるとこを確認できました。 akr> FUNCTION_CALL_MAY_RETURN_TWICE を getcontext の前で呼ぶと直 akr> るのは、(0 ? setjmp() : 0) の真偽判定で carry flag が 0 にな akr> るから、ですかね。 そういうことになるのでしょうね。なるほど。 -- 梅本 肇 @ インターネット互助会横浜 http://www.imasy.org/~ume/ ume@xxxxxxxxxxxx ume@{,jp.}FreeBSD.org プログラムは書いた人の意図ではなく書かれた通り動く I hate Modula-3 :-)
Date: January 21, 2006
From: Tanaka Akira <akr@xxxxxxxx>
In-reply-to:
<87zmlph0xx.fsf@xxxxxxxx> (Tanaka Akira's message of "Sun, 22 Jan 2006 03:52:22 +0900")
References:
<ygezmlrqybi.wl%ume@xxxxxxxxxxxx> <87lkxaaoyf.fsf@xxxxxxxx> <ygevewehdeu.wl%ume@xxxxxxxxxxxx> <ygeu0byh62e.wl%ume@xxxxxxxxxxxx> <87acdq9thc.fsf@xxxxxxxx> <ygeoe26gnuj.wl%ume@xxxxxxxxxxxx> <874q3y9ljs.fsf@xxxxxxxx> <ygelkxagkse.wl%ume@xxxxxxxxxxxx> <87u0by83lj.fsf@xxxxxxxx> <yge8xt9y17d.wl%ume@xxxxxxxxxxxx> <87zmlph0xx.fsf@xxxxxxxx>
In article <87zmlph0xx.fsf@xxxxxxxx>, Tanaka Akira <akr@xxxxxxxx> writes: > というわけで、carry flag が 1 になっているのがなぜか、という > 話なんですが、さて? そっか、carry flag が 1 なのは、getcontext で保存する時に 1 だったからですね。 http://www.freebsd.org/cgi/query-pr.cgi?pr=92110 に送ってお きました。 それはそれとして、getcontext の前で 0 にしておけばごまかせる わけで、次のようにしてみるとどうでしょう? Index: eval.c =================================================================== RCS file: /src/ruby/eval.c,v retrieving revision 1.871 diff -u -p -r1.871 eval.c --- eval.c 18 Jan 2006 15:00:58 -0000 1.871 +++ eval.c 21 Jan 2006 20:28:42 -0000 @@ -171,9 +171,11 @@ int function_call_may_return_twice_false #define FUNCTION_CALL_MAY_RETURN_TWICE 0 #endif #define ruby_longjmp(env, val) rb_jump_context(env, val) +static volatile int freebsd_clear_carry_flag = 0; #define ruby_setjmp(just_before_setjmp, j) ((j)->status = 0, \ (just_before_setjmp), \ FUNCTION_CALL_MAY_RETURN_TWICE, \ + freebsd_clear_carry_flag = freebsd_clear_carry_flag + freebsd_clear_carry_flag, \ getcontext(&(j)->context), \ FUNCTION_CALL_MAY_RETURN_TWICE, \ (j)->status) FUNCTION_CALL_MAY_RETURN_TWICE を getcontext の前で呼ぶと直 るのは、(0 ? setjmp() : 0) の真偽判定で carry flag が 0 にな るから、ですかね。 -- [田中 哲][たなか あきら][Tanaka Akira]
Date: January 21, 2006
From: Tanaka Akira <akr@xxxxxxxx>
In-reply-to:
<87zmlph0xx.fsf@xxxxxxxx> (Tanaka Akira's message of "Sun, 22 Jan 2006 03:52:22 +0900")
References:
<ygezmlrqybi.wl%ume@xxxxxxxxxxxx> <87lkxaaoyf.fsf@xxxxxxxx> <ygevewehdeu.wl%ume@xxxxxxxxxxxx> <ygeu0byh62e.wl%ume@xxxxxxxxxxxx> <87acdq9thc.fsf@xxxxxxxx> <ygeoe26gnuj.wl%ume@xxxxxxxxxxxx> <874q3y9ljs.fsf@xxxxxxxx> <ygelkxagkse.wl%ume@xxxxxxxxxxxx> <87u0by83lj.fsf@xxxxxxxx> <yge8xt9y17d.wl%ume@xxxxxxxxxxxx> <87zmlph0xx.fsf@xxxxxxxx>
In article <87zmlph0xx.fsf@xxxxxxxx>, Tanaka Akira <akr@xxxxxxxx> writes: > | eflags 0x206 518 > ここで eflags が奇数なので carry flag (eflags の最下位ビット) > は 0 です。 奇数というのは嘘です。偶数です。 -- [田中 哲][たなか あきら][Tanaka Akira]
Date: January 21, 2006
From: Tanaka Akira <akr@xxxxxxxx>
In-reply-to:
<yge8xt9y17d.wl%ume@xxxxxxxxxxxx> (Hajimu UMEMOTO's message of "Sun, 22 Jan 2006 01:51:03 +0900")
References:
<ygezmlrqybi.wl%ume@xxxxxxxxxxxx> <87lkxaaoyf.fsf@xxxxxxxx> <ygevewehdeu.wl%ume@xxxxxxxxxxxx> <ygeu0byh62e.wl%ume@xxxxxxxxxxxx> <87acdq9thc.fsf@xxxxxxxx> <ygeoe26gnuj.wl%ume@xxxxxxxxxxxx> <874q3y9ljs.fsf@xxxxxxxx> <ygelkxagkse.wl%ume@xxxxxxxxxxxx> <87u0by83lj.fsf@xxxxxxxx> <yge8xt9y17d.wl%ume@xxxxxxxxxxxx>
In article <yge8xt9y17d.wl%ume@xxxxxxxxxxxx>,
Hajimu UMEMOTO <ume@xxxxxxxxxxxx> writes:
> --enable-pthread なんですね。
はい。FUNCTION_CALL_MAY_RETURN_TWICE が使われるのは
主に --enable-pthread のときです。
(例外としては 1.8 かつ IA64 の場合があります)
> さっきダメだったのは --enable-pthread でしたが、試しに指定せずにやっ
> てみたら、無事作れて、make test も成功しました。
> FreeBSD の pthread 回りの秘孔を突いた?
AMD でなくても FreeBSD 5.4 で -mpentium4 としたら再現したので追いかけました。
コンパイルが compiling Win32API で止まるというところからテス
トケースを作ると次のようになります。
% cat z.rb
begin
raise StandardError
rescue StandardError
p $!
end
p :end
これは次のように #<StandardError: StandardError> と :end の
2行が表示されるのが適切な動作です。
% ruby z.rb
#<StandardError: StandardError>
:end
しかし、FreeBSD 5.4 で --enable-pthread とすると :end とだけ
表示して終わります。
% ./miniruby z.rb
:end
getcontext の直後と setcontext の直前で報告させるようにする
と、奇妙な挙動が観察されます。
Index: eval.c
===================================================================
RCS file: /src/ruby/eval.c,v
retrieving revision 1.871
diff -u -p -r1.871 eval.c
--- eval.c 18 Jan 2006 15:00:58 -0000 1.871
+++ eval.c 21 Jan 2006 17:51:23 -0000
@@ -94,6 +94,7 @@ rb_jump_context(env, val)
int val;
{
env->status = val;
+ fprintf(stderr, "before setcontext: %p %d\n", &env->context, env->status),
\
setcontext(&env->context);
abort(); /* ensure noreturn */
}
@@ -175,6 +176,7 @@ int function_call_may_return_twice_false
(just_before_setjmp), \
FUNCTION_CALL_MAY_RETURN_TWICE, \
getcontext(&(j)->context), \
+ fprintf(stderr, " after getcontext: %p %d\n", &(j)->context, (j)->status),
\
FUNCTION_CALL_MAY_RETURN_TWICE, \
(j)->status)
#else
% ./miniruby z.rb
after getcontext: 0xbfbfe7d0 0
after getcontext: 0xbfbfe7e0 0
after getcontext: 0xbfbfe7c0 0
after getcontext: 0xbfbfd7f0 0
before setcontext: 0xbfbfd7f0 6
:end
after getcontext: 0xbfbfe7a0 0
after getcontext: 0xbfbfe450 0
ひとつだけある setcontext が raise による大域脱出に対応しま
すが、その setcontext とその直後の getcontext の引数の
ucontext_t * と status の値が一致していません。
| % gdb miniruby
| GNU gdb 6.1.1 [FreeBSD]
| Copyright 2004 Free Software Foundation, Inc.
| GDB is free software, covered by the GNU General Public License, and you are
| welcome to change it and/or distribute copies of it under certain conditions.
| Type "show copying" to see the conditions.
| There is absolutely no warranty for GDB. Type "show warranty" for details.
| This GDB was configured as "i386-marcel-freebsd"...
まず gdb 上で、再現することを確認します。
| (gdb) run z.rb
| Starting program: /pub/akr/ruby/19/ruby/miniruby z.rb
| after getcontext: 0xbfbfe7a0 0
| after getcontext: 0xbfbfe7b0 0
| after getcontext: 0xbfbfe790 0
| after getcontext: 0xbfbfd7c0 0
| before setcontext: 0xbfbfd7c0 6
| :end
| after getcontext: 0xbfbfe770 0
| after getcontext: 0xbfbfe420 0
|
| Program exited normally.
よくわからないんですが、libc の symbol を読んでくれなくて
getcontext, setcontext に breakpoint を設定できなかったので
明示的に読ませます。
| (gdb) break main
| Breakpoint 1 at 0x8054eb2: file main.c, line 40.
| (gdb) run z.rb
| Starting program: /pub/akr/ruby/19/ruby/miniruby z.rb
|
| Breakpoint 1, main (argc=0, argv=0x0, envp=0xb