Hello,

I was getting a segfault for sane-backends when using device sane-test.
This happened when I compiled sane with uclibc or musl (on openwrt).

I debugged the problem and traced it to sanei_thread_waitpid (at
sanei/sanei_thread.c). It seems that calling pthread_detach after someone
already did a pthread_join causes a segfault.

I'm no pthread expert but I guess that after a pthread_join, the thread
becomes "detached" and "terminated".

And, according to man page PTHREAD_DETACH(3):

"Attempting to detach an already detached thread results in unspecified
behavior."

I simply removed these detach lines in order to solve my problem. What
would be the correct fix? Is there any case when join fails and detach is
still valid? I checked error codes and only EDEADLK(when the thread is
already waiting for the caller) and EINVAL (when three is another thread is
already waiting for it) are possible situations when detach might do
something. Are they possible in sane thread usage? If so, I guess detach
might only be called when one of the possible fails of join happens.

Regards,

Luiz Angelo Daros de Luca
-- 
sane-devel mailing list: [email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
             to [email protected]

Reply via email to