kmalloc() with size zero
Hello,
I ran into an issue with perfmon where I ended up calling kmalloc() with a size of zero. To my surprise, this did not return NULL but a valid data address.
I am wondering if this is a property of kmalloc() or simply a bug. It is the case that the __kmalloc() code does not check for zero size.
Thanks,
Signature · 1 line
-Stephane
Quoted 10 lines · Stephane Eranian
Hello,
I ran into an issue with perfmon where I ended up calling
kmalloc()with a size of zero. To my surprise, this did not return NULL but a valid data address.I am wondering if this is a property of
kmalloc()or simply a bug. It is the case that the__kmalloc()code does not check for zero size.
I'd say "feature", glibc's malloc also returns an address on malloc(0).
Jan
Quoted 6 lines · Jan Engelhardt
Quoted 1 line · Stephane Eranian
I'd say "feature", glibc's malloc also returns an address on malloc(0).
This is implementation defined-the standard allows for return of either null or an address.
Quoted 11 lines
Jan
--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Signature · 4 lines
Regards, Vignesh Babu BM _____________________________________________________________ "Why is it that every time I'm with you, makes me believe in magic?"
Quoted 5 lines
Quoted 3 lines
I'd say "feature", glibc's malloc also returns an address on malloc(0).
This is implementation defined-the standard allows for return of either null or an address.
Entirely for entertainment: AIX (5.3) returns NULL, IRIX returns a valid address.
Folkert van Heusden
Signature · 5 lines
MultiTail är en flexibel redskap för att fälja logfilar, utför av commandoer, filtrera, ge färg, sammanfoga, o.s.v. följa. http://www.vanheusden.com/multitail/ ---------------------------------------------------------------------- Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com
Hi,
Quoted 9 lines · Folkert van Heusden
Quoted 5 lines
Quoted 3 lines
I'd say "feature", glibc's malloc also returns an address on malloc(0).
This is implementation defined-the standard allows for return of either null or an address.
Entirely for entertainment: AIX (5.3) returns NULL, IRIX returns a valid address.
That's interesting, so many different behaviors! Personally, I still prefer when malloc(0) returns zero because it makes it easier to catch errors.
Signature · 1 line
-Stephane
Quoted 6 lines · Stephane Eranian
Hi,
Quoted 3 lines · Folkert van Heusden
Quoted 3 lines
Quoted 3 lines
I'd say "feature", glibc's malloc also returns an address on malloc(0).
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
This is implementation defined-the standard allows for return of either null or an address.
Entirely for entertainment: AIX (5.3) returns NULL, IRIX returns a valid address.
That's interesting, so many different behaviors! Personally, I still prefer when malloc(0) returns zero because it makes it easier to catch errors.
Exactly, the address returned is not really useful, the improved error checking is useful.
Signature · 3 lines
Bill Davidsen <[email protected]> "We have more to fear from the bungling of the incompetent than from the machinations of the wicked." - from Slashdot
Quoted 7 lines · Stephane Eranian
I ran into an issue with perfmon where I ended up calling
kmalloc()with a size of zero. To my surprise, this did not return NULL but a valid data address.I am wondering if this is a property of
kmalloc()or simply a bug. It is the case that the__kmalloc()code does not check for zero size.
Correct SLAB will give you the smallest possible allocation. I'd say these calls should be fixed. SLUB does check for zero and will throw a stack dump.