Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signal handler tests fail on ARM #256

Closed
janisz opened this issue Oct 25, 2017 · 1 comment
Closed

Signal handler tests fail on ARM #256

janisz opened this issue Oct 25, 2017 · 1 comment

Comments

@janisz
Copy link

janisz commented Oct 25, 2017

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
@hlsyounes
Copy link
Contributor

I had the same issue with this unit test, and the proposed patch works for me. DieInThread() shows up in the stack trace.

@sergiud sergiud closed this as completed Mar 30, 2021
@sergiud sergiud mentioned this issue May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants