This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: malloc(0) crashing with SIGABRT


On 9/9/2019 1:13 PM, Petr Skočík wrote:
> There's been a twitter discussion on how different POSIX platforms
> handle malloc(0): https://twitter.com/sortiecat/status/1170697927804817412 .
> 
> As for Cygwin, the answer appears to be "not well", but this should be
> easy to fix.

Can you show how you produced a crash?  It works fine for me with the following 
test program:

$ cat malloc_zero.c
#include <stdlib.h>
#include <stdio.h>

int
main ()
{
   printf ("malloc (0) = %p\n", malloc (0));
}

$ gcc -Wall -o malloc_zero malloc_zero.c

$ ./malloc_zero.exe
malloc (0) = 0x8000003c0

[This is on 64-bit Cygwin.  It's the same on 32-bit, but with a different address.]

Ken

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]