This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Perl core dumps when running out of memory [PATCH]
authorGisle Aas <gisle@aas.no>
Sat, 17 Jan 2004 06:18:13 +0000 (22:18 -0800)
committerDave Mitchell <davem@fdisolutions.com>
Sat, 17 Jan 2004 18:02:31 +0000 (18:02 +0000)
Message-Id:  <lrsmiebqvu.fsf@caliper.activestate.com>

Display 'out of memeory' errors using low-level I/O to avoid
recursive failure and so coredumps.

p4raw-id: //depot/perl@22169

util.c

diff --git a/util.c b/util.c
index fffc1c3..b20cd8c 100644 (file)
--- 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;
     }