PelionIoT / mbed-trace

mbed trace library
Apache License 2.0
18 stars 15 forks source link

Possible deadlock using mutexes in mbed-trace. #74

Closed korjaa closed 7 years ago

korjaa commented 7 years ago

With intensive printing I think I'm having issue with some sort of deadlock by mbed-trace.

Test to reproduce: https://github.com/ARMmbed/mbed-trace/pull/73

ciarmcom commented 7 years ago

ARM Internal Ref: IOTSYST-2476

korjaa commented 7 years ago

I was just told I'm not using recursive mutexes when I should have :)

What I should have done:

pthread_mutexattr_t stdout_mutex_attr;
pthread_mutexattr_init(&stdout_mutex_attr);
pthread_mutexattr_settype(&stdout_mutex_attr, PTHREAD_MUTEX_RECURSIVE);
pthread_mutex_init(&stdout_mutex, &stdout_mutex_attr);

What I did:

pthread_mutex_init(&stdout_mutex, NULL);

I think this recursive mutex requirement should be added to the README.md.

korjaa commented 7 years ago

So it's highly likely this issue isn't real, I was just using it wrongly.

korjaa commented 7 years ago

Changed from bug to enhancement, because just stating recursive mutex requirement on README.md would be enough I think.

tommikas commented 7 years ago

The mbed_trace.h header mentions this here: https://github.com/ARMmbed/mbed-trace/blob/master/mbed-trace/mbed_trace.h#L254-L255

But yeah, I agree it should be mentioned in the readme too.

tommikas commented 7 years ago

Documentation updated in #77.