Bug 308626 - bsfl validity bit propagation is imprecise
Summary: bsfl validity bit propagation is imprecise
Status: RESOLVED DUPLICATE of bug 308627
Alias: None
Product: valgrind
Classification: Developer tools
Component: memcheck (show other bugs)
Version: 3.9.0.SVN
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-18 21:12 UTC by Patrick J. LoPresti
Modified: 2012-11-08 11:00 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Test case illustrating bsfl validity bit failure (186 bytes, application/octet-stream)
2012-10-18 21:12 UTC, Patrick J. LoPresti
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick J. LoPresti 2012-10-18 21:12:33 UTC
Created attachment 74639 [details]
Test case illustrating bsfl validity bit failure

This is with current SVN (revision 13057).

To reproduce:

1) Compile the attached program with "gcc -O3 -Wall -o test test.c"
2) Run "valgrind test"

I expect this to produce no warnings, because even though the integer starts as an undefined value, the code explicitly clears its low bit and sets its second bit before calling __builtin_ffsl (aka. "bsfl").

Since all of the bits up to and including the first "1" are explicitly set, this program's behavior is perfectly deterministic; it is guaranteed to return "2" from main.

Similar code shows up in certain optimized word-at-a-time string routines, so this is not just hypothetical.  (And it will become even less hypothetical if we ever fix bug 294285.)
Comment 1 Julian Seward 2012-10-19 10:26:07 UTC
The patches posted to bug 308627 should also fix this bug.
Comment 2 Julian Seward 2012-11-08 11:00:02 UTC

*** This bug has been marked as a duplicate of bug 308627 ***