[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-frameworks-devel
Subject:    Re: Review Request 127968: kshareddatacache: Fix invalid use of & to avoid unaligned reads
From:       Michael Pyne <mpyne () kde ! org>
Date:       2016-05-20 23:10:07
Message-ID: 20160520231007.15344.6030 () mimi ! kde ! org
[Download RAW message or body]

--===============1275974989097109881==
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit



> On May 19, 2016, 11:17 p.m., Michael Pyne wrote:
> > This is an error upstream in the MurmurHash 1.0 aligned implementation (which \
> > still contains the error, see \
> > https://sites.google.com/site/murmurhash/MurmurHashAligned.cpp?attredirects=0 ) 
> > In our case KSharedDataCache will never pass an unaligned block into the hash \
> > function so 'align' was always 0 (and boolean false) anyways. So I concur with \
> > not bumping the cache version and agree with your patch. Thanks for taking a \
> > look!
> 
> Fabian Vogt wrote:
> I didn't know this aligned implementation actually had an upstream, it's actually \
> fixed there, the latest source is on GitHub: \
> https://github.com/aappleby/smhasher/blob/master/src/MurmurHash1.cpp#L87

Ah, great news then. I'll have to update the URL in the KSharedDataCache sources then \
for posterity.


- Michael


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/127968/#review95630
-----------------------------------------------------------


On May 20, 2016, 8:08 a.m., Fabian Vogt wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/127968/
> -----------------------------------------------------------
> 
> (Updated May 20, 2016, 8:08 a.m.)
> 
> 
> Review request for KDE Frameworks, David Faure and Michael Pyne.
> 
> 
> Repository: kcoreaddons
> 
> 
> Description
> -------
> 
> That the & is wrong here is obvious:
> align can never be 2 inside the if condition as ```(2 & bool)``` is always false,
> yet the switch on align contains a case for 2.
> Instead it drops into the while loop for an 4-byte aligned pointer.
> 
> This doesn't change the returned values on platforms where unaligned reads
> are permitted, so I didn't bump the version.
> 
> 
> Diffs
> -----
> 
> src/lib/caching/kshareddatacache.cpp 50bbf64 
> 
> Diff: https://git.reviewboard.kde.org/r/127968/diff/
> 
> 
> Testing
> -------
> 
> Ran make test, all passed.
> 
> 
> Thanks,
> 
> Fabian Vogt
> 
> 


--===============1275974989097109881==
MIME-Version: 1.0
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: 7bit




<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="12" style="border: 1px #c9c399 \
solid; border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;">  \
<tr>  <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="https://git.reviewboard.kde.org/r/127968/">https://git.reviewboard.kde.org/r/127968/</a>
  </td>
    </tr>
   </table>
   <br />





<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;">  <p style="margin-top: 0;">On May 19th, 2016, 11:17 p.m. UTC, <b>Michael \
Pyne</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;">This is an error upstream in the MurmurHash 1.0 aligned implementation \
(which still contains the error, see \
https://sites.google.com/site/murmurhash/MurmurHashAligned.cpp?attredirects=0 )

In our case KSharedDataCache will never pass an unaligned block into the hash \
function so &#39;align&#39; was always 0 (and boolean false) anyways. So I concur \
with not bumping the cache version and agree with your patch. Thanks for taking a \
look!</pre>  </blockquote>




 <p>On May 20th, 2016, 6:51 a.m. UTC, <b>Fabian Vogt</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;"><p style="padding: \
0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">I \
didn't know this aligned implementation actually had an upstream, it's actually fixed \
there, the latest source is on GitHub: \
https://github.com/aappleby/smhasher/blob/master/src/MurmurHash1.cpp#L87</p></pre>  \
</blockquote>








</blockquote>

<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Ah, great news then. \
I&#39;ll have to update the URL in the KSharedDataCache sources then for \
posterity.</pre> <br />










<p>- Michael</p>


<br />
<p>On May 20th, 2016, 8:08 a.m. UTC, Fabian Vogt wrote:</p>








<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="12" style="border: \
1px #888a85 solid; border-radius: 6px; -moz-border-radius: 6px; \
-webkit-border-radius: 6px;">  <tr>
  <td>

<div>Review request for KDE Frameworks, David Faure and Michael Pyne.</div>
<div>By Fabian Vogt.</div>


<p style="color: grey;"><i>Updated May 20, 2016, 8:08 a.m.</i></p>









<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt;">Repository: </b>
kcoreaddons
</div>


<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;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: \
inherit;white-space: inherit;">That the &amp; is wrong here is obvious: align can \
never be 2 inside the if condition as <code style="text-rendering: inherit;color: \
#4444cc;padding: 0;white-space: normal;margin: 0;line-height: inherit;">(2 &amp; \
bool)</code> is always false, yet the switch on align contains a case for 2.
Instead it drops into the while loop for an 4-byte aligned pointer.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: \
inherit;white-space: inherit;">This doesn't change the returned values on platforms \
where unaligned reads are permitted, so I didn't bump the version.</p></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;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: \
inherit;white-space: inherit;">Ran make test, all passed.</p></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>src/lib/caching/kshareddatacache.cpp <span style="color: \
grey">(50bbf64)</span></li>

</ul>

<p><a href="https://git.reviewboard.kde.org/r/127968/diff/" style="margin-left: \
3em;">View Diff</a></p>






  </td>
 </tr>
</table>







  </div>
 </body>
</html>


--===============1275974989097109881==--


[Attachment #3 (text/plain)]

_______________________________________________
Kde-frameworks-devel mailing list
Kde-frameworks-devel@kde.org
https://mail.kde.org/mailman/listinfo/kde-frameworks-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic