All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
Cc: Denis Lunev <den@virtuozzo.com>,
	Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
	"jhauser@eecs.berkeley.edu" <jhauser@eecs.berkeley.edu>,
	"cota@braap.org" <cota@braap.org>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] Fix: fp-test uninitialized member floatX::exp
Date: Tue, 27 Aug 2019 16:59:53 +0100	[thread overview]
Message-ID: <87mufu61l2.fsf@linaro.org> (raw)
In-Reply-To: <af72d680-f169-bdba-3b6e-d2da6b820aea@virtuozzo.com>


Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> writes:

> On 13/08/2019 15:21, Alex Bennée wrote:
>>
>> Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> writes:
>>
>>> PINGING...
>>
>> Sorry about the delay. I did attempt see if the existing code threw up
>> any errors when built with clang's undefined sanitizer. I think this is
>> because xPtr->exp will only get read if none of the xPtr->isFOO returns
>> false. In all those cases xPtr->exp is set.
>>
>> What pointed you towards this missing initialisations?
>>
>
> I am sorry about missing the message. It appeared in other email thread
> where I didn't expect. So, I missed the response.
> When I ran the fp-tests under the Valgrind, I got lots of reports about
> using uninitialized memory. They all disappeared after applying this
> patch. I concluded that there are paths that use xPtr->exp uninitialized.
>
> $ /usr/bin/valgrind --leak-check=no --trace-children=yes
> --keep-stacktraces=alloc-and-free --track-origins=yes
> --log-file=myqemu-%p.log make check-softfloat

It would be useful to know what tests are being run (V=1 will show you).
I can't replicate the failure with:

  valgrind --leak-check=no --trace-children=yes --keep-stacktraces=alloc-and-free --track-origins=yes ./fp-test -s -l 2 -r all  f16_to_f32 f16_to_f64 f16_to_f128 f32_to_f16 f32_to_f64

>
> ==720268== Conditional jump or move depends on uninitialised value(s)
> ==720268==    at 0x112C72: floatXRoundToInt (slowfloat.c:1371)
> ==720268==    by 0x115920: slow_f16_roundToInt (slowfloat.c:2408)
> ==720268==    by 0x133A87: test_az_f16_rx (test_az_f16_rx.c:73)
> ==720268==    by 0x10E635: do_testfloat (fp-test.c:304)
> ==720268==    by 0x10FD02: run_test (fp-test.c:1003)
> ==720268==    by 0x10FDA4: main (fp-test.c:1017)
> ==720268==  Uninitialised value was created by a stack allocation
> ==720268==    at 0x1158D3: slow_f16_roundToInt (slowfloat.c:2404)
>
> ==720311== Conditional jump or move depends on uninitialised value(s)
> ==720311==    at 0x112E54: floatXAdd (slowfloat.c:1411)
> ==720311==    by 0x115A2D: slow_f16_sub (slowfloat.c:2431)
> ==720311==    by 0x133CEC: test_abz_f16 (test_abz_f16.c:70)
> ==720311==    by 0x10E6D5: do_testfloat (fp-test.c:326)
> ==720311==    by 0x10FD02: run_test (fp-test.c:1003)
> ==720311==    by 0x10FDA4: main (fp-test.c:1017)
> ==720311==  Uninitialised value was created by a stack allocation
> ==720311==    at 0x1159C0: slow_f16_sub (slowfloat.c:2425)
>
> ==720273== Conditional jump or move depends on uninitialised value(s)
> ==720273==    at 0x113D54: floatXEq (slowfloat.c:1661)
> ==720273==    by 0x115EAD: slow_f16_eq_signaling (slowfloat.c:2538)
> ==720273==    by 0x1341D3: test_ab_f16_z_bool (test_ab_f16_z_bool.c:71)
> ==720273==    by 0x10E7DE: do_testfloat (fp-test.c:358)
> ==720273==    by 0x10FD02: run_test (fp-test.c:1003)
> ==720273==    by 0x10FDA4: main (fp-test.c:1017)
> ==720273==  Uninitialised value was created by a stack allocation
> ==720273==    at 0x115E38: slow_f16_eq_signaling (slowfloat.c:2530)
>
> Even if Valgrind is wrong, the purpose of the patch is to reduce the
> number of error reports from the Valgrind to locate other memory serious
> issues, if any.
>
> Andrey
>
>>>
>>> On 30/07/2019 13:13, Andrey Shinkevich wrote:
>>>> Not all the paths in the functions, such as f16ToFloatX(), initialize
>>>> the member 'exp' of the structure floatX.
>>>>
>>>> Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
>>>> ---
>>>>    source/slowfloat.c | 4 ++++
>>>>    1 file changed, 4 insertions(+)
>>>>
>>>> diff --git a/tests/fp/berkeley-testfloat-3/source/slowfloat.c b/tests/fp/berkeley-testfloat-3/source/slowfloat.c
>>>> index 4e84656..6e0f0a6 100644
>>>> --- a/tests/fp/berkeley-testfloat-3/source/slowfloat.c
>>>> +++ b/tests/fp/berkeley-testfloat-3/source/slowfloat.c
>>>> @@ -623,6 +623,7 @@ static void f16ToFloatX( float16_t a, struct floatX *xPtr )
>>>>        xPtr->isInf = false;
>>>>        xPtr->isZero = false;
>>>>        xPtr->sign = ((uiA & 0x8000) != 0);
>>>> +    xPtr->exp = 0;
>>>>        exp = uiA>>10 & 0x1F;
>>>>        sig64 = uiA & 0x03FF;
>>>>        sig64 <<= 45;
>>>> @@ -759,6 +760,7 @@ static void f32ToFloatX( float32_t a, struct floatX *xPtr )
>>>>        xPtr->isInf = false;
>>>>        xPtr->isZero = false;
>>>>        xPtr->sign = ((uiA & 0x80000000) != 0);
>>>> +    xPtr->exp = 0;
>>>>        exp = uiA>>23 & 0xFF;
>>>>        sig64 = uiA & 0x007FFFFF;
>>>>        sig64 <<= 32;
>>>> @@ -895,6 +897,7 @@ static void f64ToFloatX( float64_t a, struct floatX *xPtr )
>>>>        xPtr->isInf = false;
>>>>        xPtr->isZero = false;
>>>>        xPtr->sign = ((uiA & UINT64_C( 0x8000000000000000 )) != 0);
>>>> +    xPtr->exp = 0;
>>>>        exp = uiA>>52 & 0x7FF;
>>>>        sig64 = uiA & UINT64_C( 0x000FFFFFFFFFFFFF );
>>>>        if ( exp == 0x7FF ) {
>>>> @@ -1220,6 +1223,7 @@ static void f128MToFloatX( const float128_t *aPtr, struct floatX *xPtr )
>>>>        xPtr->isZero = false;
>>>>        uiA64 = uiAPtr->v64;
>>>>        xPtr->sign = ((uiA64 & UINT64_C( 0x8000000000000000 )) != 0);
>>>> +    xPtr->exp = 0;
>>>>        exp = uiA64>>48 & 0x7FFF;
>>>>        sig.v64 = uiA64 & UINT64_C( 0x0000FFFFFFFFFFFF );
>>>>        sig.v0  = uiAPtr->v0;
>>>>
>>
>>
>> --
>> Alex Bennée
>>


--
Alex Bennée


  parent reply	other threads:[~2019-08-27 16:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-30 10:13 [Qemu-devel] [PATCH] Fix: fp-test uninitialized member floatX::exp Andrey Shinkevich
2019-08-13 12:03 ` Andrey Shinkevich
2019-08-13 12:21   ` Alex Bennée
2019-08-20 17:01     ` Andrey Shinkevich
2019-08-27 15:05       ` Andrey Shinkevich
2019-08-27 15:59       ` Alex Bennée [this message]
2019-08-29 15:50         ` Andrey Shinkevich
2019-08-20 15:16 ` Andrey Shinkevich
2019-08-20 15:21   ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mufu61l2.fsf@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=andrey.shinkevich@virtuozzo.com \
    --cc=cota@braap.org \
    --cc=den@virtuozzo.com \
    --cc=jhauser@eecs.berkeley.edu \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.