[prev in list] [next in list] [prev in thread] [next in thread]
List: kwin
Subject: Re: Review Request: 1 leak,
From: Luboš Luňák <l.lunak () kde ! org>
Date: 2011-09-29 14:09:44
Message-ID: 20110929140944.30558.63650 () vidsolbach ! de
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
> On July 25, 2011, 8:48 p.m., Martin Gräßlin wrote:
> > kwin/kcmkwin/kwinrules/ruleswidget.cpp, lines 448-449
> > <http://git.reviewboard.kde.org/r/102057/diff/2/?file=29518#file29518line448>
> >
> > I don't think this check makes much sense here. Yes if rules is still a pointer \
> > to tmp, it will point to invalid memory as soon as the method returns.
> > On the other hand if we set rules to NULL it will crash as soon as the calling \
> > function tries to use rules without checking (which I doubt it does).
> > The code has worked for years so I think that rules is never null when entering \
> > the method (the assingement is clearly wrong). So a proper fix in my opinion is \
> > to add an assert as first line of the method to check whether rules is NULL.
>
> Jaime Torres Amate wrote:
> I'll change it to an assert, you are sure that path will never happen as it has not \
> happened until today.
This is bogus. Of course rules can be NULL, in which case a new empty rule was used \
(as the comment said), and now it crashes, as soon as somebody tries to create a new \
rule from scratch. Reverting.
- Luboš
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/102057/#review5107
-----------------------------------------------------------
On Aug. 1, 2011, 5:59 p.m., Jaime Torres Amate wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://git.reviewboard.kde.org/r/102057/
> -----------------------------------------------------------
>
> (Updated Aug. 1, 2011, 5:59 p.m.)
>
>
> Review request for kwin.
>
>
> Description
> -------
>
> Some minor performance .. prefix ++ for non atomic types.
> Remove the leak for library.
> Reduce the scope for two variables.
> Avoid the modification of a parameter pointer pointing to the local stack when it \
> was NULL. Avoid the use of deco before it is sure is not NULL.
>
>
> Diffs
> -----
>
> kwin/clientgroup.cpp f8604b6
> kwin/clients/oxygen/oxygenexceptionlist.cpp 652dda0
> kwin/effects.cpp 143b033
> kwin/effects/blur/blurshader.cpp e7e5bf3
> kwin/effects/coverswitch/coverswitch.cpp 6bc98b3
> kwin/effects/presentwindows/presentwindows.cpp a0e8306
> kwin/effects/slidingpopups/slidingpopups.cpp 34bdac4
> kwin/kcmkwin/kwinrules/ruleswidget.cpp c3a44df
> kwin/libkwineffects/kwineffects.cpp e0c5538
> kwin/tools/decobenchmark/preview.cpp 36cfcd1
> kwin/useractions.cpp 387e499
> kwin/workspace.cpp b955668
>
> Diff: http://git.reviewboard.kde.org/r/102057/diff/diff
>
>
> Testing
> -------
>
> Working with the patch applied.
>
>
> Thanks,
>
> Jaime Torres Amate
>
>
[Attachment #5 (text/html)]
<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 \
solid;"> <tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="http://git.reviewboard.kde.org/r/102057/">http://git.reviewboard.kde.org/r/102057/</a>
</td>
</tr>
</table>
<br />
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;"> <p style="margin-top: 0;">On July 25th, 2011, 8:48 p.m., <b>Martin \
Gräßlin</b> wrote:</p> <blockquote style="margin-left: 1em; border-left: 2px solid \
#d0d0d0; padding-left: 10px;">
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; \
border-collapse: collapse; margin: 2px padding: 2px;"> <thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; \
font-size: 9pt; padding: 4px 8px; text-align: left;"> <a \
href="http://git.reviewboard.kde.org/r/102057/diff/2/?file=29518#file29518line448" \
style="color: black; font-weight: bold; text-decoration: \
underline;">kwin/kcmkwin/kwinrules/ruleswidget.cpp</a> <span style="font-weight: \
normal;">
(Diff revision 2)
</span>
</th>
</tr>
</thead>
<tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
<tr>
<td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">void \
RulesWidget::setRules(Rules* rules)</pre></td>
</tr>
</tbody>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">448</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span \
class="k">if</span> <span class="p">(</span><span class="n">rules</span> <span \
class="o">==</span> <span class="o">&</span><span class="n">tmp</span><span \
class="p">)</span></pre></td> </tr>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">449</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span \
class="n">rules</span> <span class="o">=</span> <span class="nb">NULL</span><span \
class="p">;</span></pre></td> </tr>
</tbody>
</table>
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I don't think this \
check makes much sense here. Yes if rules is still a pointer to tmp, it will point to \
invalid memory as soon as the method returns.
On the other hand if we set rules to NULL it will crash as soon as the calling \
function tries to use rules without checking (which I doubt it does).
The code has worked for years so I think that rules is never null when entering the \
method (the assingement is clearly wrong). So a proper fix in my opinion is to add an \
assert as first line of the method to check whether rules is NULL.</pre> \
</blockquote>
<p>On July 26th, 2011, 6:55 a.m., <b>Jaime Torres Amate</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;"> <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I'll change it to an \
assert, you are sure that path will never happen as it has not happened until \
today.</pre> </blockquote>
</blockquote>
<pre style="margin-left: 1em; white-space: pre-wrap; white-space: -moz-pre-wrap; \
white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">This is \
bogus. Of course rules can be NULL, in which case a new empty rule was used (as the \
comment said), and now it crashes, as soon as somebody tries to create a new rule \
from scratch. Reverting. </pre>
<br />
<p>- Luboš</p>
<br />
<p>On August 1st, 2011, 5:59 p.m., Jaime Torres Amate wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" \
style="background-image: \
url('http://git.reviewboard.kde.org/media/rb/images/review_request_box_top_bg.png'); \
background-position: left top; background-repeat: repeat-x; border: 1px black \
solid;"> <tr>
<td>
<div>Review request for kwin.</div>
<div>By Jaime Torres Amate.</div>
<p style="color: grey;"><i>Updated Aug. 1, 2011, 5:59 p.m.</i></p>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" \
style="border: 1px solid #b8b5a0"> <tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">Some minor performance .. prefix ++ for non atomic types. Remove the \
leak for library. Reduce the scope for two variables.
Avoid the modification of a parameter pointer pointing to the local stack when it was \
NULL. Avoid the use of deco before it is sure is not NULL.
</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: \
1px solid #b8b5a0"> <tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">Working with the patch applied.</pre> </td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>kwin/clientgroup.cpp <span style="color: grey">(f8604b6)</span></li>
<li>kwin/clients/oxygen/oxygenexceptionlist.cpp <span style="color: \
grey">(652dda0)</span></li>
<li>kwin/effects.cpp <span style="color: grey">(143b033)</span></li>
<li>kwin/effects/blur/blurshader.cpp <span style="color: grey">(e7e5bf3)</span></li>
<li>kwin/effects/coverswitch/coverswitch.cpp <span style="color: \
grey">(6bc98b3)</span></li>
<li>kwin/effects/presentwindows/presentwindows.cpp <span style="color: \
grey">(a0e8306)</span></li>
<li>kwin/effects/slidingpopups/slidingpopups.cpp <span style="color: \
grey">(34bdac4)</span></li>
<li>kwin/kcmkwin/kwinrules/ruleswidget.cpp <span style="color: \
grey">(c3a44df)</span></li>
<li>kwin/libkwineffects/kwineffects.cpp <span style="color: \
grey">(e0c5538)</span></li>
<li>kwin/tools/decobenchmark/preview.cpp <span style="color: \
grey">(36cfcd1)</span></li>
<li>kwin/useractions.cpp <span style="color: grey">(387e499)</span></li>
<li>kwin/workspace.cpp <span style="color: grey">(b955668)</span></li>
</ul>
<p><a href="http://git.reviewboard.kde.org/r/102057/diff/" style="margin-left: \
3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>
_______________________________________________
kwin mailing list
kwin@kde.org
https://mail.kde.org/mailman/listinfo/kwin
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic