PtokaX forum

PtokaX => Bugs => Topic started by: dmvn on 07 December, 2013, 22:23:24

Title: Unsafe code in signal handler (linux version)
Post by: dmvn on 07 December, 2013, 22:23:24
I'm now trying to make my hub working on new PtokaX 0.500, and I noticed some potential problems in source code (at least in UNIX part).

It's a known fact that signal handlers are restricted by set of calls that are safe inside them (referring to http://man7.org/linux/man-pages/man7/signal.7.html ).
In particular, malloc and pthread_mutex_lock are cannot be done in signal handlers.

But in current code there are two problems:
1) std::string is used in first line of SigHandler function (which implies use of malloc() ),
2) adding SHUTDOWN event to queue is of course wrapped by mutex, and this is unsafe too.

This may lead to deadlocks, coredumps on terminating process, etc.

I've noticed this because of another problem, which is under my investigation now: PtokaX freezes after running again on converted users base, but I had not found why.
Title: Re: Unsafe code in signal handler (linux version)
Post by: PPK on 07 December, 2013, 23:05:25
Thank you for report, it will be fixed in next release  ;)