Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 10 Jul 2002 11:57:33 -0400 (EDT)
From:      "Alexandra (Sasha) Fedorova" <fedorova@eecs.harvard.edu>
To:        Xavier.Leroy@inria.fr
Cc:        freebsd-doc@FreeBSD.ORG
Subject:   important linuxthreads documentation issue
Message-ID:  <Pine.GSO.4.10.10207101143250.25979-100000@wino.eecs.harvard.edu>

next in thread | raw e-mail | index | archive | help
Xavier, 

I just found an issue associated with using linuxthreads port on FreeBSD.
It's an important point about how the library should be used, which must
be documented somewhere (I spent a day trying to solve this problem, and
if someone documents it, it will save other users lots of time). So here
is the problem:

- In the standard pthread.h file that comes in /usr/src/include on
FreeBSD, pthread_mutex_t is defined as a pointer to struct pthread_mutex. 

- But, in the pthread.h file that comes with linuxthreads
(/usr/local/include/linuxthreads/pthread/pthread.h), pthread_mutex_t is a
struct itself! 

- So if you use the standard definition of pthread_mutex_t and then
call pthread_mutex_init(pthread_mutex_t *, ...) of the linuxthread
library, a disaster happens: since linuxthreads implementation expects a
pointer to an allocated structure, it does not malloc anything, but goes
and zeroes the fields of pthread_mutex_t. 

- You can see that if the standard definition of pthread_mutex_t is used.
The standard definition provides to pthread_mutex_init a struct
pthread_mutex**, a double pointer! So the user expects the library to
allocate memory itself, which linuxthread library does not. As a result a
disaster happens: the library writes into memory that belongs somewhere
else in the program.

------

The key point here is that if someone is using a linuxthreads library on
FreeBSD, they should use the right include file
(/usr/local/include/linuxthreads/pthread/pthread.h), and also use
-I/usr/local/include/linuxthreads/pthread option to gcc.

If you think that this e-mail should be more appropriately addressed to
someone else, please forward it to them.


-- Sasha


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-doc" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.10.10207101143250.25979-100000>