Hi all,
Apologies if this is the wrong list, and for the somewhat vague description of my problem.
I've been working on porting Go (via gccgo) to aarch64 and things have mostly been going well. However, under some circumstances, I'm seeing crashes. What's happening is that when a signal -- SIGCHLD in this case -- is being handled, instead of being executed on the stack passed to sigaltstack, the signal is being handled on some *other* thread's stack, which unsurprisingly ends badly when a signal context object is smashed over whatever the original thread had put there.
By setting breakpoints on the signal handler in gdb and printing $sp, I can actually see that signals are never being executed on the altstack, but it takes a random number of signals before one is executed somewhere that causes a crash. So I don't know if signals are always being handled on other thread's stacks or if it's just at random-ish locations in the heap. (Goroutines run with stacks allocated in the heap).
Writing a very simple program that calls sigaltstack does behave as expected, but the go runtime is doing all sorts of things with multiple threads and getcontext/makecontext/setcontext so I guess something is getting confused.
There are some more details on this bug: https://bugs.launchpad.net/ubuntu/+source/gcc-4.8/+bug/1279620 but I don't have anything like a minimal example unfortunately. I'll try to come up with one tomorrow, but in the mean time: does this ring any bells at all with anyone? I couldn't see any obvious reasons for this behaviour in the kernel code :/
Cheers, mwh