Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.
This repository was archived by the owner on Jun 30, 2025. It is now read-only.

Signal handler tests fail on ARM #256

@janisz

Description

@janisz

When running make check on ARM. Signal handler test fails. The signal:

'SIGFPE' should appear in the output

The problem is that SIGFPE is not generated on ARM

here is no portable way to enable SIGFPE.

I've tried to replace division by 0 with explicit raise(SIGFPE) but with no succes. For some reson the stacktrace misses the function name.

diff --git a/src/signalhandler_unittest.cc b/src/signalhandler_unittest.cc
index e85f523..10b0071 100644
--- a/src/signalhandler_unittest.cc
+++ b/src/signalhandler_unittest.cc
@@ -57,10 +57,8 @@ void* DieInThread(void*) {
   // returns a pointer.  Hence we use C-style cast here, rather than
   // reinterpret/static_cast, to support both types of environments.
   fprintf(stderr, "0x%lx is dying\n", (long)pthread_self());
-  // Use volatile to prevent from these to be optimized away.
-  volatile int a = 0;
-  volatile int b = 1 / a;
-  fprintf(stderr, "We should have died: b=%d\n", b);
+  raise(SIGFPE);
+  fprintf(stderr, "We should have died!\n");
   return NULL;
 }

Got:

0xffff95e6a1e0 is dying
*** Aborted at 1508925684 (unix time) try "date -d @1508925684" if you are using GNU date ***
PC: @                0x0 (unknown)
*** SIGFPE (@0x3e900007194) received by PID 29076 (TID 0xffff95e6a1e0) from PID 29076; stack trace: ***
    @     0xffff962b66c0 ([vdso]+0x6bf)
    @     0xffff96223d60 raise
Floating point exception

Expected:

0x7f651f18c700 is dying
*** Aborted at 1508925857 (unix time) try "date -d @1508925857" if you are using GNU date ***
PC: @     0x7f652000d269 raise
*** SIGFPE (@0x3289cb000001527) received by PID 5415 (TID 0x7f651f18c700) from PID 5415; stack trace: ***
    @     0x7f652000d390 (unknown)
    @     0x7f652000d269 raise
    @           0x40146e DieInThread()
    @     0x7f65200036ba start_thread
    @     0x7f651f7a13dd clone
[1]    5415 floating point exception  ./signalhandler_unittest die_in_thread

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions