Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Mon, 10 Feb 2020 22:29:02 +0300
From: Alexander Scherbatiy <alexander.scherbatiy@...l-sw.com>
To: musl@...ts.openwall.com
Subject: No such process return value in pthread_getcpuclockid

Hello,

It seems that pthread_getcpuclockid does not properly handle non valid 
thread id argument.

Below is a sample which calls pthread_getcpuclockid with NULL thread id. 
The expected result is ESRCH (No thread with the ID thread could be 
found). It crashes in my docker with Alpine Linux 3.11.3 (musl libc 
x86_64 1.1.24). It returns ESRCH on my Ubuntu system.

---  pthread_getcpuclockid_sample.c ---

#include <time.h>
#include <stdio.h>
#include <pthread.h>
#include <errno.h>


int main()
{
     clockid_t cid;
     int s;

     s = pthread_getcpuclockid((pthread_t) NULL, &cid);

     if (s == ESRCH) {
         printf("result: ESRCH\n");
     } else {
         printf("result: %d\n", s);
     }

     return 0;
}
--------------------------------------

 > gcc -pthread -o pthread_getcpuclockid_sample 
pthread_getcpuclockid_sample.c

 > ./pthread_getcpuclockid_sample

Segmentation fault (core dumped)


Thanks,

Alexander.



Powered by blists - more mailing lists

Your e-mail address:

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.