On 10/17/2013 11:41 PM, Andrew W wrote:

and more :-

(gdb) cont
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x00000000 in ?? ()
(gdb) bt
#0 0x00000000 in ?? ()
#1 0x001ad15c in gcaddRange () at ../../../../gcc-4.8-20131010/libphobos/libdruntime/gc/gc.d:293
#2 0x00174fb4 in vibe.utils.memory.
T19FreeListObjectAllocTS4vibe4core7drivers13libevent2tcp10TCPContextVb0Vb1Z._T5allocTC4vibe4core6driver10DriverCoreTPS6deimos6event212eventstruct10eventbaseTiTPS6deimos6event211bufferevent11buffereventTS4vibe4core3net14NetworkAddressTS4vibe4core3net14NetworkAddressZ.alloc() ()
#3 0x00034008 in vibe.core.drivers.libevent2
tcp.onConnect() ()
#4 0x00043430 in vibe.core.core.CoreTask.run() ()
#5 0x001a37fc in fiber_entryPoint () at ../../../../gcc-4.8-20131010/libphobos/libdruntime/core/thread.d:3800
#6 0xb6cbe0b0 in setcontext () from /lib/arm-linux-gnueabihf/libc.so.6
#7 0xb6cbe0b0 in setcontext () from /lib/arm-linux-gnueabihf/libc.so.6
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

This looks pretty horrible - a problem with GDC maybe ?

This looks like the Fiber context switching is broken.
I had to write a fiber_switchContext to get vibe running on MIPS.
Looks somewhat cryptic but is actually fairly easy.
Simply store all callee (not caller) save-registers on the stack, swap
the stack pointer and pop the saved registers from the new context.

If no asm is available getcontext/setcontext is used as fallback. But
these functions are deprecated, very inefficient and easily break
because the size of ucontextt depends on kernel internal structures.
AFAIK they aren't available on all libc implementations either.
Maybe the ucontext
t declarations in core.sys.posix.ucontext are wrong
for ARM, check ucontextt.sizeof vs. sizeof(ucontextt) in a C program.

fiberswitchContext:
https://github.com/D-Programming-Language/druntime/blob/master/src/core/threadasm.S#L277
ucontext
t:
https://github.com/D-Programming-Language/druntime/blob/master/src/core/sys/posix/ucontext.d#L454