Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Oct 2021 15:49:54 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 259076] pthread_mutex_init fails with limited AS
Message-ID:  <bug-259076-227-NF6K7Gw09i@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-259076-227@https.bugs.freebsd.org/bugzilla/>
References:  <bug-259076-227@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D259076

--- Comment #6 from Denis Koreshkov <dynamic-wind@mail.ru> ---
All right, here's a worse bug in rtld-malloc.

Once morepages has failed, it sets pagepool_start to MAP_FAILED, that is -1.
If the next call to __crt_malloc is for the same bucket, morecore is called
again but does not call morepages, because (amt > pagepool_end -
pagepool_start) is TRUE. And the free list loop crashes.

A quick test (with -lpthread, release >=3D 12.1):
#include <sys/time.h>
#include <sys/resource.h>
#include <pthread.h>

int
main()
{
        pthread_mutex_t t;
        int lim =3D 1<<26;

        struct rlimit rl =3D { lim,lim };
        setrlimit(RLIMIT_AS,&rl);

        for(;;) {
                if (pthread_mutex_init(&t,NULL)) {
                        pthread_mutex_init(&t,NULL);
                        break;
                }
        }
        return 0;
}

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-259076-227-NF6K7Gw09i>