DynamoRIO / DynamoRIO/dynamorio

signals get lost in rare cases

Open
#1,759 1 comment 0 reactions 0 assignees View on GitHub
Bug-AppFail OpSys-Linux
Dominant language
C
Stars
3.2k
Forks
629
Avg merge
2d 15h
Merged PRs (30d)
31

Description

When executing the following test program with dynamorio (drrun), signals might get lost.

The test is rather simple: It starts a thread and sends 2 signals to that thread. On receiving a signal, the thread waits 1s. So the 2nd signal should be processed after 1s.

This works fine most of the time and 2 signals are processed, but in rare cases (1,4% for me) only one signal is received.

Note: Could it be relevant that I am using Suse (SLES 11) with an older kernel, libc, ...?

Note: When using a invalid value for vm_size (e.g. 513M), no error is shown but this test doesn't work anymore. I am not sure if this is a related issue.

Coding:

```
#include
#include
#include
#include

using std::cout;
using std::endl;

void* sayGoodMorningAfterFiveSeconds(void*)
{
usleep(5000000);
cout << "good morning from thread" << endl;
return NULL;
}

static const int signalNumber = 37;

void registerSignalHandler(void (*handler)(int, siginfo_t*, void*))
{
struct sigaction action;
action.sa_handler = NULL;
action.sa_sigaction = handler;
sigemptyset(&action.sa_mask);
action.sa_flags = SA_SIGINFO;
sigaction(signalNumber, &action, NULL);
}

unsigned int signalCount = 0;

void handleSignal(int signalNumber, siginfo_t* signalInfo, void* context)
{
cout << "signal " << signalNumber << " received" << endl;
usleep(1000000);
cout << "leaving signal handler after one second" << endl;
++signalCount;
}

int main()
{
registerSignalHandler(handleSignal);

pthread_t thread;

cout << "before thread creation" << endl;

pthread_create(&thread, NULL, sayGoodMorningAfterFiveSeconds, NULL);

//send signal twice to thread, both should be processed
pthread_kill(thread, signalNumber);
pthread_kill(thread, signalNumber);

pthread_join(thread, NULL);

return signalCount != 2;
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.