https://osmocom.org/https://osmocom.org/favicon.ico?16647414092018-07-19T20:00:48ZOpen Source Mobile Communicationslibosmocore - Bug #3407: libosmocore utils_test isqrt_test() may trigger sanitizerhttps://osmocom.org/issues/3407?journal_id=103802018-07-19T20:00:48Zneelsnhofmeyr@sysmocom.de
<ul></ul><p>It seems to me this test is guaranteed to fail, yet doesn't ever seem to print "ERROR"</p>
<pre>
uint32_t r = rand(); <--- a value up to UINT32_MAX
uint32_t sq = x*x; <--- multiplied by itself will overflow for anything > UINT16_MAX
uint32_t y = osmo_isqrt32(sq); <--- so the original x is then by definition unrecoverable
if (y != x)
printf("ERROR: x=%u, sq=%u, osmo_isqrt(%u) = %u\n", x, sq, sq, y); <-- I never see this, expect to see it a lot.
</pre>
<p>Is it some algorithmic magic? I doubt that we want to have any magic like that?</p> libosmocore - Bug #3407: libosmocore utils_test isqrt_test() may trigger sanitizerhttps://osmocom.org/issues/3407?journal_id=103812018-07-19T20:02:29Zneelsnhofmeyr@sysmocom.de
<ul></ul><p>oh geez, I completely missed the uint16_t x above that.</p> libosmocore - Bug #3407: libosmocore utils_test isqrt_test() may trigger sanitizerhttps://osmocom.org/issues/3407?journal_id=103822018-07-19T20:17:06Zneelsnhofmeyr@sysmocom.de
<ul><li><strong>Status</strong> changed from <i>New</i> to <i>In Progress</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>90</i></li></ul><p>Adding a cast fixes the sanitizer issue:</p>
<p><a class="external" href="https://gerrit.osmocom.org/#/c/libosmocore/+/10066">https://gerrit.osmocom.org/#/c/libosmocore/+/10066</a></p>
<p>and also checking stderr is a good idea: <a class="external" href="https://gerrit.osmocom.org/#/c/libosmocore/+/10067">https://gerrit.osmocom.org/#/c/libosmocore/+/10067</a></p> libosmocore - Bug #3407: libosmocore utils_test isqrt_test() may trigger sanitizerhttps://osmocom.org/issues/3407?journal_id=106842018-08-08T11:25:39Zlaforge
<ul><li><strong>Status</strong> changed from <i>In Progress</i> to <i>Resolved</i></li><li><strong>Assignee</strong> set to <i>neels</i></li></ul><p>both patches have been merged.</p>