RE: uclibc(1.0.12) mq_send return value and errno issue

2016-11-24 Thread Frank Liu
Hi Waldemar,

Thanks for the patchset. I can confirm it fixed my issue.

Regards
Frank

-Original Message-
From: Waldemar Brodkorb [mailto:w...@uclibc-ng.org] 
Sent: Thursday, November 24, 2016 2:27 PM
To: Frank Liu
Cc: Waldemar Brodkorb; 'uclibc@uclibc.org'; Dushara Jayasinghe 
(dush...@successful.com.au); de...@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
-- 
 
Click here to report this message as spam:
https://console.mailguard.com.au/ras/1PICBK8R7h/5zv7PHEQq8uVVrlQrJoc9i/0

-- 
IMPORTANTPrivileged - Private & Confidential This email and files transmitted 
with it are intended solely for the use of the addressee (s) and may contain 
information which is confidential or privileged. If you are not the intended 
recipient, be aware that any disclosure, copying, distribution or use of this 
email or any attachment is prohibited. If you receive this email and you are 
not the addressee, or you have received this email in error, please disregard 
the contents of the email, delete the email and notify the author immediately. 
It is your responsibility to check any email attachments for email viruses 
before opening or sending them on. 

 

___
uClibc mailing list
uClibc@uclibc.org
http://lists.busybox.net/mailman/listinfo/uclibc


Re: uclibc(1.0.12) mq_send return value and errno issue

2016-11-23 Thread Waldemar Brodkorb
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
>From 650e6cbd0fccf8d20efc0844582934eae8da1f58 Mon Sep 17 00:00:00 2001
From: Waldemar Brodkorb 
Date: Thu, 24 Nov 2016 04:14:20 +0100
Subject: [PATCH 1/2] arm: use common ret_ERRVAL

Signed-off-by: Waldemar Brodkorb 
---
 libc/sysdeps/linux/arm/sysdep.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/libc/sysdeps/linux/arm/sysdep.h b/libc/sysdeps/linux/arm/sysdep.h
index 80bf9ec..8813f8e 100644
--- a/libc/sysdeps/linux/arm/sysdep.h
+++ b/libc/sysdeps/linux/arm/sysdep.h
@@ -137,9 +137,6 @@
 #define	PSEUDO_END_ERRVAL(name) \
   END (name)
 
-#undef ret_ERRVAL
-#define ret_ERRVAL PSEUDO_RET_NOERRNO
-
 #if defined NOT_IN_libc
 # define SYSCALL_ERROR __local_syscall_error
 #  define SYSCALL_ERROR_HANDLER	\
-- 
2.1.4

___
uClibc mailing list
uClibc@uclibc.org
http://lists.busybox.net/mailman/listinfo/uclibc

RE: uclibc(1.0.12) mq_send return value and errno issue

2016-11-17 Thread Frank Liu
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:w...@uclibc-ng.org] 
Sent: Friday, November 18, 2016 5:13 PM
To: Frank Liu
Cc: 'uclibc@uclibc.org'; de...@uclibc-ng.org; Dushara Jayasinghe 
(dush...@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
-- 
 
Click here to report this message as spam:
https://console.mailguard.com.au/ras/1PGczunkCB/3fSLfL9xJIP2MKuhQDEQvo/1.5

-- 
IMPORTANTPrivileged - Private & Confidential This email and files transmitted 
with it are intended solely for the use of the addressee (s) and may contain 
information which is confidential or privileged. If you are not the intended 
recipient, be aware that any disclosure, copying, distribution or use of this 
email or any attachment is prohibited. If you receive this email and you are 
not the addressee, or you have received this email in error, please disregard 
the contents of the email, delete the email and notify the author immediately. 
It is your responsibility to check any email attachments for email viruses 
before opening or sending them on. 

 

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#define READERS 10
#define WRITERS 10

static void *read_test(void *data)
{
char buf[100];
int fd, good = 0, bad = 0;

fd = open("/dev/null", O_WRONLY);

//printf("read test on process : %d thread : %d\n", getpid(), 
syscall(SYS_gettid));

while (1) {
if ((read(fd, buf, sizeof(buf)) != -1) || (errno != EBADF)) {
int err = errno;
fprintf(stderr, "%d: (%d/%d) got %d instead of %d\n",
pthread_self(), bad, bad+good, err, EBADF);
bad++;
} else {
good++;
}

}

return 0;
}

static void *write_test(void *data)
{
char buf[100];
int fd, good = 0, bad = 0;

fd = open("/dev/full", O_WRONLY);

//printf("write test on process : %d thread : %d\n", getpid(), 
syscall(SYS_gettid));

while (1) {
if ((write(fd, buf, sizeof(buf)) != -1) || (errno != ENOSPC)) {
int err = errno;
fprintf(stderr, "%d: (%d/%d) got %d instead of %d\n",
pthread_self(), bad, bad+good, err, ENOSPC);
bad++;
} else {
good++;

}
}

return 0;
}

static void *overflow_queue(void * data)
{
mqd_t handle_;

// Delete any stale queues (ignore any errors)
mq_unlink("/testqueue");

struct mq_attr attr = {0};
attr.mq_maxmsg = 4;
attr.mq_msgsize = 10;

handle_ = mq_open("/testqueue", O_RDONLY | O_CREAT, S_IRWXU | S_IRWXG, 
);

assert(handle_ != -1);

handle_ = mq_open("/testqueue", O_WRONLY | O_NONBLOCK);

assert(handle_ != -1);

while (1)
{

const char* data = "test";
int size = 4;

auto volatile errno_prev = errno;

auto ret = mq_send(handle_, data, size, 0);

if (ret < 0)
{
printf("ret: %d, errno: %d, pre: %d\n", ret, errno, errno_prev);

if (errno != EAGAIN)
{
printf("affending process : %d thread : %d\n", getpid(), 
syscall(SYS_gettid));
assert(errno == EAGAIN);
}

}

}
}

int main(void)
{
pthread_t id;
int i;

for (i=0; i<READERS; i++)
pthread_create(, 0, read_test, 0);

for (i=0; i<

Re: uclibc(1.0.12) mq_send return value and errno issue

2016-11-17 Thread Waldemar Brodkorb
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
___
uClibc mailing list
uClibc@uclibc.org
http://lists.busybox.net/mailman/listinfo/uclibc