jayduhon / inferno-os

Automatically exported from code.google.com/p/inferno-os
2 stars 0 forks source link

crash on ARM when opening GUI #283

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

% Linux/arm/bin/emu -r .
; wm/wm
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x40030870 (LWP 23320)]
0x4031ed64 in __res_randomid () from /lib/libc.so.6
(gdb) bt
#0  0x4031ed64 in __res_randomid () from /lib/libc.so.6
#1  0x4031f690 in __res_vinit () from /lib/libc.so.6
#2  0x402f7ea8 in gaih_inet () from /lib/libc.so.6
#3  0x402fb0e4 in getaddrinfo () from /lib/libc.so.6
#4  0x40381c88 in ?? () from /usr/lib/libxcb.so.1
Cannot access memory at address 0xa
#5  0x40381c88 in ?? () from /usr/lib/libxcb.so.1
Cannot access memory at address 0xa
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

What is the expected output? What do you see instead?

The program crashed, but I expected the GUI to appear.

Which operating system are you using?

Linux ceres 3.1.9+ #155 PREEMPT Mon Jul 9 12:49:19 BST 2012 armv6l GNU/Linux
(Arch Linux ARM)
gcc (GCC) 4.7.0 20120505 (prerelease)
libxcb 1.8.1
inferno c19f2eb

Please provide any additional information below.

Original issue reported on code.google.com by chneukir...@gmail.com on 10 Jul 2012 at 7:16

GoogleCodeExporter commented 9 years ago
The bug seems to be triggered due to a too small stack size in kproc(). With 2k 
more it still crashes, but adding 3k seems to do the job (the GUI appears now 
and works):

diff -r c19f2eb83978 emu/port/kproc-pthreads.c
--- a/emu/port/kproc-pthreads.c Fri Jun 15 11:31:28 2012 -0400
+++ b/emu/port/kproc-pthreads.c Wed Jul 25 01:02:13 2012 +0100
@@ -159,7 +159,7 @@
    if(flags & KPX11)
        pthread_attr_setstacksize(&attr, 512*1024); /* could be a parameter */
    else if(KSTACK > 0)
-       pthread_attr_setstacksize(&attr, (KSTACK < PTHREAD_STACK_MIN? 
PTHREAD_STACK_MIN: KSTACK)+1024);
+       pthread_attr_setstacksize(&attr, (KSTACK < PTHREAD_STACK_MIN? 
PTHREAD_STACK_MIN: KSTACK)+4096);
    pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
    if(pthread_create(&thread, &attr, tramp, p))

This makes Inferno run on the Raspberry Pi.

Original comment by chneukir...@gmail.com on 25 Jul 2012 at 12:02

GoogleCodeExporter commented 9 years ago
It might be better to change KSTACK in Linux/arm/include/emu.h. The 1024 is 
just a little slop for extra data above PTHREAD_STACK_MIN.
x86 uses 32k, and perhaps ARM (for Linux) should too. KSTACK doesn't need to be 
a power of two if USE_PTHREADS is selected.
I'll change that.
Possibly it should depend on the specific board, since it might be nice to have 
more space for more kprocs if the platform allows a smaller stack size, but 
I'll think about that.

Original comment by Charles....@gmail.com on 25 Jul 2012 at 2:11

GoogleCodeExporter commented 9 years ago
CHANGES
Linux/arm/include/emu.h
include/version.h
committed changeset 543:aa92b6f626cf

Thanks for tracking it down.

Original comment by Charles....@gmail.com on 25 Jul 2012 at 2:14