<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 01.04.2013 21:30, Anna Zaks wrote:<br>
</div>
<blockquote
cite="mid:AF271BEB-E82E-4C31-B7EB-29264A4CEECF@apple.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<br>
<div>
<div>On Mar 29, 2013, at 6:35 PM, Anton Yartsev <<a
moz-do-not-send="true" href="mailto:anton.yartsev@gmail.com">anton.yartsev@gmail.com</a>>
wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">
<div text="#000000" bgcolor="#FFFFFF" style="letter-spacing:
normal; orphans: auto; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal; widows: auto;
word-spacing: 0px; -webkit-text-stroke-width: 0px;">
<div class="moz-cite-prefix">On 30.03.2013 4:59, Jordan Rose
wrote:<br>
</div>
<blockquote
cite="mid:33478C08-4DC3-4FCB-A51C-8C45EBBC8560@apple.com"
type="cite"><br>
<div>
<div>On Mar 29, 2013, at 17:50 , Anton Yartsev <<a
moz-do-not-send="true"
href="mailto:anton.yartsev@gmail.com">anton.yartsev@gmail.com</a>>
wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite"><span style="font-family:
Menlo-Regular; font-size: 11px; font-style: normal;
font-variant: normal; font-weight: normal;
letter-spacing: normal; line-height: normal;
orphans: auto; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal; widows:
auto; word-spacing: 0px; -webkit-text-stroke-width:
0px; float: none; display: inline !important;">+//-----
Test free standard new</span><br style="font-family:
Menlo-Regular; font-size: 11px; font-style: normal;
font-variant: normal; font-weight: normal;
letter-spacing: normal; line-height: normal;
orphans: auto; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal; widows:
auto; word-spacing: 0px; -webkit-text-stroke-width:
0px;">
<span style="font-family: Menlo-Regular; font-size:
11px; font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal;
line-height: normal; orphans: auto; text-align:
start; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px; float: none;
display: inline !important;">+void testFreeOpNew() {</span><br
style="font-family: Menlo-Regular; font-size: 11px;
font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal;
line-height: normal; orphans: auto; text-align:
start; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px;">
<span style="font-family: Menlo-Regular; font-size:
11px; font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal;
line-height: normal; orphans: auto; text-align:
start; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px; float: none;
display: inline !important;">+ void *p = operator
new(0);</span><br style="font-family: Menlo-Regular;
font-size: 11px; font-style: normal; font-variant:
normal; font-weight: normal; letter-spacing: normal;
line-height: normal; orphans: auto; text-align:
start; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px;">
<span style="font-family: Menlo-Regular; font-size:
11px; font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal;
line-height: normal; orphans: auto; text-align:
start; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px; float: none;
display: inline !important;">+ free(p);</span><br
style="font-family: Menlo-Regular; font-size: 11px;
font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal;
line-height: normal; orphans: auto; text-align:
start; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px;">
<span style="font-family: Menlo-Regular; font-size:
11px; font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal;
line-height: normal; orphans: auto; text-align:
start; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px; float: none;
display: inline !important;">+} //
expected-warning{{Memory is never released;
potential leak}}</span><br style="font-family:
Menlo-Regular; font-size: 11px; font-style: normal;
font-variant: normal; font-weight: normal;
letter-spacing: normal; line-height: normal;
orphans: auto; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal; widows:
auto; word-spacing: 0px; -webkit-text-stroke-width:
0px;">
<span style="font-family: Menlo-Regular; font-size:
11px; font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal;
line-height: normal; orphans: auto; text-align:
start; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px; float: none;
display: inline !important;">+// FIXME: Pointer
should escape</span><br style="font-family:
Menlo-Regular; font-size: 11px; font-style: normal;
font-variant: normal; font-weight: normal;
letter-spacing: normal; line-height: normal;
orphans: auto; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal; widows:
auto; word-spacing: 0px; -webkit-text-stroke-width:
0px;">
<span style="font-family: Menlo-Regular; font-size:
11px; font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal;
line-height: normal; orphans: auto; text-align:
start; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px; float: none;
display: inline !important;">+</span><br
style="font-family: Menlo-Regular; font-size: 11px;
font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal;
line-height: normal; orphans: auto; text-align:
start; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px;">
<span style="font-family: Menlo-Regular; font-size:
11px; font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal;
line-height: normal; orphans: auto; text-align:
start; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px; float: none;
display: inline !important;">+void testFreeNewExpr()
{</span><br style="font-family: Menlo-Regular;
font-size: 11px; font-style: normal; font-variant:
normal; font-weight: normal; letter-spacing: normal;
line-height: normal; orphans: auto; text-align:
start; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px;">
<span style="font-family: Menlo-Regular; font-size:
11px; font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal;
line-height: normal; orphans: auto; text-align:
start; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px; float: none;
display: inline !important;">+ int *p = new int;</span><br
style="font-family: Menlo-Regular; font-size: 11px;
font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal;
line-height: normal; orphans: auto; text-align:
start; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px;">
<span style="font-family: Menlo-Regular; font-size:
11px; font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal;
line-height: normal; orphans: auto; text-align:
start; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px; float: none;
display: inline !important;">+ free(p);</span><br
style="font-family: Menlo-Regular; font-size: 11px;
font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal;
line-height: normal; orphans: auto; text-align:
start; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px;">
<span style="font-family: Menlo-Regular; font-size:
11px; font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal;
line-height: normal; orphans: auto; text-align:
start; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px; float: none;
display: inline !important;">+} //
expected-warning{{Memory is never released;
potential leak}}</span><br style="font-family:
Menlo-Regular; font-size: 11px; font-style: normal;
font-variant: normal; font-weight: normal;
letter-spacing: normal; line-height: normal;
orphans: auto; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal; widows:
auto; word-spacing: 0px; -webkit-text-stroke-width:
0px;">
<span style="font-family: Menlo-Regular; font-size:
11px; font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal;
line-height: normal; orphans: auto; text-align:
start; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px; float: none;
display: inline !important;">+// FIXME: Pointer
should escape</span><br style="font-family:
Menlo-Regular; font-size: 11px; font-style: normal;
font-variant: normal; font-weight: normal;
letter-spacing: normal; line-height: normal;
orphans: auto; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal; widows:
auto; word-spacing: 0px; -webkit-text-stroke-width:
0px;">
<span style="font-family: Menlo-Regular; font-size:
11px; font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal;
line-height: normal; orphans: auto; text-align:
start; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px; float: none;
display: inline !important;">+</span><br
style="font-family: Menlo-Regular; font-size: 11px;
font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal;
line-height: normal; orphans: auto; text-align:
start; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px;">
<span style="font-family: Menlo-Regular; font-size:
11px; font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal;
line-height: normal; orphans: auto; text-align:
start; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px; float: none;
display: inline !important;">+void
testObjcFreeNewed() {</span><br style="font-family:
Menlo-Regular; font-size: 11px; font-style: normal;
font-variant: normal; font-weight: normal;
letter-spacing: normal; line-height: normal;
orphans: auto; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal; widows:
auto; word-spacing: 0px; -webkit-text-stroke-width:
0px;">
<span style="font-family: Menlo-Regular; font-size:
11px; font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal;
line-height: normal; orphans: auto; text-align:
start; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px; float: none;
display: inline !important;">+ int *p = new int;</span><br
style="font-family: Menlo-Regular; font-size: 11px;
font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal;
line-height: normal; orphans: auto; text-align:
start; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px;">
<span style="font-family: Menlo-Regular; font-size:
11px; font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal;
line-height: normal; orphans: auto; text-align:
start; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px; float: none;
display: inline !important;">+ NSData *nsdata =
[NSData dataWithBytesNoCopy:p length:sizeof(int)
freeWhenDone:1]; // expected-warning{{Memory is
never released; potential leak}}</span><br
style="font-family: Menlo-Regular; font-size: 11px;
font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal;
line-height: normal; orphans: auto; text-align:
start; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px;">
<span style="font-family: Menlo-Regular; font-size:
11px; font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal;
line-height: normal; orphans: auto; text-align:
start; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px; float: none;
display: inline !important;">+}</span><br
style="font-family: Menlo-Regular; font-size: 11px;
font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal;
line-height: normal; orphans: auto; text-align:
start; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px;">
<span style="font-family: Menlo-Regular; font-size:
11px; font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal;
line-height: normal; orphans: auto; text-align:
start; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px; float: none;
display: inline !important;">+// FIXME: Pointer
should escape</span><br style="font-family:
Menlo-Regular; font-size: 11px; font-style: normal;
font-variant: normal; font-weight: normal;
letter-spacing: normal; line-height: normal;
orphans: auto; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal; widows:
auto; word-spacing: 0px; -webkit-text-stroke-width:
0px;">
</blockquote>
</div>
<br>
<div>These don't escape because we assume arbitrary system
functions don't free memory. I think these are fine when
unix.Malloc is disabled.</div>
</blockquote>
Now, when allocation families got in, I would like to
propose to split doesNotFreeMemOrInteresting() into two:
doesNotFreeMem() and isInteresting() or something similar.<br>
<br>
doesNotFreeMem() should return "true" for a given call if it
is known not to free memory, and "false" otherwise.<br>
<br>
For a known deallocation function isInteresting() should
return "true", if a deallocation function is of the same
family, as allocation one, and "false" otherwise. It also
may contain any additional logic for non-deallocation
functions if required.<br>
<br>
With this logic the cases will be considered as pointer
escape that is symmetrical to the reverse case, when
malloced memory is deleted (assume NewDelete id ON and
UnixMalloc is OFF):<br>
void testDeleteMalloced() {<br>
int *p = (int *)malloc(sizeof(int)); // do not add
RefState to p<br>
delete p; // keep silent<br>
}<span class="Apple-converted-space"> </span><br>
<br>
One more argument: that cases should be the subject of
unix.MismatchedDeallocator - the memory<span
class="Apple-converted-space"> </span><i>is</i><span
class="Apple-converted-space"> </span>deallocated, but the
deallocator do not match the allocator.<br>
<br>
What do you think?<br>
<br>
</div>
</blockquote>
<div><br>
</div>
<div>Anton,</div>
<div><br>
</div>
<div>I think that the current behavior is fine. First, if a
malloced pointer is freed with a delete (or wise versa), it is
an error. When the MismatchedDeallocator checker is turned
off, we do not do a good job diagnosing the issue, but it is
still better to warn than not, in my opinion. Second, my hope
is that after the initial evaluation, all these checkers will
be turned on by default, so it it fine if the diagnostic is
suboptimal.</div>
<div><br>
</div>
<div>I don't mind refactoring the doesNotFreeMemOrInteresting so
that it better reflects families; the name might be outdated
now. However, I don't think we should change the current
behavior not to report a leak on mismatched deallocator.</div>
<div><br>
</div>
<div>Does this sound convincing?</div>
</div>
</blockquote>
Yes, I agree. Just maybe refactor doesNotFreeMemOrInteresting.<br>
<br>
<blockquote
cite="mid:AF271BEB-E82E-4C31-B7EB-29264A4CEECF@apple.com"
type="cite">
<div>
<div><br>
</div>
<div>Anna.</div>
<br>
<blockquote type="cite">
<div text="#000000" bgcolor="#FFFFFF" style="letter-spacing:
normal; orphans: auto; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal; widows: auto;
word-spacing: 0px; -webkit-text-stroke-width: 0px;">
<pre class="moz-signature" cols="72">--
Anton</pre>
</div>
</blockquote>
</div>
<br>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
Anton</pre>
</body>
</html>