---
+  // Check if an expected deallocation function matches the real one.
+  if (RsBase &&
+  RsBase->getAllocationFamily() != AF_None &&
+ RsBase->getAllocationFamily() != getAllocationFamily(C, ParentExpr) ) { Is it possible to have AF_None family here? Shouldn't " RsBase->getAllocationFamily() != AF_None" be inside an assert?
It is possible. In the example below initWithCharactersNoCopy:length:freeWhenDone takes ownership of memory allocated by unknown means, RefState with AF_None is bound to the call and after, when free() is processed, we have RsBase->getAllocationFamily() == AF_None.

My understanding is that this API assumes that the memory belongs to the malloc family. So, for example, we would warn on freeing with a regular "free" after freeing with "initWithCharactersNoCopy.. freeWhenDone".

If the family is unknown, we should not be tracking the memory at all.
Great idea, I'll include corresponding changes in the next patch devoted to unix.MismatchedDeallocator

I am sitting on the patch that disables tracking if unknown memory by checkPostObjCMessage(). The only thing preventing me from committing is the presence of the following testcase in malloc.mm:

void test12365078_nocheck_nomalloc(unichar *characters) {
NSString *string = [[NSString alloc] initWithCharactersNoCopy:characters length:12 freeWhenDone:1]; free(characters); // expected-warning {{Attempt to free non-owned memory}}
}

Should this warning be muted?

--
Anton

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to