paulfloyd / freebsd_valgrind

Git repo used to Upstream the FreeBSD Port of Valgrind
GNU General Public License v2.0
15 stars 4 forks source link

none/tests/faultstatus is failing #86

Closed paulfloyd closed 4 years ago

paulfloyd commented 4 years ago

There's an issue with the testcase not working correctly standalone. Test 3 is supposed to generate a SIGBUS but instead it is generating a SIGSEGV. Under Valgrind it isn't getting that far, and terminates after Test 1.

Test 1: --5273-- sync signal handler: signal=11, si_code=1, EIP=0x2016d9, eip=0x4026fef1e, from kernel
--5273-- SIGSEGV: si_code=1 faultaddr=0x1234 tid=1 ESP=0x7fc000410 seg=0x0-0x1fffff
--5273-- delivering signal 11 (SIGSEGV):1 to thread 1
--5273-- push_signal_frame (thread 1): signal 11
==5273==    at 0x2016D9: test1 (faultstatus.c:116)
==5273==    by 0x201572: main (faultstatus.c:179)
--5273-- sys_sigaction: sigNo 11, new 0x40268de48, old 0x0, new flags 0x0
--5273-- delivering signal 11 (SIGSEGV):128 to thread 1
--5273-- delivering 11 (code 128) to default handler; action: terminate+core
==5273== 
==5273== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==5273==  General Protection Fault

I did have some false hopes based on the sigaction manpage that there was an issue related to struct sigaction. But it seems as though the manpage is wrong and in fact the two function pointers are in a union.

paulfloyd commented 4 years ago

This reduced example is quite interesting (not that I'm 100% certain that this is the same problem).

#include <signal.h>
#include <stdio.h>
#include <stdlib.h>

void on_sigusr1(int sig)
{
  printf("SIGUSR1 received!\n");
}

int main(void)
{
  signal(SIGUSR1, &on_sigusr1);
  raise(SIGUSR1);
}

It seems to work OK with GCC but with clang it crashed but only if debug (-g) was specified.

paulfloyd commented 4 years ago

The fix for issue #117 also resolves the SIGSEGV here.

Now only have the issue of test3 generating SIGSEGV rather than SIGBUS.

paulfloyd commented 4 years ago

Fixed with commit commit 8002159ac1d600e5521392f08e30b57d7897e533