Discussion:
sane_init()/sane_exit() crashes on debian systems / not on e.g. arch linux
Add Reply
Wilhelm
2017-04-05 14:55:39 UTC
Reply
Permalink
Raw Message
Hi all,

the following small program regularly crashes on debian based system
when inserting / removing a device. This does not happen on e.g. arch
linux or gentoo systems.

Investigating the problem further reveals that on debian based systems
every iteration starts a new thread ending up with tons of threads:
thats obviously the problem here.

On ArchLinux the sane_exit() call termintates the thread started in
sane_init() abd therefore no crash happens here.

Any reasons or plans to fix that?

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <sane/sane.h>

int main () {
while (true) {
SANE_Int sane_version = 0;
if (sane_init(&sane_version, 0) != SANE_STATUS_GOOD) {
printf("Can't init sane\n");
exit(EXIT_FAILURE);
}
printf("sane version %d.%d\n", SANE_VERSION_MAJOR(sane_version),
SANE_VERSION_MINOR(sane_version));

const SANE_Device** device_list = NULL;
if (sane_get_devices(&device_list, SANE_TRUE) == SANE_STATUS_GOOD) {
const SANE_Device** dev = device_list;
while (*dev) {
printf("dev name: %s\n", (*dev)->name);
dev++;
}
} else {
printf("Can't get dev list\n");
exit(EXIT_FAILURE);
}
sleep (1);
printf("sane_exit\n");
sane_exit();
sleep (1);
}
exit(EXIT_SUCCESS);
}
--
sane-devel mailing list: sane-***@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
to sane-devel-***@lists.alioth.debian.org
Loading...