[Ecls-list] cl_boot() segfaults when called not in the main thread

Juan Jose Garcia-Ripoll juanjose.garciaripoll at googlemail.com
Thu Jul 16 07:41:03 UTC 2009


On Thu, Jul 16, 2009 at 8:51 AM, Kamil Shakirov<kamils80 at gmail.com> wrote:
> Hi Juan,
>
> On Thu, 2009-07-16 at 04:01 +0700, Kamil Shakirov wrote:
>> On Wed, Jul 15, 2009 at 8:26 PM, Juan Jose
>> Garcia-Ripoll<juanjose.garciaripoll at googlemail.com> wrote:
>> > On Tue, Jul 14, 2009 at 6:16 PM, Kamil Shakirov<kamils80 at gmail.com> wrote:
>> >> Thanks a lot for your help. I did as you suggested but it still
>> >> segfaults getting SIGTTOU signal. import.c from 'examples/threads'
>> >> directory also segfaults with the following backtrace:
>> >
>> > The lisp environment has to be initialized before we may allocate a
>> > process object. Somehow I mixed up the statements. It should be
>> > working now in the git repository.
>> >
>>
>> Great, it is working now.
>>
>
> I have tested it on GNU/Linux x86_64 (Ubuntu 9.04) and it is working
> fine, but it still segfaults on Linux 32bit with the message "Collecting
> from unknown thread.". The main thread calls cl_boot() when application
> is started, ecl_import_current_thread() gets called in the second thread
> before other calls to ECL:

Hi Kamil, I think the problem might be due to the fact that the thread
is not registered with the garbage collector. This has nothing to do
with the architecture, but with how the garbage collector library is
used.

If you read your previous emails, you will see that the garbage
collector library intercepts your calls to the POSIX thread creation
routines. This is what should normally happen. I guess on your 32bits
box this is not occurring.

Could you try calling the functions below, found in <ecl/gc/gc.h> or
<gc/gc.h> or <gc.h>, on entrance and on exit of your thread? If it
works I will add them to what ECL is doing for registering threads.

Juanjo

/* Register the current thread, with the indicated stack base, as	*/
/* a new thread whose stack(s) should be traced by the GC.  If a 	*/
/* platform does not implicitly do so, this must be called before a	*/
/* thread can allocate garbage collected memory, or assign pointers	*/
/* to the garbage collected heap.  Once registered, a thread will be	*/
/* stopped during garbage collections.					*/
/* Return codes:	*/
#define GC_SUCCESS 0
#define GC_DUPLICATE 1	/* Was already registered.	*/
#define GC_NO_THREADS 2	/* No thread support in GC.  	*/
#define GC_UNIMPLEMENTED 3	/* Not yet implemented on this platform. */
GC_API int GC_register_my_thread(struct GC_stack_base *);

/* Unregister the current thread.  The thread may no longer allocate	*/
/* garbage collected memory or manipulate pointers to the		*/
/* garbage collected heap after making this call.			*/
/* Specifically, if it wants to return or otherwise communicate a 	*/
/* pointer to the garbage-collected heap to another thread, it must	*/
/* do this before calling GC_unregister_my_thread, most probably	*/
/* by saving it in a global data structure.				*/
GC_API int GC_unregister_my_thread(void);


>
> #0  0xb7f5c430 in __kernel_vsyscall ()
> #1  0xb7c7b6d0 in raise () from /lib/tls/i686/cmov/libc.so.6
> #2  0xb7c7d098 in abort () from /lib/tls/i686/cmov/libc.so.6
> #3  0xb7b8faa5 in GC_abort ()
> from /home/kamil/temp/IVRENG/lib/libecl.so.9.7
> #4  0xb7b950ba in GC_push_all_stacks ()
> from /home/kamil/temp/IVRENG/lib/libecl.so.9.7
> #5  0xb7b91587 in GC_default_push_other_roots ()
> from /home/kamil/temp/IVRENG/lib/libecl.so.9.7
> #6  0xb7b6c4ce in ?? () from /home/kamil/temp/IVRENG/lib/libecl.so.9.7
> #7  0xb7b8ee91 in GC_push_roots ()
> from /home/kamil/temp/IVRENG/lib/libecl.so.9.7
> #8  0xb7b8e77c in GC_mark_some ()
> from /home/kamil/temp/IVRENG/lib/libecl.so.9.7
> #9  0xb7b87f7d in GC_stopped_mark ()
> from /home/kamil/temp/IVRENG/lib/libecl.so.9.7
> #10 0xb7b881f9 in GC_try_to_collect_inner ()
> from /home/kamil/temp/IVRENG/lib/libecl.so.9.7
> #11 0xb7b8845c in GC_collect_or_expand ()
> from /home/kamil/temp/IVRENG/lib/libecl.so.9.7
> #12 0xb7b8b4f9 in GC_alloc_large ()
> from /home/kamil/temp/IVRENG/lib/libecl.so.9.7
> #13 0xb7b8c585 in GC_generic_malloc_ignore_off_page ()
> from /home/kamil/temp/IVRENG/lib/libecl.so.9.7
> #14 0xb7b8c6b5 in GC_malloc_atomic_ignore_off_page ()
> from /home/kamil/temp/IVRENG/lib/libecl.so.9.7
> #15 0xb7b6c52d in ecl_alloc_atomic_unprotected ()
> from /home/kamil/temp/IVRENG/lib/libecl.so.9.7
> #16 0xb7b6c7f6 in ecl_alloc_atomic ()
> from /home/kamil/temp/IVRENG/lib/libecl.so.9.7
> #17 0xb7b1f5ac in ecl_stack_set_size ()
> from /home/kamil/temp/IVRENG/lib/libecl.so.9.7
> #18 0xb7a662ca in ecl_init_env ()
> from /home/kamil/temp/IVRENG/lib/libecl.so.9.7
> #19 0xb7b6b95c in ecl_import_current_thread ()
> from /home/kamil/temp/IVRENG/lib/libecl.so.9.7
> #20 0xb7e3e1ee in g_task_on_pre_run (task=0x8405848)
> at /home/kamil/temp/IVRENG/src/module/eng_ecl/eng_resource.c:35
> #21 0xb7ead76e in g_task_run (thread_handle=0x8405908, data=0x8405848)
> at /home/kamil/temp/IVRENG/src/apk/apk_task.c:407
>
>
> --
> --wbr.
>
>



-- 
Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28006 (Spain)
http://juanjose.garciaripoll.googlepages.com




More information about the ecl-devel mailing list