timer_delete does not cancel the thread to run the function
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
linux (Ubuntu) |
Expired
|
Undecided
|
Unassigned |
Bug Description
timer_create(), when told to run a function at time expiration, creates immediately an ancillary thread
(it could have created it when armed, or even better, when expired). When the timer is deleted, the
ancillary thread does not get cancelled. Not even if it was created as detached. That ancillary thread
must instead be terminated, otherwise it wastes resources (and prevents the process to terminate
normally).
Program that shows it:
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <signal.h>
#include <unistd.h>
#include <dirent.h>
#include <stddef.h>
// enumerate all threads of this process
static void listthreads(char* str){
printf("threads %s\n",str);
char buf[100];
sprintf(
DIR* dir = opendir(buf);
int len = offsetof(struct dirent,d_name) +
struct dirent* entryp;
entryp = malloc(len);
struct dirent* res;
for (;;){
if (res == NULL) break;
if (entryp->d_name[0] == '.') continue;
printf(" %s\n",entryp-
}
closedir(dir);
printf("end of list\n");
}
void timerfunction(
}
int main(int argc, char* argv[]){
printf("main %d\n",getpid());
struct sigevent event;
event.
event.
event.
event.
timer_t timer_id;
if (timer_
}
listthreads
struct itimerspec itime; // arm timer
itime.
itime.
itime.
itime.
if (timer_
}
listthreads
timer_
listthreads
}
$ gcc timerdelete.c -lrt
$ ./a.out
main 9958
threads after timer creation
9958
9959
end of list
threads after timer arming
9958
9959
end of list
threads after timer delete
9958
9959
end of list
ProblemType: Bug
Architecture: i386
AudioDevicesInUse:
USER PID ACCESS COMMAND
/dev/snd/
CRDA: Error: [Errno 2] No such file or directory
Card0.Amixer.info:
Card hw:0 'NVidia'/'HDA NVidia at 0xfe028000 irq 23'
Mixer name : 'Realtek ALC888'
Components : 'HDA:10ec0888,
Controls : 37
Simple ctrls : 21
Date: Sat Nov 28 10:24:21 2009
DistroRelease: Ubuntu 9.10
HibernationDevice: RESUME=
InstallationMedia: Ubuntu 9.10 "Karmic Koala" - Release i386 (20091028.5)
Lsusb:
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 046d:c315 Logitech, Inc. Classic New Touch Keyboard
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
MachineType: Packard Bell BV IMEDIA 8425
NonfreeKernelMo
Package: linux-image-
ProcCmdLine: BOOT_IMAGE=
ProcEnviron:
LANG=en_US.UTF-8
SHELL=/bin/bash
ProcVersionSign
RelatedPackageV
linux-
linux-firmware 1.25
RfKill:
0: phy0: Wireless LAN
Soft blocked: no
Hard blocked: no
SourcePackage: linux
Uname: Linux 2.6.31-15-generic i686
dmi.bios.date: 11/01/2006
dmi.bios.vendor: Phoenix Technologies, LTD
dmi.bios.version: M2N-NM 0401
dmi.board.name: M2N-NM
dmi.board.vendor: Packard Bell BV
dmi.board.version: 1.XX
dmi.chassis.
dmi.chassis.type: 3
dmi.chassis.vendor: Packard Bell BV
dmi.chassis.
dmi.modalias: dmi:bvnPhoenixT
dmi.product.name: IMEDIA 8425
dmi.product.
dmi.sys.vendor: Packard Bell BV
---
AlsaVersion: Advanced Linux Sound Architecture Driver Version 1.0.21.
Architecture: i386
AudioDevicesInUse:
USER PID ACCESS COMMAND
/dev/snd/
CRDA: Error: [Errno 2] No such file or directory
Card0.Amixer.info:
Card hw:0 'NVidia'/'HDA NVidia at 0xfe028000 irq 23'
Mixer name : 'Realtek ALC888'
Components : 'HDA:10ec0888,
Controls : 37
Simple ctrls : 21
DistroRelease: Ubuntu 10.04
HibernationDevice: RESUME=
InstallationMedia: Ubuntu 10.04 LTS "Lucid Lynx" - Release i386 (20100429)
Lsusb:
Bus 002 Device 002: ID 046d:c315 Logitech, Inc. Classic New Touch Keyboard
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
MachineType: Packard Bell BV IMEDIA 8425
NonfreeKernelMo
Package: linux (not installed)
ProcCmdLine: BOOT_IMAGE=
ProcEnviron:
LANG=en_US.utf8
SHELL=/bin/bash
ProcVersionSign
Regression: No
RelatedPackageV
Reproducible: Yes
RfKill:
0: phy0: Wireless LAN
Soft blocked: no
Hard blocked: no
Tags: lucid needs-upstream-
Uname: Linux 2.6.32-22-generic i686
UserGroups: adm admin cdrom dialout lpadmin plugdev sambashare
dmi.bios.date: 11/01/2006
dmi.bios.vendor: Phoenix Technologies, LTD
dmi.bios.version: M2N-NM 0401
dmi.board.name: M2N-NM
dmi.board.vendor: Packard Bell BV
dmi.board.version: 1.XX
dmi.chassis.
dmi.chassis.type: 3
dmi.chassis.vendor: Packard Bell BV
dmi.chassis.
dmi.modalias: dmi:bvnPhoenixT
dmi.product.name: IMEDIA 8425
dmi.product.
dmi.sys.vendor: Packard Bell BV
tags: | added: kernel-karmic |
Hi Angelo,
This bug was reported a while ago and there hasn't been any activity in it recently. We were wondering if this is still an issue? Can you try with the latest development release of Ubuntu? ISO CD images are available from http:// cdimage. ubuntu. com/releases/ .
If it remains an issue, could you run the following command from a Terminal (Applications- >Accessories- >Terminal) . It will automatically gather and attach updated debug information to this report.
apport-collect -p linux 489497
Also, if you could test the latest upstream kernel available that would be great. It will allow additional upstream developers to examine the issue. Refer to https:/ /wiki.ubuntu. com/KernelMainl ineBuilds . Once you've tested the upstream kernel, please remove the 'needs- upstream- testing' tag. This can be done by clicking on the yellow pencil icon next to the tag located at the bottom of the bug description and deleting the 'needs- upstream- testing' text. Please let us know your results.
Thanks in advance.
[This is an automated message. Apologies if it has reached you inappropriately; please just reply to this message indicating so.]