[Gauche-devel] segfault with threads
R7RS Scheme scripting engine
Status: Beta
Brought to you by:
shirok
From: <mm...@ma...> - 2006-06-09 01:36:45
|
Hello Shiro and all, I have a kahua application, which segfaults iff I use threads. The program uses custom C bindings, so I don't claim it's not a bug in my code. But the fault occurs always at the same point (in gauche code), so maybe some hint would help me. The fault is this: [Switching to Thread -1212094784 (LWP 1321)] 0xb7df43b0 in run_loop () at vm.c:1126 1126 CASE(SCM_VM_LREF20) { VAL0 = ENV_DATA(ENV->up->up, 0);NEXT1; } (gdb) bt #0 0xb7df43b0 in run_loop () at vm.c:1126 #1 0xb7dfc698 in user_eval_inner (program=0x8c24580, codevec=0x80ead48) at vm.c:2919 #2 0x0804a3d1 in main (argc=11, argv=0xbf960a64) at main.c:425 The program uses 2 helper threads only at one point. To trace down the problem I tried to run those threads serially. Here is how I make the threads run serially: (let1 t1 (load-people-list pg "f") (if (thread? t1) (thread-join! t1))) (let1 t2 (load-people-list pg "m") (if (thread? t2) (thread-join! t2))) And this is the worker, where I can switch off use of threads: (define (load-people-list pg gender) (let1 pgh (pg:new-handle pg :private #t) (logformat-color 'yellow "pg:new-handle: backend ~d\n" (pg-backend-pid (ref pgh 'conn))) (if (and (eq? 'pthread (gauche-thread-type)) #f) ;; <--- Now I don't want threads (let1 t (make-thread (lambda () (logformat-color 'yellow "Thread started!\n") (do-load pgh gender) (pg:dispose-handle pg pgh) (logformat-color 'yellow "Thread exiting!\n")) "loader thread") (thread-start! t) t) (begin (do-load pgh gender) (pg:dispose-handle pg pgh) #t )))) So, If I enable threads, programs segfaults always at the same point, If I disable them, all is ok. thanks. -- http://maruska.dyndns.org/wiki/ |