diff options
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | bus/dispatch.c | 128 | ||||
-rw-r--r-- | configure.in | 1 | ||||
-rw-r--r-- | dbus/dbus-spawn.c | 3 | ||||
-rw-r--r-- | test/data/valid-service-files/debug-echo.service.in | 2 | ||||
-rw-r--r-- | test/data/valid-service-files/debug-segfault.service.in | 4 | ||||
-rw-r--r-- | test/test-segfault.c | 11 |
7 files changed, 141 insertions, 18 deletions
@@ -1,7 +1,15 @@ 2003-04-10 Havoc Pennington <hp@pobox.com> + * bus/dispatch.c (check_segfault_service_activation): add test + for launching an executable that just crashes. + + * test/test-segfault.c (main): try setting coredumpsize to 0 so we + don't leave a million cores. We'll see how portable this is. + +2003-04-10 Havoc Pennington <hp@pobox.com> + * dbus/dbus-spawn.c (_dbus_spawn_async_with_babysitter): move all - the possible parent failures before we fork, so that we don't + the possible parent failures before we fork, so that we don't q fail to create a babysitter after creating the child. * bus/activation.c (bus_activation_activate_service): kill child diff --git a/bus/dispatch.c b/bus/dispatch.c index f6ddc76a..29364665 100644 --- a/bus/dispatch.c +++ b/bus/dispatch.c @@ -1571,16 +1571,9 @@ check_existent_service_activation (BusContext *context, ; /* good, this is a valid response */ } else if (dbus_message_name_is (message, - DBUS_ERROR_ACTIVATE_SERVICE_NOT_FOUND)) - { - ; /* good, this is expected also */ - } - else if (dbus_message_name_is (message, DBUS_ERROR_SPAWN_CHILD_EXITED)) { - ; /* good, this is expected also (child will exit if for example we don't - * have memory to register it) - */ + ; /* good, this is expected also */ } else { @@ -1687,7 +1680,7 @@ check_existent_service_activation (BusContext *context, goto out; } } - + retval = TRUE; out: @@ -1700,6 +1693,110 @@ check_existent_service_activation (BusContext *context, return retval; } +/* returns TRUE if the correct thing happens, + * but the correct thing may include OOM errors. + */ +static dbus_bool_t +check_segfault_service_activation (BusContext *context, + DBusConnection *connection) +{ + DBusMessage *message; + dbus_int32_t serial; + dbus_bool_t retval; + DBusError error; + + dbus_error_init (&error); + + message = dbus_message_new (DBUS_SERVICE_DBUS, + DBUS_MESSAGE_ACTIVATE_SERVICE); + + if (message == NULL) + return TRUE; + + if (!dbus_message_append_args (message, + DBUS_TYPE_STRING, + "org.freedesktop.DBus.TestSuiteSegfaultService", + DBUS_TYPE_UINT32, 0, + DBUS_TYPE_INVALID)) + { + dbus_message_unref (message); + return TRUE; + } + + if (!dbus_connection_send (connection, message, &serial)) + { + dbus_message_unref (message); + return TRUE; + } + + dbus_message_unref (message); + message = NULL; + + bus_test_run_everything (context); + block_connection_until_message_from_bus (context, connection); + bus_test_run_everything (context); + + if (!dbus_connection_get_is_connected (connection)) + { + _dbus_verbose ("connection was disconnected\n"); + return TRUE; + } + + retval = FALSE; + + message = pop_message_waiting_for_memory (connection); + if (message == NULL) + { + _dbus_warn ("Did not receive a reply to %s %d on %p\n", + DBUS_MESSAGE_ACTIVATE_SERVICE, serial, connection); + goto out; + } + + _dbus_verbose ("Received %s on %p\n", + dbus_message_get_name (message), connection); + + if (dbus_message_get_is_error (message)) + { + if (!dbus_message_sender_is (message, DBUS_SERVICE_DBUS)) + { + _dbus_warn ("Message has wrong sender %s\n", + dbus_message_get_sender (message) ? + dbus_message_get_sender (message) : "(none)"); + goto out; + } + + if (dbus_message_name_is (message, + DBUS_ERROR_NO_MEMORY)) + { + ; /* good, this is a valid response */ + } + else if (dbus_message_name_is (message, + DBUS_ERROR_SPAWN_CHILD_SIGNALED)) + { + ; /* good, this is expected also */ + } + else + { + _dbus_warn ("Did not expect error %s\n", + dbus_message_get_name (message)); + goto out; + } + } + else + { + _dbus_warn ("Did not expect to successfully activate segfault service\n"); + goto out; + } + + retval = TRUE; + + out: + if (message) + dbus_message_unref (message); + + return retval; +} + typedef struct { Check1Func func; @@ -1825,16 +1922,17 @@ bus_dispatch_test (const DBusString *test_data_dir) if (!check_hello_message (context, baz)) _dbus_assert_not_reached ("hello message failed"); -#if 1 - check2_try_iterations (context, foo, "existent_service_activation", - check_existent_service_activation); -#endif + check1_try_iterations (context, "create_and_hello", + check_hello_connection); check2_try_iterations (context, foo, "nonexistent_service_activation", check_nonexistent_service_activation); - check1_try_iterations (context, "create_and_hello", - check_hello_connection); + check2_try_iterations (context, foo, "segfault_service_activation", + check_segfault_service_activation); + + check2_try_iterations (context, foo, "existent_service_activation", + check_existent_service_activation); _dbus_verbose ("Disconnecting foo, bar, and baz\n"); diff --git a/configure.in b/configure.in index 907d78ca..cf25b2d9 100644 --- a/configure.in +++ b/configure.in @@ -530,6 +530,7 @@ dbus-1.0.pc dbus-glib-1.0.pc test/data/valid-config-files/debug-allow-all.conf test/data/valid-service-files/debug-echo.service +test/data/valid-service-files/debug-segfault.service ]) dnl ========================================================================== diff --git a/dbus/dbus-spawn.c b/dbus/dbus-spawn.c index c11dba21..c36e6000 100644 --- a/dbus/dbus-spawn.c +++ b/dbus/dbus-spawn.c @@ -287,6 +287,9 @@ _dbus_babysitter_unref (DBusBabysitter *sitter) } else { + _dbus_verbose ("Reaped %ld, waiting for babysitter %ld\n", + (long) ret, (long) sitter->sitter_pid); + if (WIFEXITED (sitter->status)) _dbus_verbose ("Babysitter exited with status %d\n", WEXITSTATUS (sitter->status)); diff --git a/test/data/valid-service-files/debug-echo.service.in b/test/data/valid-service-files/debug-echo.service.in index 62e79161..c22735a6 100644 --- a/test/data/valid-service-files/debug-echo.service.in +++ b/test/data/valid-service-files/debug-echo.service.in @@ -1,3 +1,3 @@ [D-BUS Service] Name=org.freedesktop.DBus.TestSuiteEchoService -Exec=@TEST_SERVICE_BINARY@
\ No newline at end of file +Exec=@TEST_SERVICE_BINARY@ diff --git a/test/data/valid-service-files/debug-segfault.service.in b/test/data/valid-service-files/debug-segfault.service.in new file mode 100644 index 00000000..73c7b55b --- /dev/null +++ b/test/data/valid-service-files/debug-segfault.service.in @@ -0,0 +1,4 @@ +[D-BUS Service] +Name=org.freedesktop.DBus.TestSuiteSegfaultService +Exec=@TEST_SEGFAULT_BINARY@ + diff --git a/test/test-segfault.c b/test/test-segfault.c index 6c197823..dad0b589 100644 --- a/test/test-segfault.c +++ b/test/test-segfault.c @@ -1,13 +1,22 @@ /* This is simply a process that segfaults */ #include <signal.h> +#include <sys/resource.h> + int main (int argc, char **argv) { - char *p = 0; + char *p; + + struct rlimit r = { 0, }; + + getrlimit (RLIMIT_CORE, &r); + r.rlim_cur = 0; + setrlimit (RLIMIT_CORE, &r); raise (SIGSEGV); + p = 0; *p = 'a'; return 0; |