9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] _threadmalloc() size>100000000; shouldn't be totalmalloc?
@ 2022-06-26  9:50 adr
  2022-06-28 13:00 ` [9fans] " adr
  0 siblings, 1 reply; 7+ messages in thread
From: adr @ 2022-06-26  9:50 UTC (permalink / raw)
  To: 9fans

/sys/src/libthread/lib.c

[...]
void*
_threadmalloc(long size, int z)
{
        void *m;

        m = malloc(size);
        if (m == nil)
                sysfatal("Malloc of size %ld failed: %r", size);
        setmalloctag(m, getcallerpc(&size));
        totalmalloc += size;
        if (size > 100000000) {
                fprint(2, "Malloc of size %ld, total %ld\n", size, totalmalloc);
                abort();
        }
        if (z)
                memset(m, 0, size);
        return m;
}
[...]

Shouldn't the if statement test the size of totalmalloc before the
abort? That size, 100M for internal allocations? It has to be
totalmalloc, doesn't it? If not this if statement should be after
testing the success of the malloc. Am I missing something?

adr.

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Te1be8dc72738258d-M704d54262c512e9fce0f9fae
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-06-28 15:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-26  9:50 [9fans] _threadmalloc() size>100000000; shouldn't be totalmalloc? adr
2022-06-28 13:00 ` [9fans] " adr
2022-06-28 13:50   ` Dan Cross
2022-06-28 14:21     ` adr
2022-06-28 14:32       ` Dan Cross
2022-06-28 15:36         ` adr
2022-06-28 15:57           ` Dan Cross

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).