Bug 24903 - malloc/tst-mxfast fails on i386
Summary: malloc/tst-mxfast fails on i386
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: malloc (show other bugs)
Version: 2.31
: P3 minor
Target Milestone: 2.31
Assignee: dj@redhat.com
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-08-13 15:16 UTC by Florian Weimer
Modified: 2020-07-08 16:45 UTC (History)
1 user (show)

See Also:
Host:
Target: i686-linux-gnu
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Weimer 2019-08-13 15:16:52 UTC
The test fails like this (also when run by the harness):

GLIBC_TUNABLES=glibc.malloc.tcache_count=0:glibc.malloc.mxfast=0 bash testrun.sh malloc/tst-mxfast
tst-mxfast: tst-mxfast.c:42: do_test: Assertion `m.smblks == 0' failed.
Didn't expect signal from child: got `Aborted'

The assert is incorrect too, it should be TEST_VERIFY.  Furthermore, the copyright date on the file is wrong (it was committed in 2019).  mallinfo() is a format glitch, too.
Comment 1 Florian Weimer 2019-08-15 09:50:11 UTC
This looks related to bug 24906 due to the way set_max_fast is defined:

#define set_max_fast(s) \
  global_max_fast = (((s) == 0)						      \
                     ? SMALLBIN_WIDTH : ((s + SIZE_SZ) & ~MALLOC_ALIGN_MASK))

On i386, set_max_fast (0) does not actually disable fastbins, I think.
Comment 2 Carlos O'Donell 2019-08-15 13:33:39 UTC
(In reply to Florian Weimer from comment #1)
> This looks related to bug 24906 due to the way set_max_fast is defined:
> 
> #define set_max_fast(s) \
>   global_max_fast = (((s) == 0)						      \
>                      ? SMALLBIN_WIDTH : ((s + SIZE_SZ) & ~MALLOC_ALIGN_MASK))
> 
> On i386, set_max_fast (0) does not actually disable fastbins, I think.

It should always set things to a smallbin width that is smaller than the allowed smallbin width. If it doesn't then it's a bug in the i686 support.
Comment 3 Carlos O'Donell 2019-10-31 00:14:07 UTC
Patch posted to fix this:
https://www.sourceware.org/ml/libc-alpha/2019-10/msg00952.html
Comment 4 Sourceware Commits 2019-10-31 03:09:26 UTC
The master branch has been updated by DJ Delorie <dj@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=ff12e0fb91b9072800f031cb21fb2651ee7b6251

commit ff12e0fb91b9072800f031cb21fb2651ee7b6251
Author: DJ Delorie <dj@redhat.com>
Date:   Wed Oct 30 18:03:14 2019 -0400

    Base max_fast on alignment, not width, of bins (Bug 24903)
    
    set_max_fast sets the "impossibly small" value based on,
    eventually, MALLOC_ALIGNMENT.  The comparisons for the smallest
    chunk used is, eventually, MIN_CHUNK_SIZE.  Note that i386
    is the only platform where these are the same, so a smallest
    chunk *would* be put in a no-fastbins fastbin.
    
    This change calculates the "impossibly small" value
    based on MIN_CHUNK_SIZE instead, so that we can know it will
    always be impossibly small.
Comment 5 dj@redhat.com 2019-10-31 03:12:54 UTC
I fixed the cause of the bug but not the details in the test case itself, leaving open for that purpose.
Comment 6 dj@redhat.com 2019-10-31 03:29:10 UTC
The test itself was fixed in commit f9769a239784772453d595bc2f4bed8739810e06 (2019-08-15)
Comment 7 Sourceware Commits 2019-10-31 15:49:47 UTC
The release/2.28/master branch has been updated by Arjun Shankar <arjun@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=f144981490bd2ab13189d85902ca74beecb307e4

commit f144981490bd2ab13189d85902ca74beecb307e4
Author: DJ Delorie <dj@redhat.com>
Date:   Wed Oct 30 18:03:14 2019 -0400

    Base max_fast on alignment, not width, of bins (Bug 24903)
    
    set_max_fast sets the "impossibly small" value based on,
    eventually, MALLOC_ALIGNMENT.  The comparisons for the smallest
    chunk used is, eventually, MIN_CHUNK_SIZE.  Note that i386
    is the only platform where these are the same, so a smallest
    chunk *would* be put in a no-fastbins fastbin.
    
    This change calculates the "impossibly small" value
    based on MIN_CHUNK_SIZE instead, so that we can know it will
    always be impossibly small.
    
    (cherry picked from commit ff12e0fb91b9072800f031cb21fb2651ee7b6251)
Comment 8 Sourceware Commits 2019-11-18 17:59:12 UTC
The release/2.29/master branch has been updated by Arjun Shankar <arjun@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=a683450f261d7e79abc543481f7f473abdb9b406

commit a683450f261d7e79abc543481f7f473abdb9b406
Author: DJ Delorie <dj@redhat.com>
Date:   Wed Oct 30 18:03:14 2019 -0400

    Base max_fast on alignment, not width, of bins (Bug 24903)
    
    set_max_fast sets the "impossibly small" value based on,
    eventually, MALLOC_ALIGNMENT.  The comparisons for the smallest
    chunk used is, eventually, MIN_CHUNK_SIZE.  Note that i386
    is the only platform where these are the same, so a smallest
    chunk *would* be put in a no-fastbins fastbin.
    
    This change calculates the "impossibly small" value
    based on MIN_CHUNK_SIZE instead, so that we can know it will
    always be impossibly small.
    
    (cherry picked from commit ff12e0fb91b9072800f031cb21fb2651ee7b6251)
Comment 9 Sourceware Commits 2019-11-19 12:13:10 UTC
The release/2.30/master branch has been updated by Arjun Shankar <arjun@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=919af705eef416f4469341dfdf4ca23450f30236

commit 919af705eef416f4469341dfdf4ca23450f30236
Author: DJ Delorie <dj@redhat.com>
Date:   Wed Oct 30 18:03:14 2019 -0400

    Base max_fast on alignment, not width, of bins (Bug 24903)
    
    set_max_fast sets the "impossibly small" value based on,
    eventually, MALLOC_ALIGNMENT.  The comparisons for the smallest
    chunk used is, eventually, MIN_CHUNK_SIZE.  Note that i386
    is the only platform where these are the same, so a smallest
    chunk *would* be put in a no-fastbins fastbin.
    
    This change calculates the "impossibly small" value
    based on MIN_CHUNK_SIZE instead, so that we can know it will
    always be impossibly small.
    
    (cherry picked from commit ff12e0fb91b9072800f031cb21fb2651ee7b6251)