[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: linuxthreads/malloc problem
From: |
Wolfram Gloger |
Subject: |
Re: linuxthreads/malloc problem |
Date: |
Thu, 2 Nov 2000 10:11:03 +0100 ("MET) |
> I have problems with malloc/free when I use it in my pthread programs. I
> keep getting segfaults when I start 2 instances of the program.
Huh? That would indicate either a kernel or a hardware problem.
> The program starts a bunch of threads. The threads malloc a buffer and
> signal another thread which frees the buffer. After the buffer is freed,
> the whole circle starts again.
Two points that you're probably already aware of, but just in case:
- You must never call malloc() or free() in a signal handler.
_Never_!
- You can't pass buffer addresses between separate processes and
then free them in a process other than the one that allocated them.
(Note `process(es)', not `thread(s)'!)
> I wrote a little test program that demonstrates the problems on my
> machine. When I remove the malloc/free's, everything runs fine. I can
> send it to you when you think it helps.
Yes, if you're aware of the above restrictions, please send it
(possibly in private if it is large).
Regards,
Wolfram.