[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: threads question
- To: "Nadav Har'El" <nyh(at-nospam)math.technion.ac.il>
- Subject: Re: threads question
- From: Oleg Goldshmidt <ogoldshmidt(at-nospam)computer.org>
- Date: 26 Nov 2001 22:57:48 -0500
- Cc: linux-il(at-nospam)linux.org.il
- Delivered-To: linux.org.il-linux-il@linux.org.il
- In-Reply-To: <20011126191258.A2144@leeor.math.technion.ac.il>
- Organization: Speaking for myself only.
- Original-Sender: ogoldshmidt@computer.org
- References: <m3snb1nl00.fsf@localhost.localdomain><20011126191258.A2144@leeor.math.technion.ac.il>
- Reply-To: linux-il(at-nospam)linux.org.il
- Sender: ogoldshmidt(at-nospam)computer.org
- Sender: linux-il-bounce(at-nospam)cs.huji.ac.il
- User-Agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.1 (Cuyahoga Valley)
"Nadav Har'El" <nyh@math.technion.ac.il> writes:
> What is this last return statement?? Returning from main? That's not
> something you're supposed to do in a multithreaded program. It
> might, for example, free the entire malloc pool, including arg which
> is later freed in the second thread, causing a segmentation fault.
You are right that there should not be a return statement, but it is
not what is happening: free() is OK, according to the
debugger. Besides, return from main(), as well as any exit(), should
terminate the process (including any threads), freeing the memory by
independent means, not execute the rest of the code, buggy as it may
be.
> Try replacing "return EXIT_SUCCESS" by "pause()" (for example) and see
> if it now works.
Tried it, with pause() or without - did not help.
--
Oleg Goldshmidt | ogoldshmidt@NOSPAM.computer.org
If it aint't broken it hasn't got enough features yet.
=================================================================
To unsubscribe, send mail to linux-il-request@linux.org.il with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail linux-il-request@linux.org.il