Subject: is PT_STACKSIZE too small?
To: None <tech-userlevel@netbsd.org>
From: T.SHIOZAKI <tshiozak@bsdclub.org>
List: tech-userlevel
Date: 06/24/2003 19:47:29
Hi,

Emacs-21.3 frequently (but random) crashes on the recent
NetBSD/i386 current + X (configured with ThreadedX=yes).
Emacs seems to crash when it catch a key event of X while
garbage collection.  Additionally, Mozilla has crashed similarly.

The crash information of Emacs is here:

==============================
% gdb /usr/pkg/bin/emacs emacs.core
GNU gdb 5.0nb1
Copyright 2000 Free Software Foundation, Inc.

..snip..

Core was generated by `emacs'.
Program terminated with signal 4, Illegal instruction.

..snip..

(gdb) info registers
eax            0x0      0
ecx            0x5      5
edx            0x582dc5a4       1479394724
ebx            0x0      0
esp            0xbfbc1f80       0xbfbc1f80
ebp            0xbfbeef9c       0xbfbeef9c
esi            0x833d7ac        137615276
edi            0x5      5
eip            0x80d62f9        0x80d62f9
eflags         0x10282  66178

..snip..

==============================

Look at esp register.  This value is on the redzone of the stack.
(c.f. src/lib/libpthread/pthread_stack.c)
the stack is surely overflowing, although I can not understand
why this causes SIGILL.
Emacs is stabilized when PT_STACKSIZE is increased to 1<<20.

I guess we should improve the implementation around per-thread stack,
but it requires time.
Thus, we need to set PT_STACKSIZE appropriately for the present.
Anyway, I guess the current value of PT_STACKSIZE, 1<<18, is too small
for me to live on the -current :-)

How much is suitable value of PT_STACKSIZE?

# Of course, this value changes with architecture and usage.
# How about making PT_STACKSIZE configurable in mk.conf or something?

--
Takuya SHIOZAKI