guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

build failure of guile 2.2.2 with musl libc


From: Natanael Copa
Subject: build failure of guile 2.2.2 with musl libc
Date: Wed, 27 Sep 2017 11:05:00 +0200

Hi,

Build of guile 2.2.2 fails on Alpine Linux which uses musl libc. The
build fails during bootstrap and happens due to a recursive call that
ends up with running out of stack space. This is triggered with musl
libc because the default stack size on musl libc is only 80k.

There are two ways to fix it:
- explicitly set pthread stacksize
- convert the recursive function to be iterative

As a workaround I have increased the pthread stack size for Alpine
Linux, but ideally I would prefer to make the recursive function
`give_to_poor` iterative.

Backtrace:

#0  0xe83d4795 in GC_call_with_alloc_lock () from /usr/lib/libgc.so.1
#1  0xe84d7503 in copy_weak_entry (dst=0xe7b09060, src=0xe640d5dc)
    at weak-table.c:123
#2  give_to_poor (address@hidden, address@hidden)
    at weak-table.c:286
#3  0xe84d7561 in give_to_poor (address@hidden, address@hidden)
    at weak-table.c:291
#4  0xe84d7561 in give_to_poor (address@hidden, address@hidden)
    at weak-table.c:291

...

#859 0xe84d7561 in give_to_poor (address@hidden, address@hidden)
    at weak-table.c:291
#860 0xe84d7561 in give_to_poor (address@hidden, address@hidden)
    at weak-table.c:291
#861 0xe84d7561 in give_to_poor (address@hidden, k=6270, 
    address@hidden) at weak-table.c:291
#862 0xe84d7561 in give_to_poor (address@hidden, address@hidden)
    at weak-table.c:291
#863 0xe84d7561 in give_to_poor (address@hidden, address@hidden)
    at weak-table.c:291
#864 0xe84d7561 in give_to_poor (address@hidden, address@hidden)
    at weak-table.c:291
#865 0xe84d7561 in give_to_poor (address@hidden, address@hidden)
    at weak-table.c:291
#866 0xe84d7561 in give_to_poor (address@hidden, address@hidden)
    at weak-table.c:291
#867 0xe84d7561 in give_to_poor (address@hidden, address@hidden)
    at weak-table.c:291
#868 0xe84d7561 in give_to_poor (address@hidden, address@hidden)
    at weak-table.c:291
#869 0xe84d7561 in give_to_poor (address@hidden, address@hidden)
    at weak-table.c:291
#870 0xe84d7561 in give_to_poor (address@hidden, address@hidden)
    at weak-table.c:291
#871 0xe84d7561 in give_to_poor (address@hidden, address@hidden)
    at weak-table.c:291
#872 0xe84d7561 in give_to_poor (address@hidden, address@hidden)
    at weak-table.c:291
#873 0xe84d7561 in give_to_poor (address@hidden, address@hidden)
    at weak-table.c:291
#874 0xe84d7d9b in vacuum_weak_table (table=0xe81b0e00) at weak-table.c:562
#875 do_vacuum_weak_table (table=<optimized out>) at weak-table.c:829
#876 scm_i_visit_weak_list (list_loc=0xe856ad04 <all_weak_tables>, 
    visit=<optimized out>) at ../libguile/weak-list.h:57
#877 vacuum_all_weak_tables () at weak-table.c:843
#878 0xe8454777 in async_gc_finalizer (ptr=0xe81b2fa8, data=0x0)
    at finalizers.c:305
#879 0xe83cedc1 in GC_invoke_finalizers () from /usr/lib/libgc.so.1
#880 0xe8454d94 in scm_run_finalizers () at finalizers.c:387
#881 0xe8454e0d in finalization_thread_proc (unused=0x0) at finalizers.c:223
#882 0xe844489d in c_body (d=0xe7b1dc10) at continuations.c:422
#883 0xe84d21f7 in vm_regular_engine (thread=0xe81afd10, vp=0xe8017f30, 
    registers=0xe7b1d970, resume=0) at vm-engine.c:784
#884 0xe84d5328 in scm_call_n (proc=0xe80312e0, argv=0x0, nargs=0) at vm.c:1257
#885 0xe844a9fc in scm_call_0 (proc=0xe80312e0) at eval.c:481
#886 0xe84c144c in catch (tag=0x404, thunk=0xe80312e0, handler=0xe80312c0, 
    pre_unwind_handler=0xe80312b0) at throw.c:137
#887 0xe84c17e5 in scm_catch_with_pre_unwind_handler (key=0x404, 
    thunk=0xe80312e0, handler=0xe80312c0, pre_unwind_handler=0xe80312b0)
    at throw.c:254
#888 0xe84c19be in scm_c_catch (tag=0x404, body=0xe8444890 <c_body>, 
    body_data=0xe7b1dc10, handler=0xe8444b80 <c_handler>, 
    handler_data=0xe7b1dc10, 
    pre_unwind_handler=0xe84449a0 <pre_unwind_handler>, 
    pre_unwind_handler_data=0xe8014980) at throw.c:377
#889 0xe8444f08 in scm_i_with_continuation_barrier (body=0xe8444890 <c_body>, 
    body_data=0xe7b1dc10, handler=0xe8444b80 <c_handler>, 
    handler_data=0xe7b1dc10, 
    pre_unwind_handler=0xe84449a0 <pre_unwind_handler>, 
    pre_unwind_handler_data=0xe8014980) at continuations.c:360
#890 0xe8444ff3 in scm_c_with_continuation_barrier (
    func=0xe8454da0 <finalization_thread_proc>, data=0x0)
    at continuations.c:456
#891 0xe84bfc0e in with_guile (base=0xe7b1dc88, data=0xe7b1dcb0)
    at threads.c:660
#892 0xe83d4806 in GC_call_with_stack_base () from /usr/lib/libgc.so.1
#893 0xe84c0066 in scm_i_with_guile (dynamic_state=<optimized out>, data=0x0, 
    func=0xe8454da0 <finalization_thread_proc>) at threads.c:703
#894 scm_with_guile (func=0xe8454da0 <finalization_thread_proc>, data=0x0)
    at threads.c:709
#895 0xe84548cf in run_finalization_thread (arg=0x0) at finalizers.c:236
#896 0xe85c0152 in start (p=0xe7b1dd50) at src/thread/pthread_create.c:145
#897 0xe85beea1 in __clone () at src/thread/i386/clone.s:36
#898 0x00000000 in ?? ()


The workaround we currently use (256kb stack was apparently not enough
for ppc64le):

diff --git a/libguile/finalizers.c b/libguile/finalizers.c
index c5d69e8..f8d78d8 100644
--- a/libguile/finalizers.c
+++ b/libguile/finalizers.c
@@ -246,11 +246,19 @@ start_finalization_thread (void)
         to block on any lock that scm_spawn_thread might want to take,
         and we don't want to inherit the dynamic state (fluids) of the
         caller.  */
-      if (pthread_create (&finalization_thread, NULL,
-                         run_finalization_thread, NULL))
-       perror ("error creating finalization thread");
+      pthread_attr_t attr;
+      if (pthread_attr_init(&attr))
+        perror ("pthread_attr_init");
       else
-       finalization_thread_is_running = 1;
+        {
+          if (pthread_attr_setstacksize(&attr, 512 * 1024) == 0 &&
+              pthread_create (&finalization_thread, &attr,
+                             run_finalization_thread, NULL) == 0)
+           finalization_thread_is_running = 1;
+          else
+           perror ("error creating finalization thread");
+          pthread_attr_destroy(&attr);
+       }
     }
   scm_i_pthread_mutex_unlock (&finalization_thread_lock);
 }



-nc




reply via email to

[Prev in Thread] Current Thread [Next in Thread]