Commit 78e79022 authored by Havoc Pennington's avatar Havoc Pennington

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.
parent eb63ba50
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
......
......@@ -1570,17 +1570,10 @@ 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");
......
......@@ -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 ==========================================================================
......
......@@ -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));
......
[D-BUS Service]
Name=org.freedesktop.DBus.TestSuiteEchoService
Exec=@TEST_SERVICE_BINARY@
\ No newline at end of file
Exec=@TEST_SERVICE_BINARY@
[D-BUS Service]
Name=org.freedesktop.DBus.TestSuiteSegfaultService
Exec=@TEST_SEGFAULT_BINARY@
/* 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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment