lpereira / lwan

Experimental, scalable, high performance HTTP server
https://lwan.ws
GNU General Public License v2.0
5.94k stars 548 forks source link

SIGSEGV: coro_reset:getcontext() on uClibc armv7l #284

Closed dset0x closed 3 years ago

dset0x commented 4 years ago

Hello,

I build lwan-latest using ImportExecutables.cmake from a native build, using a buildroot uClibc (arm-buildroot-linux-uclibcgnueabihf).

cd ../amd64/src/
make clean; rm -rf CMakeCache.txt CMakeFiles ImportExecutables.cmake Makefile cmake_install.cmake empty.c lwan-build-config.h lwan.pc && cmake -DCMAKE_BUILD_TYPE=Debug .. && make

cd ../arm/src/
make clean; rm -rf CMakeCache.txt CMakeFiles ImportExecutables.cmake Makefile cmake_install.cmake empty.c lwan-build-config.h lwan.pc && cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=/my/buildroot/arm-buildroot-linux-uclibcgnueabihf_sdk-buildroot/share/buildroot/toolchainfile.cmake -DIMPORT_EXECUTABLES=$PWD/../amd64/src/ImportExecutables.cmake -DCMAKE_VERBOSE_MAKEFILE=1 -DCMAKE_C_FLAGS='-g -O0' .. && make && scp src/bin/lwan/lwan target:/sbin/lwan

I then run lwan (under gdb) and make a request to it to trigger the problem.

# gdb lwan
Reading symbols from /sbin/lwan...done.
(gdb) b lib/lwan-coro.c:294
Breakpoint 1 at 0x189e8: file src/lib/lwan-coro.c, line 294.
(gdb) run
Starting program: /sbin/lwan 
9300 lwan-job.c:104 lwan_job_thread_init() Initializing low priority job thread
9300 lwan-tables.c:47 lwan_tables_init() Uncompressing MIME type table: 8082->31348 bytes, 953 entries
9300 lwan.c:495 setup_from_config() Loading configuration file: lwan.conf
9300 lwan.c:365 parse_listener_prefix() Initializing module serve_files from config
9300 lwan-response.c:77 lwan_response_init() Initializing default response
9300 lwan.c:696 lwan_init_with_config() Initializing lwan web server
9300 lwan.c:723 lwan_init_with_config() Using 1 threads, maximum 4096 sockets per thread
9300 lwan-readahead.c:177 lwan_readahead_init() Initializing low priority readahead thread
9300 lwan-thread.c:701 lwan_thread_init() Initializing threads
9300 lwan-thread.c:710 lwan_thread_init() Pending client file descriptor queue has 256 items
9305 lwan-thread.c:453 thread_io_loop() Worker thread #1 starting
9300 lwan-thread.c:743 lwan_thread_init() Worker threads created and ready to serve
9300 lwan-socket.c:247 lwan_socket_init() Initializing sockets
9300 lwan-socket.c:236 setup_socket_normally() a
9300 lwan-socket.c:168 listen_addrinfo() Listening on http://0.0.0.0:8080
9300 lwan-socket.c:239 setup_socket_normally() b
9300 lwan.c:831 lwan_main_loop() Ready to serve
[New LWP 9305]
[Switching to LWP 9305]

Breakpoint 1, coro_reset (coro=0x4f200, func=0x254f9 <process_request_coro>, data=0x50c58) at src/lwan2/src/lib/lwan-coro.c:294
294     lwan_status_info("getcontext <");
(gdb) l
289     coro->context[5 /* EIP */] = (uintptr_t)coro_entry_point;
290 
291 #define STACK_PTR 6
292     coro->context[STACK_PTR] = (uintptr_t)stack;
293 #else
294     lwan_status_info("getcontext <");
295     getcontext(&coro->context);
296     lwan_status_info("getcontext >");
297 
298     coro->context.uc_stack.ss_sp = stack;
(gdb) p stack
$1 = (unsigned char *) 0x76f0f000 ""
(gdb) p coro->context 
$2 = {uc_flags = 0, uc_link = 0x0, uc_stack = {ss_sp = 0x0, ss_flags = 0, ss_size = 0}, uc_mcontext = {trap_no = 0, error_code = 0, oldmask = 0, arm_r0 = 0, 
    arm_r1 = 0, arm_r2 = 0, arm_r3 = 0, arm_r4 = 0, arm_r5 = 0, arm_r6 = 0, arm_r7 = 0, arm_r8 = 0, arm_r9 = 0, arm_r10 = 0, arm_fp = 0, arm_ip = 0, arm_sp = 0, 
    arm_lr = 0, arm_pc = 0, arm_cpsr = 0, fault_address = 0}, uc_sigmask = {__val = {0, 0}}, uc_regspace = {0, 0, 0, 0, 0, 0, 325168, 1, 4, 
    0 <repeats 39 times>, 325272, 1, 4, 0 <repeats 77 times>}}
(gdb) c
Continuing.
9305 lwan-coro.c:294 coro_reset() getcontext <
Program received signal SIGSEGV, Segmentation fault.
0x76e79810 in getcontext () from /lib//libc.so.0
(gdb) quit

I am not quite sure how to debug this any further. Please let me know if I can help with more output.

dset0x commented 4 years ago

Note that I was forced to comment this out for the build to complete (might as well be the source of my problems)

diff --git a/src/lib/lwan-websocket.c b/src/lib/lwan-websocket.c
index a484b1f..3a6a4c1 100644
--- a/src/lib/lwan-websocket.c
+++ b/src/lib/lwan-websocket.c
@@ -121,7 +121,7 @@ static size_t get_frame_length(struct lwan_request *request, uint16_t header)
 {
     size_t len;

-    static_assert(sizeof(size_t) == sizeof(uint64_t), "size_t has a sane size");
+    /* static_assert(sizeof(size_t) == sizeof(uint64_t), "size_t has a sane size"); */

     switch (header & 0x7f) {
     case 0x7e:

I have also commented out lua, brotli and zstd from CMakeLists.txt, because the build host has these, but the target platform does not.

lpereira commented 4 years ago

I rarely test Lwan on ARM, let alone with uClibc. Coroutines in C are but a hack, so stuff like this is bound to happen on untested platform combinations.

The getcontext() function is implemented in assembly, so you'd have to step through it at an instruction level to see what's actually causing the segmentation fault. Set up a breakpoint there before main() starts and go from there. Maybe the answer is just to provide a 1st-class implementation of coroutines for ARM, but I'm not familiar enough with the platform, or have the need right now, to implement it properly; there are some coroutine libraries out there (I've starred some of them here on GitHub) with ARM support, which might help figure out what's needed.

BTW, it's unlikely that the thing you've commented out is the source of the problem, unless you're trying to receive WebSockets frames that are larger than 64KB.

dset0x commented 4 years ago

Thanks for taking a look, @lpereira. I understand if support for this is not a priority. I am not sure if I will be able to eventually make sense of this. My gdb fails to create a record due to lack of support for some instruction, but for reference, I'm including some output from stepping through it.

gdb output

``` gdb lwan GNU gdb (GDB) 7.6 Copyright (C) 2013 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "arm-linux-gnueabi". For bug reporting instructions, please see: ... Reading symbols from /sbin/lwan...done. (gdb) (gdb) b lib/lwan-coro.c:295 Breakpoint 1 at 0x189fc: file /home/user/src/lwan2/src/lib/lwan-coro.c, line 295. (gdb) run Starting program: /sbin/lwan 24295 lwan-job.c:104 lwan_job_thread_init() Initializing low priority job thread 24295 lwan-tables.c:47 lwan_tables_init() Uncompressing MIME type table: 8082->31348 bytes, 953 entries 24295 lwan.c:495 setup_from_config() Loading configuration file: lwan.conf 24295 lwan.c:365 parse_listener_prefix() Initializing module serve_files from config 24295 lwan-response.c:77 lwan_response_init() Initializing default response 24295 lwan.c:696 lwan_init_with_config() Initializing lwan web server 24295 lwan.c:723 lwan_init_with_config() Using 1 threads, maximum 4096 sockets per thread 24295 lwan-readahead.c:177 lwan_readahead_init() Initializing low priority readahead thread 24295 lwan-thread.c:701 lwan_thread_init() Initializing threads 24295 lwan-thread.c:710 lwan_thread_init() Pending client file descriptor queue has 256 items 24300 lwan-thread.c:453 thread_io_loop() Worker thread #1 starting 24295 lwan-thread.c:743 lwan_thread_init() Worker threads created and ready to serve 24295 lwan-socket.c:247 lwan_socket_init() Initializing sockets 24295 lwan-socket.c:236 setup_socket_normally() a 24295 lwan-socket.c:168 listen_addrinfo() Listening on http://0.0.0.0:8080 24295 lwan-socket.c:239 setup_socket_normally() b 24295 lwan.c:831 lwan_main_loop() Ready to serve 24300 lwan-coro.c:294 coro_reset() getcontext < [New LWP 24300] [Switching to LWP 24300] Breakpoint 1, coro_reset (coro=0x4f200, func=0x254f9 , data=0x50c58) at /home/user/src/lwan2/src/lib/lwan-coro.c:295 295 getcontext(&coro->context); (gdb) (gdb) display/i $pc 1: x/i $pc => 0x189fc : ldr r3, [r7, #12] (gdb) (gdb) info registers r0 0x76b4d970 1991563632 r1 0x1 1 r2 0x76b4d970 1991563632 r3 0x0 0 r4 0xf 15 r5 0x7e91882c 2123466796 r6 0x76b4cef8 1991560952 r7 0x76b4cb20 1991559968 r8 0x76b4d040 1991561280 r9 0x76ffb000 1996468224 r10 0x200000 2097152 r11 0x7e91882c 2123466796 r12 0x45f60 286560 sp 0x76b4cb18 0x76b4cb18 lr 0x189fd 100861 pc 0x189fc 0x189fc cpsr 0x30 48 (gdb) si 0x000189fe 295 getcontext(&coro->context); 1: x/i $pc => 0x189fe : adds r3, #8 (gdb) 0x00018a00 295 getcontext(&coro->context); 1: x/i $pc => 0x18a00 : mov r0, r3 (gdb) info registers r0 0x76b4d970 1991563632 r1 0x1 1 r2 0x76b4d970 1991563632 r3 0x4f208 324104 r4 0xf 15 r5 0x7e91882c 2123466796 r6 0x76b4cef8 1991560952 r7 0x76b4cb20 1991559968 r8 0x76b4d040 1991561280 r9 0x76ffb000 1996468224 r10 0x200000 2097152 r11 0x7e91882c 2123466796 r12 0x45f60 286560 sp 0x76b4cb18 0x76b4cb18 lr 0x189fd 100861 pc 0x18a00 0x18a00 cpsr 0x30 48 (gdb) si 0x00018a02 295 getcontext(&coro->context); 1: x/i $pc => 0x18a02 : blx 0x12824 (gdb) 0x00012824 in ?? () 1: x/i $pc => 0x12824: add r12, pc, #0, 12 (gdb) info registers r0 0x4f208 324104 r1 0x1 1 r2 0x76b4d970 1991563632 r3 0x4f208 324104 r4 0xf 15 r5 0x7e91882c 2123466796 r6 0x76b4cef8 1991560952 r7 0x76b4cb20 1991559968 r8 0x76b4d040 1991561280 r9 0x76ffb000 1996468224 r10 0x200000 2097152 r11 0x7e91882c 2123466796 r12 0x45f60 286560 sp 0x76b4cb18 0x76b4cb18 lr 0x18a07 100871 pc 0x12824 0x12824 cpsr 0x10 16 (gdb) si 0x00012828 in ?? () 1: x/i $pc => 0x12828: add r12, r12, #208896 ; 0x33000 (gdb) 0x0001282c in ?? () 1: x/i $pc => 0x1282c: ldr pc, [r12, #1768]! ; 0x6e8 (gdb) info registers r0 0x4f208 324104 r1 0x1 1 r2 0x76b4d970 1991563632 r3 0x4f208 324104 r4 0xf 15 r5 0x7e91882c 2123466796 r6 0x76b4cef8 1991560952 r7 0x76b4cb20 1991559968 r8 0x76b4d040 1991561280 r9 0x76ffb000 1996468224 r10 0x200000 2097152 r11 0x7e91882c 2123466796 r12 0x4582c 284716 sp 0x76b4cb18 0x76b4cb18 lr 0x18a07 100871 pc 0x1282c 0x1282c cpsr 0x10 16 (gdb) si 0x76f5d7e0 in getcontext () from /lib//libc.so.0 1: x/i $pc => 0x76f5d7e0 : add r1, r0, #48 ; 0x30 (gdb) 0x76f5d7e4 in getcontext () from /lib//libc.so.0 1: x/i $pc => 0x76f5d7e4 : stm r1, {r4, r5, r6, r7, r8, r9, r10, r11} (gdb) info registers r0 0x4f208 324104 r1 0x4f238 324152 r2 0x76b4d970 1991563632 r3 0x4f208 324104 r4 0xf 15 r5 0x7e91882c 2123466796 r6 0x76b4cef8 1991560952 r7 0x76b4cb20 1991559968 r8 0x76b4d040 1991561280 r9 0x76ffb000 1996468224 r10 0x200000 2097152 r11 0x7e91882c 2123466796 r12 0x45f14 286484 sp 0x76b4cb18 0x76b4cb18 lr 0x18a07 100871 pc 0x76f5d7e4 0x76f5d7e4 cpsr 0x10 16 (gdb) si 0x76f5d7e8 in getcontext () from /lib//libc.so.0 1: x/i $pc => 0x76f5d7e8 : str sp, [r0, #84] ; 0x54 (gdb) 0x76f5d7ec in getcontext () from /lib//libc.so.0 1: x/i $pc => 0x76f5d7ec : str lr, [r0, #88] ; 0x58 (gdb) info registers r0 0x4f208 324104 r1 0x4f238 324152 r2 0x76b4d970 1991563632 r3 0x4f208 324104 r4 0xf 15 r5 0x7e91882c 2123466796 r6 0x76b4cef8 1991560952 r7 0x76b4cb20 1991559968 r8 0x76b4d040 1991561280 r9 0x76ffb000 1996468224 r10 0x200000 2097152 r11 0x7e91882c 2123466796 r12 0x45f14 286484 sp 0x76b4cb18 0x76b4cb18 lr 0x18a07 100871 pc 0x76f5d7ec 0x76f5d7ec cpsr 0x10 16 (gdb) si 0x76f5d7f0 in getcontext () from /lib//libc.so.0 1: x/i $pc => 0x76f5d7f0 : str lr, [r0, #92] ; 0x5c (gdb) 0x76f5d7f4 in getcontext () from /lib//libc.so.0 1: x/i $pc => 0x76f5d7f4 : mov r2, #0 (gdb) info registers r0 0x4f208 324104 r1 0x4f238 324152 r2 0x76b4d970 1991563632 r3 0x4f208 324104 r4 0xf 15 r5 0x7e91882c 2123466796 r6 0x76b4cef8 1991560952 r7 0x76b4cb20 1991559968 r8 0x76b4d040 1991561280 r9 0x76ffb000 1996468224 r10 0x200000 2097152 r11 0x7e91882c 2123466796 r12 0x45f14 286484 sp 0x76b4cb18 0x76b4cb18 lr 0x18a07 100871 pc 0x76f5d7f4 0x76f5d7f4 cpsr 0x10 16 (gdb) si 0x76f5d7f8 in getcontext () from /lib//libc.so.0 1: x/i $pc => 0x76f5d7f8 : str r2, [r0, #32] (gdb) 0x76f5d7fc in getcontext () from /lib//libc.so.0 1: x/i $pc => 0x76f5d7fc : mov r4, r0 (gdb) info registers r0 0x4f208 324104 r1 0x4f238 324152 r2 0x0 0 r3 0x4f208 324104 r4 0xf 15 r5 0x7e91882c 2123466796 r6 0x76b4cef8 1991560952 r7 0x76b4cb20 1991559968 r8 0x76b4d040 1991561280 r9 0x76ffb000 1996468224 r10 0x200000 2097152 r11 0x7e91882c 2123466796 r12 0x45f14 286484 sp 0x76b4cb18 0x76b4cb18 lr 0x18a07 100871 pc 0x76f5d7fc 0x76f5d7fc cpsr 0x10 16 (gdb) si 0x76f5d800 in getcontext () from /lib//libc.so.0 1: x/i $pc => 0x76f5d800 : mov r0, #0 (gdb) 0x76f5d804 in getcontext () from /lib//libc.so.0 1: x/i $pc => 0x76f5d804 : mov r1, #0 (gdb) info registers r0 0x0 0 r1 0x4f238 324152 r2 0x0 0 r3 0x4f208 324104 r4 0x4f208 324104 r5 0x7e91882c 2123466796 r6 0x76b4cef8 1991560952 r7 0x76b4cb20 1991559968 r8 0x76b4d040 1991561280 r9 0x76ffb000 1996468224 r10 0x200000 2097152 r11 0x7e91882c 2123466796 r12 0x45f14 286484 sp 0x76b4cb18 0x76b4cb18 lr 0x18a07 100871 pc 0x76f5d804 0x76f5d804 cpsr 0x10 16 (gdb) si 0x76f5d808 in getcontext () from /lib//libc.so.0 1: x/i $pc => 0x76f5d808 : add r2, r4, #104 ; 0x68 (gdb) 0x76f5d80c in getcontext () from /lib//libc.so.0 1: x/i $pc => 0x76f5d80c : bl 0x76f5d008 (gdb) info registers r0 0x0 0 r1 0x0 0 r2 0x4f270 324208 r3 0x4f208 324104 r4 0x4f208 324104 r5 0x7e91882c 2123466796 r6 0x76b4cef8 1991560952 r7 0x76b4cb20 1991559968 r8 0x76b4d040 1991561280 r9 0x76ffb000 1996468224 r10 0x200000 2097152 r11 0x7e91882c 2123466796 r12 0x45f14 286484 sp 0x76b4cb18 0x76b4cb18 lr 0x18a07 100871 pc 0x76f5d80c 0x76f5d80c cpsr 0x10 16 (gdb) si 0x76f5d008 in ?? () from /lib//libc.so.0 1: x/i $pc => 0x76f5d008: add r12, pc, #0, 12 (gdb) 0x76f5d00c in ?? () from /lib//libc.so.0 1: x/i $pc => 0x76f5d00c: add r12, r12, #352256 ; 0x56000 (gdb) info registers r0 0x0 0 r1 0x0 0 r2 0x4f270 324208 r3 0x4f208 324104 r4 0x4f208 324104 r5 0x7e91882c 2123466796 r6 0x76b4cef8 1991560952 r7 0x76b4cb20 1991559968 r8 0x76b4d040 1991561280 r9 0x76ffb000 1996468224 r10 0x200000 2097152 r11 0x7e91882c 2123466796 r12 0x76f5d010 1995821072 sp 0x76b4cb18 0x76b4cb18 lr 0x76f5d810 1995823120 pc 0x76f5d00c 0x76f5d00c cpsr 0x10 16 (gdb) si 0x76f5d010 in ?? () from /lib//libc.so.0 1: x/i $pc => 0x76f5d010: ldr pc, [r12, #3824]! ; 0xef0 (gdb) 0x76f607cc in sigprocmask () from /lib//libc.so.0 1: x/i $pc => 0x76f607cc : push {r0, r1, r2, r3, r4, r5, r6, lr} (gdb) info registers r0 0x0 0 r1 0x0 0 r2 0x4f270 324208 r3 0x4f208 324104 r4 0x4f208 324104 r5 0x7e91882c 2123466796 r6 0x76b4cef8 1991560952 r7 0x76b4cb20 1991559968 r8 0x76b4d040 1991561280 r9 0x76ffb000 1996468224 r10 0x200000 2097152 r11 0x7e91882c 2123466796 r12 0x76fb3f00 1996177152 sp 0x76b4cb18 0x76b4cb18 lr 0x76f5d810 1995823120 pc 0x76f607cc 0x76f607cc cpsr 0x30 48 (gdb) si 0x76f607ce in sigprocmask () from /lib//libc.so.0 1: x/i $pc => 0x76f607ce : mov r5, r0 (gdb) 0x76f607d0 in sigprocmask () from /lib//libc.so.0 1: x/i $pc => 0x76f607d0 : cbz r1, 0x76f607f4 (gdb) info registers r0 0x0 0 r1 0x0 0 r2 0x4f270 324208 r3 0x4f208 324104 r4 0x4f208 324104 r5 0x0 0 r6 0x76b4cef8 1991560952 r7 0x76b4cb20 1991559968 r8 0x76b4d040 1991561280 r9 0x76ffb000 1996468224 r10 0x200000 2097152 r11 0x7e91882c 2123466796 r12 0x76fb3f00 1996177152 sp 0x76b4caf8 0x76b4caf8 lr 0x76f5d810 1995823120 pc 0x76f607d0 0x76f607d0 cpsr 0x30 48 (gdb) si 0x76f607f4 in sigprocmask () from /lib//libc.so.0 1: x/i $pc => 0x76f607f4 : movs r3, #175 ; 0xaf (gdb) 0x76f607f6 in sigprocmask () from /lib//libc.so.0 1: x/i $pc => 0x76f607f6 : add r6, sp, #8 (gdb) info registers r0 0x0 0 r1 0x0 0 r2 0x4f270 324208 r3 0xaf 175 r4 0x4f208 324104 r5 0x0 0 r6 0x76b4cef8 1991560952 r7 0x76b4cb20 1991559968 r8 0x76b4d040 1991561280 r9 0x76ffb000 1996468224 r10 0x200000 2097152 r11 0x7e91882c 2123466796 r12 0x76fb3f00 1996177152 sp 0x76b4caf8 0x76b4caf8 lr 0x76f5d810 1995823120 pc 0x76f607f6 0x76f607f6 cpsr 0x30 48 (gdb) si 0x76f607f8 in sigprocmask () from /lib//libc.so.0 1: x/i $pc => 0x76f607f8 : str r3, [sp, #8] (gdb) 0x76f607fa in sigprocmask () from /lib//libc.so.0 1: x/i $pc => 0x76f607fa : mov r0, r5 (gdb) info registers r0 0x0 0 r1 0x0 0 r2 0x4f270 324208 r3 0xaf 175 r4 0x4f208 324104 r5 0x0 0 r6 0x76b4cb00 1991559936 r7 0x76b4cb20 1991559968 r8 0x76b4d040 1991561280 r9 0x76ffb000 1996468224 r10 0x200000 2097152 r11 0x7e91882c 2123466796 r12 0x76fb3f00 1996177152 sp 0x76b4caf8 0x76b4caf8 lr 0x76f5d810 1995823120 pc 0x76f607fa 0x76f607fa cpsr 0x30 48 (gdb) si 0x76f607fc in sigprocmask () from /lib//libc.so.0 1: x/i $pc => 0x76f607fc : movs r3, #8 (gdb) 0x76f607fe in sigprocmask () from /lib//libc.so.0 1: x/i $pc => 0x76f607fe : str r7, [r6, #4] (gdb) info registers r0 0x0 0 r1 0x0 0 r2 0x4f270 324208 r3 0x8 8 r4 0x4f208 324104 r5 0x0 0 r6 0x76b4cb00 1991559936 r7 0x76b4cb20 1991559968 r8 0x76b4d040 1991561280 r9 0x76ffb000 1996468224 r10 0x200000 2097152 r11 0x7e91882c 2123466796 r12 0x76fb3f00 1996177152 sp 0x76b4caf8 0x76b4caf8 lr 0x76f5d810 1995823120 pc 0x76f607fe 0x76f607fe cpsr 0x30 48 (gdb) si 0x76f60800 in sigprocmask () from /lib//libc.so.0 1: x/i $pc => 0x76f60800 : ldr r7, [r6, #0] (gdb) 0x76f60802 in sigprocmask () from /lib//libc.so.0 1: x/i $pc => 0x76f60802 : svc 0 (gdb) info registers r0 0x0 0 r1 0x0 0 r2 0x4f270 324208 r3 0x8 8 r4 0x4f208 324104 r5 0x0 0 r6 0x76b4cb00 1991559936 r7 0xaf 175 r8 0x76b4d040 1991561280 r9 0x76ffb000 1996468224 r10 0x200000 2097152 r11 0x7e91882c 2123466796 r12 0x76fb3f00 1996177152 sp 0x76b4caf8 0x76b4caf8 lr 0x76f5d810 1995823120 pc 0x76f60802 0x76f60802 cpsr 0x30 48 (gdb) si 0x76f60804 in sigprocmask () from /lib//libc.so.0 1: x/i $pc => 0x76f60804 : ldr r7, [r6, #4] (gdb) 0x76f60806 in sigprocmask () from /lib//libc.so.0 1: x/i $pc => 0x76f60806 : cmn.w r0, #4096 ; 0x1000 (gdb) info registers r0 0x0 0 r1 0x0 0 r2 0x4f270 324208 r3 0x8 8 r4 0x4f208 324104 r5 0x0 0 r6 0x76b4cb00 1991559936 r7 0x76b4cb20 1991559968 r8 0x76b4d040 1991561280 r9 0x76ffb000 1996468224 r10 0x200000 2097152 r11 0x7e91882c 2123466796 r12 0x76fb3f00 1996177152 sp 0x76b4caf8 0x76b4caf8 lr 0x76f5d810 1995823120 pc 0x76f60806 0x76f60806 cpsr 0x30 48 (gdb) si 0x76f6080a in sigprocmask () from /lib//libc.so.0 1: x/i $pc => 0x76f6080a : bls.n 0x76f6081e (gdb) 0x76f6081e in sigprocmask () from /lib//libc.so.0 1: x/i $pc => 0x76f6081e : add sp, #16 (gdb) info registers r0 0x0 0 r1 0x0 0 r2 0x4f270 324208 r3 0x8 8 r4 0x4f208 324104 r5 0x0 0 r6 0x76b4cb00 1991559936 r7 0x76b4cb20 1991559968 r8 0x76b4d040 1991561280 r9 0x76ffb000 1996468224 r10 0x200000 2097152 r11 0x7e91882c 2123466796 r12 0x76fb3f00 1996177152 sp 0x76b4caf8 0x76b4caf8 lr 0x76f5d810 1995823120 pc 0x76f6081e 0x76f6081e cpsr 0x30 48 (gdb) si 0x76f60820 in sigprocmask () from /lib//libc.so.0 1: x/i $pc => 0x76f60820 : pop {r4, r5, r6, pc} (gdb) 0x76f5d810 in getcontext () from /lib//libc.so.0 1: x/i $pc => 0x76f5d810 : vstmia r0!, {d8-d15} (gdb) info registers r0 0x0 0 r1 0x0 0 r2 0x4f270 324208 r3 0x8 8 r4 0x4f208 324104 r5 0x7e91882c 2123466796 r6 0x76b4cef8 1991560952 r7 0x76b4cb20 1991559968 r8 0x76b4d040 1991561280 r9 0x76ffb000 1996468224 r10 0x200000 2097152 r11 0x7e91882c 2123466796 r12 0x76fb3f00 1996177152 sp 0x76b4cb18 0x76b4cb18 lr 0x76f5d810 1995823120 pc 0x76f5d810 0x76f5d810 cpsr 0x10 16 (gdb) si Program received signal SIGSEGV, Segmentation fault. 0x76f5d810 in getcontext () from /lib//libc.so.0 1: x/i $pc => 0x76f5d810 : vstmia r0!, {d8-d15} (gdb) [LWP 24295 exited] [LWP 24300 exited] Program terminated with signal SIGSEGV, Segmentation fault. The program no longer exists. ```

lpereira commented 4 years ago

Interesting. It's trying to store the SIMD registers onto address 0. Not sure if a bug in uClibc, or what's happening here. What version of uClibc are you using? The uClibc-ng, I presume, since the original one has not been maintained in a few years?

dset0x commented 4 years ago

As built with https://github.com/buildroot/buildroot/tree/2019.02/package/uclibc, therefore https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/tree/?h=v1.0.31

lpereira commented 4 years ago

The funny thing is that I added 32-bit x86 support for Lwan's coroutines (rather than relying on the deprecated ucontext.h, which wasn't available in the original uClibc) because I wanted to use it on a x86 board with an OS built with this C library. Will probably have to add 1st-class support for ARM processors. This will take a while as I'm not working on any project in my free time for a while, but I'll keep this issue updated.

lpereira commented 4 years ago

One of the things we could try here is to use libucontext -- and use it instead of the ucontext provided by the C library. It should be possible to do this with minimal changes to the build system. (I don't have an ARM machine I can play with readily here. My RPis are being used right now and I can't disturb them.)

lpereira commented 4 years ago

I've tentatively pushed a change to CMakeLists.txt so that it'll look for libucontext when building on ARM. Could you please try this out after installing that library?

dset0x commented 4 years ago

Hey - appreciate you looking for a fix already!

Note I'm building with buildroot now to save myself from figuring out how to get it to detect libucontext. Seems to be loading the new library,

...
-- armv7l processor detected, looking for libucontext
-- libucontext found, using it for context switching routines
...

Note that I couldn't get gdb to load the sources this time, so the breakpoint is on getcontext. I'm not sure if that was the right thing to do, or if the right getcontext is actually being used.

gdb output

``` Breakpoint 1, 0x76e747e0 in getcontext () from /lib//libc.so.0 (gdb) display/i $pc 1: x/i $pc => 0x76e747e0 : add r1, r0, #48 ; 0x30 (gdb) info registers r0 0x43148 274760 r1 0x433c0 275392 r2 0x43140 274752 r3 0x0 0 r4 0x43140 274752 r5 0x76f0a000 1995481088 r6 0x1cb2d 117549 r7 0x43c98 277656 r8 0x76a63c50 1990605904 r9 0x43bc0 277440 r10 0x5cc60 380000 r11 0x7ec2fbb0 2126707632 r12 0x38f20 233248 sp 0x76a63b60 0x76a63b60 lr 0x16441 91201 pc 0x76e747e0 0x76e747e0 cpsr 0x40000010 1073741840 (gdb) si 0x76e747e4 in getcontext () from /lib//libc.so.0 1: x/i $pc => 0x76e747e4 : stm r1, {r4, r5, r6, r7, r8, r9, r10, r11} (gdb) info registers r0 0x43148 274760 r1 0x43178 274808 r2 0x43140 274752 r3 0x0 0 r4 0x43140 274752 r5 0x76f0a000 1995481088 r6 0x1cb2d 117549 r7 0x43c98 277656 r8 0x76a63c50 1990605904 r9 0x43bc0 277440 r10 0x5cc60 380000 r11 0x7ec2fbb0 2126707632 r12 0x38f20 233248 sp 0x76a63b60 0x76a63b60 lr 0x16441 91201 pc 0x76e747e4 0x76e747e4 cpsr 0x40000010 1073741840 (gdb) si 0x76e747e8 in getcontext () from /lib//libc.so.0 1: x/i $pc => 0x76e747e8 : str sp, [r0, #84] ; 0x54 (gdb) info registers r0 0x43148 274760 r1 0x43178 274808 r2 0x43140 274752 r3 0x0 0 r4 0x43140 274752 r5 0x76f0a000 1995481088 r6 0x1cb2d 117549 r7 0x43c98 277656 r8 0x76a63c50 1990605904 r9 0x43bc0 277440 r10 0x5cc60 380000 r11 0x7ec2fbb0 2126707632 r12 0x38f20 233248 sp 0x76a63b60 0x76a63b60 lr 0x16441 91201 pc 0x76e747e8 0x76e747e8 cpsr 0x40000010 1073741840 (gdb) si 0x76e747ec in getcontext () from /lib//libc.so.0 1: x/i $pc => 0x76e747ec : str lr, [r0, #88] ; 0x58 (gdb) info registers r0 0x43148 274760 r1 0x43178 274808 r2 0x43140 274752 r3 0x0 0 r4 0x43140 274752 r5 0x76f0a000 1995481088 r6 0x1cb2d 117549 r7 0x43c98 277656 r8 0x76a63c50 1990605904 r9 0x43bc0 277440 r10 0x5cc60 380000 r11 0x7ec2fbb0 2126707632 r12 0x38f20 233248 sp 0x76a63b60 0x76a63b60 lr 0x16441 91201 pc 0x76e747ec 0x76e747ec cpsr 0x40000010 1073741840 (gdb) si 0x76e747f0 in getcontext () from /lib//libc.so.0 1: x/i $pc => 0x76e747f0 : str lr, [r0, #92] ; 0x5c (gdb) info registers r0 0x43148 274760 r1 0x43178 274808 r2 0x43140 274752 r3 0x0 0 r4 0x43140 274752 r5 0x76f0a000 1995481088 r6 0x1cb2d 117549 r7 0x43c98 277656 r8 0x76a63c50 1990605904 r9 0x43bc0 277440 r10 0x5cc60 380000 r11 0x7ec2fbb0 2126707632 r12 0x38f20 233248 sp 0x76a63b60 0x76a63b60 lr 0x16441 91201 pc 0x76e747f0 0x76e747f0 cpsr 0x40000010 1073741840 (gdb) si 0x76e747f4 in getcontext () from /lib//libc.so.0 1: x/i $pc => 0x76e747f4 : mov r2, #0 (gdb) info registers r0 0x43148 274760 r1 0x43178 274808 r2 0x43140 274752 r3 0x0 0 r4 0x43140 274752 r5 0x76f0a000 1995481088 r6 0x1cb2d 117549 r7 0x43c98 277656 r8 0x76a63c50 1990605904 r9 0x43bc0 277440 r10 0x5cc60 380000 r11 0x7ec2fbb0 2126707632 r12 0x38f20 233248 sp 0x76a63b60 0x76a63b60 lr 0x16441 91201 pc 0x76e747f4 0x76e747f4 cpsr 0x40000010 1073741840 (gdb) si 0x76e747f8 in getcontext () from /lib//libc.so.0 1: x/i $pc => 0x76e747f8 : str r2, [r0, #32] (gdb) info registers r0 0x43148 274760 r1 0x43178 274808 r2 0x0 0 r3 0x0 0 r4 0x43140 274752 r5 0x76f0a000 1995481088 r6 0x1cb2d 117549 r7 0x43c98 277656 r8 0x76a63c50 1990605904 r9 0x43bc0 277440 r10 0x5cc60 380000 r11 0x7ec2fbb0 2126707632 r12 0x38f20 233248 sp 0x76a63b60 0x76a63b60 lr 0x16441 91201 pc 0x76e747f8 0x76e747f8 cpsr 0x40000010 1073741840 (gdb) si 0x76e747fc in getcontext () from /lib//libc.so.0 1: x/i $pc => 0x76e747fc : mov r4, r0 (gdb) info registers r0 0x43148 274760 r1 0x43178 274808 r2 0x0 0 r3 0x0 0 r4 0x43140 274752 r5 0x76f0a000 1995481088 r6 0x1cb2d 117549 r7 0x43c98 277656 r8 0x76a63c50 1990605904 r9 0x43bc0 277440 r10 0x5cc60 380000 r11 0x7ec2fbb0 2126707632 r12 0x38f20 233248 sp 0x76a63b60 0x76a63b60 lr 0x16441 91201 pc 0x76e747fc 0x76e747fc cpsr 0x40000010 1073741840 (gdb) si 0x76e74800 in getcontext () from /lib//libc.so.0 1: x/i $pc => 0x76e74800 : mov r0, #0 (gdb) info registers r0 0x43148 274760 r1 0x43178 274808 r2 0x0 0 r3 0x0 0 r4 0x43148 274760 r5 0x76f0a000 1995481088 r6 0x1cb2d 117549 r7 0x43c98 277656 r8 0x76a63c50 1990605904 r9 0x43bc0 277440 r10 0x5cc60 380000 r11 0x7ec2fbb0 2126707632 r12 0x38f20 233248 sp 0x76a63b60 0x76a63b60 lr 0x16441 91201 pc 0x76e74800 0x76e74800 cpsr 0x40000010 1073741840 (gdb) si 0x76e74804 in getcontext () from /lib//libc.so.0 1: x/i $pc => 0x76e74804 : mov r1, #0 (gdb) info registers r0 0x0 0 r1 0x43178 274808 r2 0x0 0 r3 0x0 0 r4 0x43148 274760 r5 0x76f0a000 1995481088 r6 0x1cb2d 117549 r7 0x43c98 277656 r8 0x76a63c50 1990605904 r9 0x43bc0 277440 r10 0x5cc60 380000 r11 0x7ec2fbb0 2126707632 r12 0x38f20 233248 sp 0x76a63b60 0x76a63b60 lr 0x16441 91201 pc 0x76e74804 0x76e74804 cpsr 0x40000010 1073741840 (gdb) si 0x76e74808 in getcontext () from /lib//libc.so.0 1: x/i $pc => 0x76e74808 : add r2, r4, #104 ; 0x68 (gdb) info registers r0 0x0 0 r1 0x0 0 r2 0x0 0 r3 0x0 0 r4 0x43148 274760 r5 0x76f0a000 1995481088 r6 0x1cb2d 117549 r7 0x43c98 277656 r8 0x76a63c50 1990605904 r9 0x43bc0 277440 r10 0x5cc60 380000 r11 0x7ec2fbb0 2126707632 r12 0x38f20 233248 sp 0x76a63b60 0x76a63b60 lr 0x16441 91201 pc 0x76e74808 0x76e74808 cpsr 0x40000010 1073741840 (gdb) si 0x76e7480c in getcontext () from /lib//libc.so.0 1: x/i $pc => 0x76e7480c : bl 0x76e74008 (gdb) info registers r0 0x0 0 r1 0x0 0 r2 0x431b0 274864 r3 0x0 0 r4 0x43148 274760 r5 0x76f0a000 1995481088 r6 0x1cb2d 117549 r7 0x43c98 277656 r8 0x76a63c50 1990605904 r9 0x43bc0 277440 r10 0x5cc60 380000 r11 0x7ec2fbb0 2126707632 r12 0x38f20 233248 sp 0x76a63b60 0x76a63b60 lr 0x16441 91201 pc 0x76e7480c 0x76e7480c cpsr 0x40000010 1073741840 (gdb) si 0x76e74008 in ?? () from /lib//libc.so.0 1: x/i $pc => 0x76e74008: add r12, pc, #0, 12 (gdb) info registers r0 0x0 0 r1 0x0 0 r2 0x431b0 274864 r3 0x0 0 r4 0x43148 274760 r5 0x76f0a000 1995481088 r6 0x1cb2d 117549 r7 0x43c98 277656 r8 0x76a63c50 1990605904 r9 0x43bc0 277440 r10 0x5cc60 380000 r11 0x7ec2fbb0 2126707632 r12 0x38f20 233248 sp 0x76a63b60 0x76a63b60 lr 0x76e74810 1994868752 pc 0x76e74008 0x76e74008 cpsr 0x40000010 1073741840 (gdb) si 0x76e7400c in ?? () from /lib//libc.so.0 1: x/i $pc => 0x76e7400c: add r12, r12, #352256 ; 0x56000 (gdb) info registers r0 0x0 0 r1 0x0 0 r2 0x431b0 274864 r3 0x0 0 r4 0x43148 274760 r5 0x76f0a000 1995481088 r6 0x1cb2d 117549 r7 0x43c98 277656 r8 0x76a63c50 1990605904 r9 0x43bc0 277440 r10 0x5cc60 380000 r11 0x7ec2fbb0 2126707632 r12 0x76e74010 1994866704 sp 0x76a63b60 0x76a63b60 lr 0x76e74810 1994868752 pc 0x76e7400c 0x76e7400c cpsr 0x40000010 1073741840 (gdb) si 0x76e74010 in ?? () from /lib//libc.so.0 1: x/i $pc => 0x76e74010: ldr pc, [r12, #3824]! ; 0xef0 (gdb) info registers r0 0x0 0 r1 0x0 0 r2 0x431b0 274864 r3 0x0 0 r4 0x43148 274760 r5 0x76f0a000 1995481088 r6 0x1cb2d 117549 r7 0x43c98 277656 r8 0x76a63c50 1990605904 r9 0x43bc0 277440 r10 0x5cc60 380000 r11 0x7ec2fbb0 2126707632 r12 0x76eca010 1995218960 sp 0x76a63b60 0x76a63b60 lr 0x76e74810 1994868752 pc 0x76e74010 0x76e74010 cpsr 0x40000010 1073741840 (gdb) si 0x76e777cc in sigprocmask () from /lib//libc.so.0 1: x/i $pc => 0x76e777cc : push {r0, r1, r2, r3, r4, r5, r6, lr} (gdb) info registers r0 0x0 0 r1 0x0 0 r2 0x431b0 274864 r3 0x0 0 r4 0x43148 274760 r5 0x76f0a000 1995481088 r6 0x1cb2d 117549 r7 0x43c98 277656 r8 0x76a63c50 1990605904 r9 0x43bc0 277440 r10 0x5cc60 380000 r11 0x7ec2fbb0 2126707632 r12 0x76ecaf00 1995222784 sp 0x76a63b60 0x76a63b60 lr 0x76e74810 1994868752 pc 0x76e777cc 0x76e777cc cpsr 0x40000030 1073741872 (gdb) si 0x76e777ce in sigprocmask () from /lib//libc.so.0 1: x/i $pc => 0x76e777ce : mov r5, r0 (gdb) info registers r0 0x0 0 r1 0x0 0 r2 0x431b0 274864 r3 0x0 0 r4 0x43148 274760 r5 0x76f0a000 1995481088 r6 0x1cb2d 117549 r7 0x43c98 277656 r8 0x76a63c50 1990605904 r9 0x43bc0 277440 r10 0x5cc60 380000 r11 0x7ec2fbb0 2126707632 r12 0x76ecaf00 1995222784 sp 0x76a63b40 0x76a63b40 lr 0x76e74810 1994868752 pc 0x76e777ce 0x76e777ce cpsr 0x40000030 1073741872 (gdb) si 0x76e777d0 in sigprocmask () from /lib//libc.so.0 1: x/i $pc => 0x76e777d0 : cbz r1, 0x76e777f4 (gdb) info registers r0 0x0 0 r1 0x0 0 r2 0x431b0 274864 r3 0x0 0 r4 0x43148 274760 r5 0x0 0 r6 0x1cb2d 117549 r7 0x43c98 277656 r8 0x76a63c50 1990605904 r9 0x43bc0 277440 r10 0x5cc60 380000 r11 0x7ec2fbb0 2126707632 r12 0x76ecaf00 1995222784 sp 0x76a63b40 0x76a63b40 lr 0x76e74810 1994868752 pc 0x76e777d0 0x76e777d0 cpsr 0x40000030 1073741872 (gdb) si 0x76e777f4 in sigprocmask () from /lib//libc.so.0 1: x/i $pc => 0x76e777f4 : movs r3, #175 ; 0xaf (gdb) info registers r0 0x0 0 r1 0x0 0 r2 0x431b0 274864 r3 0x0 0 r4 0x43148 274760 r5 0x0 0 r6 0x1cb2d 117549 r7 0x43c98 277656 r8 0x76a63c50 1990605904 r9 0x43bc0 277440 r10 0x5cc60 380000 r11 0x7ec2fbb0 2126707632 r12 0x76ecaf00 1995222784 sp 0x76a63b40 0x76a63b40 lr 0x76e74810 1994868752 pc 0x76e777f4 0x76e777f4 cpsr 0x40000030 1073741872 (gdb) si 0x76e777f6 in sigprocmask () from /lib//libc.so.0 1: x/i $pc => 0x76e777f6 : add r6, sp, #8 (gdb) info registers r0 0x0 0 r1 0x0 0 r2 0x431b0 274864 r3 0xaf 175 r4 0x43148 274760 r5 0x0 0 r6 0x1cb2d 117549 r7 0x43c98 277656 r8 0x76a63c50 1990605904 r9 0x43bc0 277440 r10 0x5cc60 380000 r11 0x7ec2fbb0 2126707632 r12 0x76ecaf00 1995222784 sp 0x76a63b40 0x76a63b40 lr 0x76e74810 1994868752 pc 0x76e777f6 0x76e777f6 cpsr 0x30 48 (gdb) si 0x76e777f8 in sigprocmask () from /lib//libc.so.0 1: x/i $pc => 0x76e777f8 : str r3, [sp, #8] (gdb) info registers r0 0x0 0 r1 0x0 0 r2 0x431b0 274864 r3 0xaf 175 r4 0x43148 274760 r5 0x0 0 r6 0x76a63b48 1990605640 r7 0x43c98 277656 r8 0x76a63c50 1990605904 r9 0x43bc0 277440 r10 0x5cc60 380000 r11 0x7ec2fbb0 2126707632 r12 0x76ecaf00 1995222784 sp 0x76a63b40 0x76a63b40 lr 0x76e74810 1994868752 pc 0x76e777f8 0x76e777f8 cpsr 0x30 48 (gdb) si 0x76e777fa in sigprocmask () from /lib//libc.so.0 1: x/i $pc => 0x76e777fa : mov r0, r5 (gdb) info registers r0 0x0 0 r1 0x0 0 r2 0x431b0 274864 r3 0xaf 175 r4 0x43148 274760 r5 0x0 0 r6 0x76a63b48 1990605640 r7 0x43c98 277656 r8 0x76a63c50 1990605904 r9 0x43bc0 277440 r10 0x5cc60 380000 r11 0x7ec2fbb0 2126707632 r12 0x76ecaf00 1995222784 sp 0x76a63b40 0x76a63b40 lr 0x76e74810 1994868752 pc 0x76e777fa 0x76e777fa cpsr 0x30 48 (gdb) si 0x76e777fc in sigprocmask () from /lib//libc.so.0 1: x/i $pc => 0x76e777fc : movs r3, #8 (gdb) info registers r0 0x0 0 r1 0x0 0 r2 0x431b0 274864 r3 0xaf 175 r4 0x43148 274760 r5 0x0 0 r6 0x76a63b48 1990605640 r7 0x43c98 277656 r8 0x76a63c50 1990605904 r9 0x43bc0 277440 r10 0x5cc60 380000 r11 0x7ec2fbb0 2126707632 r12 0x76ecaf00 1995222784 sp 0x76a63b40 0x76a63b40 lr 0x76e74810 1994868752 pc 0x76e777fc 0x76e777fc cpsr 0x30 48 (gdb) si 0x76e777fe in sigprocmask () from /lib//libc.so.0 1: x/i $pc => 0x76e777fe : str r7, [r6, #4] (gdb) info registers r0 0x0 0 r1 0x0 0 r2 0x431b0 274864 r3 0x8 8 r4 0x43148 274760 r5 0x0 0 r6 0x76a63b48 1990605640 r7 0x43c98 277656 r8 0x76a63c50 1990605904 r9 0x43bc0 277440 r10 0x5cc60 380000 r11 0x7ec2fbb0 2126707632 r12 0x76ecaf00 1995222784 sp 0x76a63b40 0x76a63b40 lr 0x76e74810 1994868752 pc 0x76e777fe 0x76e777fe cpsr 0x30 48 (gdb) si 0x76e77800 in sigprocmask () from /lib//libc.so.0 1: x/i $pc => 0x76e77800 : ldr r7, [r6, #0] (gdb) info registers r0 0x0 0 r1 0x0 0 r2 0x431b0 274864 r3 0x8 8 r4 0x43148 274760 r5 0x0 0 r6 0x76a63b48 1990605640 r7 0x43c98 277656 r8 0x76a63c50 1990605904 r9 0x43bc0 277440 r10 0x5cc60 380000 r11 0x7ec2fbb0 2126707632 r12 0x76ecaf00 1995222784 sp 0x76a63b40 0x76a63b40 lr 0x76e74810 1994868752 pc 0x76e77800 0x76e77800 cpsr 0x30 48 (gdb) si 0x76e77802 in sigprocmask () from /lib//libc.so.0 1: x/i $pc => 0x76e77802 : svc 0 (gdb) info registers r0 0x0 0 r1 0x0 0 r2 0x431b0 274864 r3 0x8 8 r4 0x43148 274760 r5 0x0 0 r6 0x76a63b48 1990605640 r7 0xaf 175 r8 0x76a63c50 1990605904 r9 0x43bc0 277440 r10 0x5cc60 380000 r11 0x7ec2fbb0 2126707632 r12 0x76ecaf00 1995222784 sp 0x76a63b40 0x76a63b40 lr 0x76e74810 1994868752 pc 0x76e77802 0x76e77802 cpsr 0x30 48 (gdb) si 0x76e77804 in sigprocmask () from /lib//libc.so.0 1: x/i $pc => 0x76e77804 : ldr r7, [r6, #4] (gdb) info registers r0 0x0 0 r1 0x0 0 r2 0x431b0 274864 r3 0x8 8 r4 0x43148 274760 r5 0x0 0 r6 0x76a63b48 1990605640 r7 0xaf 175 r8 0x76a63c50 1990605904 r9 0x43bc0 277440 r10 0x5cc60 380000 r11 0x7ec2fbb0 2126707632 r12 0x76ecaf00 1995222784 sp 0x76a63b40 0x76a63b40 lr 0x76e74810 1994868752 pc 0x76e77804 0x76e77804 cpsr 0x30 48 (gdb) si 0x76e77806 in sigprocmask () from /lib//libc.so.0 1: x/i $pc => 0x76e77806 : cmn.w r0, #4096 ; 0x1000 (gdb) info registers r0 0x0 0 r1 0x0 0 r2 0x431b0 274864 r3 0x8 8 r4 0x43148 274760 r5 0x0 0 r6 0x76a63b48 1990605640 r7 0x43c98 277656 r8 0x76a63c50 1990605904 r9 0x43bc0 277440 r10 0x5cc60 380000 r11 0x7ec2fbb0 2126707632 r12 0x76ecaf00 1995222784 sp 0x76a63b40 0x76a63b40 lr 0x76e74810 1994868752 pc 0x76e77806 0x76e77806 cpsr 0x30 48 (gdb) si 0x76e7780a in sigprocmask () from /lib//libc.so.0 1: x/i $pc => 0x76e7780a : bls.n 0x76e7781e (gdb) info registers r0 0x0 0 r1 0x0 0 r2 0x431b0 274864 r3 0x8 8 r4 0x43148 274760 r5 0x0 0 r6 0x76a63b48 1990605640 r7 0x43c98 277656 r8 0x76a63c50 1990605904 r9 0x43bc0 277440 r10 0x5cc60 380000 r11 0x7ec2fbb0 2126707632 r12 0x76ecaf00 1995222784 sp 0x76a63b40 0x76a63b40 lr 0x76e74810 1994868752 pc 0x76e7780a 0x76e7780a cpsr 0x30 48 (gdb) si 0x76e7781e in sigprocmask () from /lib//libc.so.0 1: x/i $pc => 0x76e7781e : add sp, #16 (gdb) info registers r0 0x0 0 r1 0x0 0 r2 0x431b0 274864 r3 0x8 8 r4 0x43148 274760 r5 0x0 0 r6 0x76a63b48 1990605640 r7 0x43c98 277656 r8 0x76a63c50 1990605904 r9 0x43bc0 277440 r10 0x5cc60 380000 r11 0x7ec2fbb0 2126707632 r12 0x76ecaf00 1995222784 sp 0x76a63b40 0x76a63b40 lr 0x76e74810 1994868752 pc 0x76e7781e 0x76e7781e cpsr 0x30 48 (gdb) si 0x76e77820 in sigprocmask () from /lib//libc.so.0 1: x/i $pc => 0x76e77820 : pop {r4, r5, r6, pc} (gdb) info registers r0 0x0 0 r1 0x0 0 r2 0x431b0 274864 r3 0x8 8 r4 0x43148 274760 r5 0x0 0 r6 0x76a63b48 1990605640 r7 0x43c98 277656 r8 0x76a63c50 1990605904 r9 0x43bc0 277440 r10 0x5cc60 380000 r11 0x7ec2fbb0 2126707632 r12 0x76ecaf00 1995222784 sp 0x76a63b50 0x76a63b50 lr 0x76e74810 1994868752 pc 0x76e77820 0x76e77820 cpsr 0x30 48 (gdb) si 0x76e74810 in getcontext () from /lib//libc.so.0 1: x/i $pc => 0x76e74810 : vstmia r0!, {d8-d15} (gdb) info registers r0 0x0 0 r1 0x0 0 r2 0x431b0 274864 r3 0x8 8 r4 0x43148 274760 r5 0x76f0a000 1995481088 r6 0x1cb2d 117549 r7 0x43c98 277656 r8 0x76a63c50 1990605904 r9 0x43bc0 277440 r10 0x5cc60 380000 r11 0x7ec2fbb0 2126707632 r12 0x76ecaf00 1995222784 sp 0x76a63b60 0x76a63b60 lr 0x76e74810 1994868752 pc 0x76e74810 0x76e74810 cpsr 0x10 16 (gdb) si Program received signal SIGSEGV, Segmentation fault. 0x76e74810 in getcontext () from /lib//libc.so.0 ```

lpereira commented 4 years ago

From the looks of it, the getcontext() being used is from the C library. Will see if I can find a spare SD card here and remove the dust from my RPi and see what I can do. It's time for proper ARM support :)

lpereira commented 3 years ago

Hi -- it took a long while but I've finally fixed the libucontext support yesterday. Tested working on a Raspberry Pi (AARCH64) running Raspbian. You have to build the library with meson rather than make, though; the Makefile seems broken somehow.

lpereira commented 3 years ago

Better yet -- now, if you build Lwan on non-x86 targets, it should download and build libucontext for you (they merged a patch I sent fixing build with Makefiles on armv7l today).

dset0x commented 3 years ago

Thanks so much for fixing this. Unfortunately I no longer have access to the hardware or build environment this was targeting. (I had to continue that project with a different server)

Feel free to close this issue!