Hi, Frank Liu wrote,
Hi All,
Kernel version : 4.4.19-linux4sam_5.4 uclibc version : 1.0.12 uclibc threading support : NPTL Processor Arch: ARM
Better you switch to uClibc-ng mailinglist for this question.
We create a NONBLOCKING message queue.
The expected behavior is when the message queue is full, calling mq_send would return -1 and set errno to EAGAIN(11). However we are seeing some inconsistent behaviors of mq_send.
When calling mq_send in a single threaded environment, the expected behavior is observed.
If the program starts a second thread, which is doing completely different task, calling mq_send when the queue is full would return -11 instead of -1. Also, the errno is set to an incorrect value. Values we have seen are 0, 2, which are completely different from the expected EAGAIN(11).
Can you provide a simple test case to check the behaviour?
best regards Waldemar
Please see the attached sample code.
If I turn READERS and WRITERS to 0, the test works fine.
Adding another thread in the process by setting a non-zero number to either READERS or WRITER, the test program crashes due to the assertion at line 99.
Regards
-----Original Message----- From: Waldemar Brodkorb [mailto:wbx@uclibc-ng.org] Sent: Friday, November 18, 2016 5:13 PM To: Frank Liu Cc: 'uclibc@uclibc.org'; devel@uclibc-ng.org; Dushara Jayasinghe (dushara@successful.com.au) Subject: Re: uclibc(1.0.12) mq_send return value and errno issue
Hi, Frank Liu wrote,
Hi All,
Kernel version : 4.4.19-linux4sam_5.4 uclibc version : 1.0.12 uclibc threading support : NPTL Processor Arch: ARM
Better you switch to uClibc-ng mailinglist for this question.
We create a NONBLOCKING message queue.
The expected behavior is when the message queue is full, calling mq_send would return -1 and set errno to EAGAIN(11). However we are seeing some inconsistent behaviors of mq_send.
When calling mq_send in a single threaded environment, the expected behavior is observed.
If the program starts a second thread, which is doing completely different task, calling mq_send when the queue is full would return -11 instead of -1. Also, the errno is set to an incorrect value. Values we have seen are 0, 2, which are completely different from the expected EAGAIN(11).
Can you provide a simple test case to check the behaviour?
best regards Waldemar
Hi Frank, Frank Liu wrote,
Please see the attached sample code.
If I turn READERS and WRITERS to 0, the test works fine.
Adding another thread in the process by setting a non-zero number to either READERS or WRITER, the test program crashes due to the assertion at line 99.
I think I found the reason for the problem.
Try attached patch,
best regards Waldemar
Hi Waldemar,
Thanks for the patchset. I can confirm it fixed my issue.
Regards Frank
-----Original Message----- From: Waldemar Brodkorb [mailto:wbx@uclibc-ng.org] Sent: Thursday, November 24, 2016 2:27 PM To: Frank Liu Cc: Waldemar Brodkorb; 'uclibc@uclibc.org'; Dushara Jayasinghe (dushara@successful.com.au); devel@uclibc-ng.org Subject: Re: uclibc(1.0.12) mq_send return value and errno issue
Hi Frank, Frank Liu wrote,
Please see the attached sample code.
If I turn READERS and WRITERS to 0, the test works fine.
Adding another thread in the process by setting a non-zero number to either READERS or WRITER, the test program crashes due to the assertion at line 99.
I think I found the reason for the problem.
Try attached patch,
best regards Waldemar