On Thursday 27 September 2012 23:15:56 Juan Jose Garcia-Ripoll wrote:
> 
> Thanks a lot for the careful debugging. It seems ECL ran into a vicious
> circle: to register itself it has to create an environment, but to allocate
> any object an existing environment was assumed. I have fixed this and
> another problem with GC_unregister_my_thread(), which can only be called
> once. Your example seems to work here now.
> 
> Juanjo

Hi and thanks for the fix. Previous example works fine but my problems 
continue. Now I try use ECL with third-party thread abstraction (where gc 
macro cant replace thread calls). The following example illustrates the bug:

thread.c:
#include<pthread.h>

pthread_t my_create_thread(void*(*foo)(void*)){
 pthread_t pt;
 pthread_create(&pt,0,foo,0);
 return pt;}

void my_thread_join(pthread_t p){
 pthread_join(p,0);}

-------------------
main.c:
#include<pthread.h>
#include<stdio.h>
#include<ecl/ecl.h>

pthread_t my_create_thread(void*(*)(void*));
void my_thread_join(pthread_t);

void *foo(void *x){
 ecl_import_current_thread(Cnil,Cnil); (1)
 int i;
 for(i=0;i<5;i++){
  printf("%d\n",i);
  sleep(1);}
 ecl_release_current_thread(); (2)
 return 0;}

int main(int argc,char **argv){
 cl_boot(argc,argv);
 pthread_t threads[10];
 int i;
 for(i=0;i<sizeof(threads)/sizeof(*threads);i++)
  threads[i]=my_create_thread(foo);
 for(i=0;i<sizeof(threads)/sizeof(*threads);i++)
  my_thread_join(threads[i]);
 cl_shutdown();
 printf("Exit\n");
 return 0;}


If the lines (1) and (2) are commented out, program works fine. Otherwise 
program fails with sigsegv after ecl_import_current_thread. I don't know is 
there ECL or Boehm problem.

While I debug program with gdb I saw many SIGPWR signals. There is the 
backtrace after sigsegv occurs:

#0  0xb7b41c2f in GC_push_all_eager () from /usr/lib/libgc.so.1
#1  0xb7b41c83 in GC_push_all_stack () from /usr/lib/libgc.so.1
#2  0xb7b4a4bb in GC_push_all_stacks () from /usr/lib/libgc.so.1
#3  0xb7b44e74 in GC_default_push_other_roots () from /usr/lib/libgc.so.1
#4  0xb7f2da8c in stacks_scanner () at /home/staseg/devel/ecl-
src/src/c/alloc_2.d:1344
#5  0xb7b4334d in GC_push_roots () from /usr/lib/libgc.so.1
#6  0xb7b427fe in GC_mark_some () from /usr/lib/libgc.so.1
#7  0xb7b393f0 in GC_stopped_mark () from /usr/lib/libgc.so.1
#8  0xb7b39acc in GC_try_to_collect_inner () from /usr/lib/libgc.so.1
#9  0xb7b3a66c in GC_collect_or_expand () from /usr/lib/libgc.so.1
#10 0xb7b3f0e8 in GC_alloc_large () from /usr/lib/libgc.so.1
#11 0xb7b3fc66 in GC_generic_malloc_ignore_off_page () from 
/usr/lib/libgc.so.1
#12 0xb7b3fda3 in GC_malloc_atomic_ignore_off_page () from /usr/lib/libgc.so.1
#13 0xb7f2e00b in ecl_alloc_atomic_unprotected (n=2245632)
    at /home/staseg/devel/ecl-src/src/c/alloc_2.d:716
#14 0xb7f2e19f in ecl_alloc_atomic (n=2245632)
    at /home/staseg/devel/ecl-src/src/c/alloc_2.d:736
#15 0xb7ed1d0d in ecl_stack_set_size (env=0xb7dc6000, 
tentative_new_size=32768)
    at /home/staseg/devel/ecl-src/src/c/interpreter.d:42
#16 0xb7e01bb7 in ecl_init_env (env=0xb7dc6000)
    at /home/staseg/devel/ecl-src/src/c/main.d:145
#17 0xb7f2a49b in ecl_import_current_thread (name=0x1, bindings=0x1)
    at /home/staseg/devel/ecl-src/src/c/threads/process.d:393
#18 0x08048826 in foo ()
#19 0xb7d96d7a in start_thread () from /lib/libpthread.so.0
#20 0xb7cb617e in clone () from /lib/libc.so.6


------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Ecls-list mailing list
Ecls-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ecls-list

Reply via email to