dovecot-2.2: If DEBUG_OUTOFMEM environment is set, abort() on "o...

dovecot at dovecot.org dovecot at dovecot.org
Thu Oct 3 11:35:04 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/b5ec4d364c2e
changeset: 16833:b5ec4d364c2e
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Oct 03 11:34:48 2013 +0300
description:
If DEBUG_OUTOFMEM environment is set, abort() on "out of memory" errors.

diffstat:

 src/lib/failures.c           |   3 ++-
 src/master/master-settings.c |   2 +-
 src/master/service-process.c |  19 +++++++++++++------
 3 files changed, 16 insertions(+), 8 deletions(-)

diffs (61 lines):

diff -r 81aedacbb01f -r b5ec4d364c2e src/lib/failures.c
--- a/src/lib/failures.c	Thu Oct 03 11:20:09 2013 +0300
+++ b/src/lib/failures.c	Thu Oct 03 11:34:48 2013 +0300
@@ -187,7 +187,8 @@
 			i_error("Raw backtrace: %s", backtrace);
 	}
 
-	if (type == LOG_TYPE_PANIC)
+	if (type == LOG_TYPE_PANIC ||
+	    (status == FATAL_OUTOFMEM && getenv("DEBUG_OUTOFMEM") != NULL))
 		abort();
 	else
 		failure_exit(status);
diff -r 81aedacbb01f -r b5ec4d364c2e src/master/master-settings.c
--- a/src/master/master-settings.c	Thu Oct 03 11:20:09 2013 +0300
+++ b/src/master/master-settings.c	Thu Oct 03 11:34:48 2013 +0300
@@ -217,7 +217,7 @@
 	.state_dir = PKG_STATEDIR,
 	.libexec_dir = PKG_LIBEXECDIR,
 	.instance_name = PACKAGE,
-	.import_environment = "TZ" ENV_SYSTEMD ENV_GDB,
+	.import_environment = "TZ DEBUG_OUTOFMEM" ENV_SYSTEMD ENV_GDB,
 	.protocols = "imap pop3 lmtp",
 	.listen = "*, ::",
 	.ssl = "yes:no:required",
diff -r 81aedacbb01f -r b5ec4d364c2e src/master/service-process.c
--- a/src/master/service-process.c	Thu Oct 03 11:20:09 2013 +0300
+++ b/src/master/service-process.c	Thu Oct 03 11:34:48 2013 +0300
@@ -405,6 +405,8 @@
 static const char *
 get_exit_status_message(struct service *service, enum fatal_exit_status status)
 {
+	string_t *str;
+
 	switch (status) {
 	case FATAL_LOGOPEN:
 		return "Can't open log file";
@@ -413,12 +415,17 @@
 	case FATAL_LOGERROR:
 		return "Internal logging error";
 	case FATAL_OUTOFMEM:
-		if (service->vsz_limit == 0)
-			return "Out of memory";
-		return t_strdup_printf("Out of memory (service %s { vsz_limit=%u MB }, "
-				"you may need to increase it)",
-				service->set->name,
-				(unsigned int)(service->vsz_limit/1024/1024));
+		str = t_str_new(128);
+		str_append(str, "Out of memory");
+		if (service->vsz_limit != 0) {
+			str_printfa(str, " (service %s { vsz_limit=%u MB }, "
+				    "you may need to increase it)",
+				    service->set->name,
+				    (unsigned int)(service->vsz_limit/1024/1024));
+		}
+		if (getenv("DEBUG_OUTOFMEM") == NULL)
+			str_append(str, " - set DEBUG_OUTOFMEM=1 environment to get core dump");
+		return str_c(str);
 	case FATAL_EXEC:
 		return "exec() failed";
 


More information about the dovecot-cvs mailing list