From: Konstantin S. <kon...@gm...> - 2009-06-02 08:05:30
|
On Tue, Jun 2, 2009 at 11:54 AM, Bart Van Assche <bar...@gm...> wrote: > On Tue, Jun 2, 2009 at 9:36 AM, Konstantin Serebryany > <kon...@gm...> wrote: >> On Mon, Jun 1, 2009 at 8:19 PM, Bart Van Assche >>> One additional remark regarding the ANNOTATE_HAPPENS_* macro's: a data >>> race detection tool has to allocate some memory to keep track of the >>> inter-thread ordering imposed by these annotations. >> >> True. >> >>> Since >>> ANNOTATE_HAPPENS_AFTER may be invoked multiple times with the same >>> argument, a tool cannot know when it can free the memory allocated to >>> implement such an annotation. I have added the >>> ANNOTATE_HAPPENS_AFTER_DONE() annotation in drd.h for this purpose. >> >> I would avoid doing this. >> Once the program frees the memory which was used as an argument to >> ANNOTATE_HAPPENS_*, the detector may release the resources. >> (ThreadSanitizer doesn't do this now. I haven't seen this as a >> problem, but maybe it is...) > > I agree that the tool should free the allocated resources at the time > the client object is freed. But what should a tool do when the > argument passed to ANNOTATE_HAPPENS_* is not a valid client address, > such as in unit tests 30 and 31 ? Hm. Maybe just leak the resources? I hate to have annotations that do not represent any synchronization and are need just for bookkeeping. In ThreadSanitizer I have to cleanup the whole state from time to time (usually, once per 10-20 minutes). This is done because of other reasons, but the leaked objects are freed as well. --kcc > > Bart. > |