Bug 308626

Summary: bsfl validity bit propagation is imprecise
Product: [Developer tools] valgrind Reporter: Patrick J. LoPresti <lopresti>
Component: memcheckAssignee: Julian Seward <jseward>
Status: RESOLVED DUPLICATE    
Severity: normal    
Priority: NOR    
Version: 3.9.0.SVN   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Test case illustrating bsfl validity bit failure

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 ***