Email List: Xaustin-group-lX
[All Lists]

Re: safe use of pthread_xxx_init functions

To: austin-group-l@xxxxxxxxxxxxx
Subject: Re: safe use of pthread_xxx_init functions
From: Larry Dwyer <Larry.Dwyer@xxxxxx>
Date: Thu, 15 Feb 2007 11:14:30 -0800
References: <45D3669E.2010903@xxxxxx><1171484522.27476.67.camel@amstaff2.msbit.com><45D385B0.9080406@xxxxxx><1171492211.27476.94.camel@amstaff2.msbit.com><45D39706.4090405@xxxxxx><1171496494.27476.99.camel@amstaff2.msbit.com><45D3AD15.50803@xxxxxx><200702150759.XAA02158@xxxxxx><1171563516.10413.20.camel@amstaff2.msbit.com><45D4AA83.9080302@xxxxxx>
At 10:46 AM 2/15/2007, Wojtek Lerch wrote:
Nick Stoughton wrote:
[...] Therefore, an implementation SHALL NOT attempt to detect double
initialization. To do so would make it non-conform.
Not necessarily. An implementation could keep the addresses of all the initialized objects in an array, and store the array index in the object. This would allow it to quickly and reliably detect whether a given object is initialized or not, by taking the index from it, checking if it's in range, and then comparing the object's address with the address stored in the array.
What if the object is allocated by the application on the stack? What if it exits the function and pops the stack, then enters another function and reuses this portion of the stack for another purpose? How can the implementation tell that, when the stack was popped, the object was intentionally abandoned? Just because the application is passing an object address that has the same value of a previously initialized object does not mean this is an initialized object.

Cheers,
Larry

<Prev in Thread] Current Thread [Next in Thread>