This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug time/19821] Timer crash when repeat create-start-delete several times
- From: "anton.gritsevich at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Mon, 14 Mar 2016 16:29:11 +0000
- Subject: [Bug time/19821] Timer crash when repeat create-start-delete several times
- Auto-submitted: auto-generated
- References: <bug-19821-131 at http dot sourceware dot org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=19821
--- Comment #2 from Anton Hrytsevich <anton.gritsevich at gmail dot com> ---
Nevermind, take version without mutex it's faol too.
#include <pthread.h>
#include <sys/signal.h>
#include <stdio.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <sys/resource.h>
void timer_thread (sigval signal_value) {
printf ("Timer callback!\n");
}
int main(int argc, char* argv[]) {
const int TIMER_COUNT = 300;
for (int i = 0; i < 10000; i++) {
printf("\n~~~~~~~ Iteration #%06d ~~~~~~~~~~~~~\n", i+1);
int status = 0;
timer_t timer_id[TIMER_COUNT] = {};
memset(&timer_id[0], 0, sizeof(timer_t)*TIMER_COUNT);
printf ("Start creating timers! \n");
for (int j = 0; j < TIMER_COUNT; j++) {
printf(" ___Subiteration #%02d___\n", j+1);
struct itimerspec ts = {};
struct sigevent se = {};
memset(&ts, 0, sizeof(itimerspec));
memset(&se, 0, sizeof(sigevent));
se.sigev_notify = SIGEV_THREAD;
se.sigev_value.sival_int = j;
se.sigev_notify_function = timer_thread;
// Specify a repeating timer that fires each 100000 nanosec.
memset(&ts, 0, sizeof(ts));
ts.it_value.tv_nsec = 100000;
ts.it_interval.tv_nsec = 100000;
//printf ("Creating timer\n");
status = timer_create(CLOCK_REALTIME, &se, &timer_id[j]);
assert(!status && "Create timer");
//printf ("Setting timer %#08x...\n", *(unsigned int*)&timer_id[j]);
status = timer_settime(timer_id[j], 0, &ts, 0);
assert(!status && "Set timer");
}
printf ("All timers has already started! \n");
printf ("Start timers deleted! \n");
for (int j = 0; j < TIMER_COUNT; j++) {
usleep(100);
//stop and delete
printf ("Delete timer %#08x...\n", *(int*)&timer_id[j]);
status = timer_delete(timer_id[j]);
assert(!status && "Fail delete timer");
}
printf ("All timers deleted! \n");
}
printf("Success!\n");
return 0;
}
--
You are receiving this mail because:
You are on the CC list for the bug.