なかだです。

At Wed, 14 Sep 2005 14:46:34 +0900,
H.Yamamoto wrote in [ruby-dev:27070]:
> すみません、まだ落ちます。私が気になってたのは、

再現する条件を教えてもらえますか。

>   1. ALLOC_N や malloc なんかも GC を発生させる可能性があるので、
>      もう、どんな関数も ruby_init 前に呼び出すのは危険な気がする。

malloc()は発生させません。init_env()でも何も考えずにALLOC_Nを使っ
てしまってました。

> ではいけないのでしょうか?ruby_init は複数回呼んだら無視するように
> なっているので、とりあえず動いているようなのですが。

組み込みの話も絡んでくるので、意図する前に呼ばれているというの
は望ましくないような気がします。


Index: win32/win32.c =================================================================== RCS file: /cvs/ruby/src/ruby/win32/win32.c,v retrieving revision 1.166 diff -U2 -p -u -r1.166 win32.c --- win32/win32.c 12 Sep 2005 11:40:40 -0000 1.166 +++ win32/win32.c 14 Sep 2005 06:07:51 -0000 @@ -407,5 +407,5 @@ init_env(void) return; } - NTLoginName = ALLOC_N(char, len+1); + NTLoginName = malloc(len+1); strncpy(NTLoginName, env, len); NTLoginName[len] = '\0'; @@ -1031,10 +1031,9 @@ insert(const char *path, VALUE vinfo) NtCmdLineElement ***tail = (NtCmdLineElement ***)vinfo; - tmpcurr = ALLOC(NtCmdLineElement); + tmpcurr = (NtCmdLineElement *)malloc(sizeof(NtCmdLineElement)); MEMZERO(tmpcurr, NtCmdLineElement, 1); tmpcurr->len = strlen(path); - tmpcurr->str = ALLOC_N(char, tmpcurr->len + 1); + tmpcurr->str = strdup(path); tmpcurr->flags |= NTMALLOC; - strcpy(tmpcurr->str, path); **tail = tmpcurr; *tail = &tmpcurr->next; @@ -1291,5 +1290,5 @@ rb_w32_cmdvector(const char *cmd, char * } - curr = ALLOC(NtCmdLineElement); + curr = malloc(sizeof(NtCmdLineElement)); MEMZERO(curr, NtCmdLineElement, 1); curr->str = base; @@ -1315,5 +1314,5 @@ rb_w32_cmdvector(const char *cmd, char * len = (elements+1)*sizeof(char *) + strsz; - buffer = ALLOC_N(char, len); + buffer = malloc(len); //
-- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦