]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
If DEBUG_OUTOFMEM environment is set, abort() on "out of memory" errors.
authorTimo Sirainen <tss@iki.fi>
Thu, 3 Oct 2013 08:34:48 +0000 (11:34 +0300)
committerTimo Sirainen <tss@iki.fi>
Thu, 3 Oct 2013 08:34:48 +0000 (11:34 +0300)
src/lib/failures.c
src/master/master-settings.c
src/master/service-process.c

index 7e819192e7c49247f6676d76d2722e8bbc1c91d6..556f8937ff3b40983a8bf292c8700e2fecdb3c60 100644 (file)
@@ -187,7 +187,8 @@ default_fatal_finish(enum log_type type, int status)
                        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);
index 2ea707abee445be2f91ef656d7cb2d4f3fd34378..16e4ebf54d3f160e7870d8b3aa724e6e1e9c6fd0 100644 (file)
@@ -217,7 +217,7 @@ static const struct master_settings master_default_settings = {
        .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",
index 6d2d22246e47afa58183e2dfa723a65483e63d92..c3a5b87b6403afe493636ed71ccff657fe957c8e 100644 (file)
@@ -405,6 +405,8 @@ void service_process_unref(struct service_process *process)
 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 @@ get_exit_status_message(struct service *service, enum fatal_exit_status status)
        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";