Bug #1205
closed
SET_STACK_END crashes due to uninitialized ruby_current_thread
Added by hsugawar (hiro sugawara) over 15 years ago.
Updated over 13 years ago.
Description
=begin
I ported ruby-1.9.1-p0 to Android. It built fine with a few patches and a custom Android.mk with a target of "miniruby."
The executable crashed at an early stage. I succeeded in tracing the crash to a null pointer reference to ruby_current_thread in SET_STACK_END (through GET_THREAD()) called in ruby_get_stack_grow_direction() called in STACK_UPPER() called in ruby_init_stack() called in Init_stack().
Reversing the calling order of Init_BareVM() and Init_stack in eval.c:ruby_init() seems to fix the problem.
Am I right?
Thanks,
hiro
ruby-1.9.1-p0/eval.c ====
*** 56,63 ****
rb_origenviron = environ;
Init_stack((void *)&state);
! Init_BareVM();
Init_heap();
PUSH_TAG();
--- 56,64 ----
rb_origenviron = environ;
! //Init_BareVM();
Init_heap();
PUSH_TAG();
=end
=begin
Hi,
At Wed, 25 Feb 2009 09:37:32 +0900,
hiro sugawara wrote in [ruby-core:22439]:
The executable crashed at an early stage. I succeeded in
tracing the crash to a null pointer reference to
ruby_current_thread in SET_STACK_END (through GET_THREAD())
called in ruby_get_stack_grow_direction() called in
STACK_UPPER() called in ruby_init_stack() called in
Init_stack().
Isn't the stack direction on Android defined statically?
Reversing the calling order of Init_BareVM() and Init_stack
in eval.c:ruby_init() seems to fix the problem.
Does this patch fix it?
Index: gc.c
--- gc.c (revision 22639)
+++ gc.c (working copy)
@@ -1103,8 +1103,8 @@ int
ruby_get_stack_grow_direction(VALUE *addr)
{
- rb_thread_t *th = GET_THREAD();
- SET_STACK_END;
- VALUE *end;
- SET_MACHINE_STACK_END(&end);
- if (STACK_END > addr) return ruby_stack_grow_direction = 1;
- if (end > addr) return ruby_stack_grow_direction = 1;
return ruby_stack_grow_direction = -1;
}
--
Nobu Nakada
=end
- Assignee set to nobu (Nobuyoshi Nakada)
- Status changed from Open to Closed
- % Done changed from 0 to 100
=begin
Applied in changeset r22659.
=end
=begin
今日は。Ubuntuで日本語を使えるようにしたので、日本語で行きます。
示していただいたパッチでクラッシュは解消しました。似たようなコード(ruby_stack_length(), stack_check())が直後にありますが、こちらは大丈夫でしょうか?この辺はコードがマクロでピョンピョン飛び回っているので分かりづらいところです。
Isn't the stack direction on Android defined statically?
この質問の意味がよくわかりません。
hiro
=end
=begin
なかだです。
At Sat, 28 Feb 2009 05:42:59 +0900,
hiro sugawara wrote in [ruby-core:22577]:
今日は。Ubuntuで日本語を使えるようにしたので、日本語で行きます。
ruby-devに移動します。
示していただいたパッチでクラッシュは解消しました。似たようなコー
ド(ruby_stack_length(), stack_check())が直後にありますが、こ
ちらは大丈夫でしょうか?この辺はコードがマクロでピョンピョン飛
び回っているので分かりづらいところです。
その二つは現在実行中のスレッドのスタックに関するチェックなので、
GET_THREAD()は必須ですし、Init_BareVM()以前に呼ばれることもあり
ません。
Isn't the stack direction on Android defined statically?
この質問の意味がよくわかりません。
Androidで使用しているCPUのスタック方向は決まっていないのでしょう
か。もし分かっているのなら、configureで決定できるのですが。
--
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
中田 伸悦
=end
Also available in: Atom
PDF
Like0
Like0Like0Like0Like0Like0