From: Gisle Aas Date: Sat, 17 Jan 2004 06:18:13 +0000 (-0800) Subject: Perl core dumps when running out of memory [PATCH] X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e0767201fcaa7af00aab34d9bca69adf68de6451;p=p5sagit%2Fp5-mst-13.2.git Perl core dumps when running out of memory [PATCH] Message-Id: Display 'out of memeory' errors using low-level I/O to avoid recursive failure and so coredumps. p4raw-id: //depot/perl@22169 --- diff --git a/util.c b/util.c index fffc1c3..b20cd8c 100644 --- a/util.c +++ b/util.c @@ -72,7 +72,9 @@ Perl_safesysmalloc(MEM_SIZE size) else if (PL_nomemok) return Nullch; else { - PerlIO_puts(Perl_error_log,PL_no_mem) FLUSH; + /* Can't use PerlIO to write as it allocates memory */ + PerlLIO_write(PerlIO_fileno(Perl_error_log), + PL_no_mem, strlen(PL_no_mem)); my_exit(1); return Nullch; } @@ -119,7 +121,9 @@ Perl_safesysrealloc(Malloc_t where,MEM_SIZE size) else if (PL_nomemok) return Nullch; else { - PerlIO_puts(Perl_error_log,PL_no_mem) FLUSH; + /* Can't use PerlIO to write as it allocates memory */ + PerlLIO_write(PerlIO_fileno(Perl_error_log), + PL_no_mem, strlen(PL_no_mem)); my_exit(1); return Nullch; } @@ -171,7 +175,9 @@ Perl_safesyscalloc(MEM_SIZE count, MEM_SIZE size) else if (PL_nomemok) return Nullch; else { - PerlIO_puts(Perl_error_log,PL_no_mem) FLUSH; + /* Can't use PerlIO to write as it allocates memory */ + PerlLIO_write(PerlIO_fileno(Perl_error_log), + PL_no_mem, strlen(PL_no_mem)); my_exit(1); return Nullch; }