[202] in Pthreads mailing list archive
Checking pthread allocation in pthread_create.
daemon@ATHENA.MIT.EDU (Yann Langlais)
Mon Nov 13 16:42:28 1995
From: Yann Langlais <ylanglais@houston.geoquest.slb.com>
To: pthreads@MIT.EDU
Date: Mon, 13 Nov 1995 15:06:07 -0600 (CST)
Hi,
I installed pthreads-1_60_beta4_1 on SunOS 4.1.3, using gcc2.7.0.
After a stupid trial of passing non allocated pthread_t variable to
pthread_create, I had an infinite loop while running a veray simple
test. Using gdb, it appeard that a segmentation fault occured in
pthread_create() line 193 of the file ./pthreads/pthread.c while
trying to assign the new thread structure to the user one:
193 (*thread) = new_thread;
Wouldn't it be possible to test the assignment of the thread
variable at the very beginning of the pthread_create() function???
e.g.:
140 size_t size;
141
/*
* Testing that the user is not stupid:
*/
if (thread == (pthread_t *) 0) {
/*
* He is:
*/
return !OK;
}
142 if (new_thread = (pthread_t)malloc(sizeof(struct pthread))) {
143
Ok, this is not an issue, but it assumes that the user is intelligent
and will not make something stupid, which is far from being my case;-)
Well thanks for this package, it's great!!!
| Yann LANGLAIS | l.
langlais@houston.GeoQuest.slb.com lOO.
| o o | lOOl}
| __ | lOT]
| / \ | IOI
| \___| o /| | IOI
____|\_______/|____/ \___/ lO
\ lO
_ \ oOOO lI Oo
/ | .OOO' ob Oo oOO
| / .OOO' ollO. OD`OOOOOOOOOOOOOOOO'
\_______/o o OOOD "OOOP OO ol. ol.
OOOo. oO' `OP `OP
`"TOOOo. oOOP
`"TOOOo. ooO'
`"SOOOP"'