]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
2003-04-10 Havoc Pennington <hp@pobox.com>
authorHavoc Pennington <hp@redhat.com>
Fri, 11 Apr 2003 03:45:40 +0000 (03:45 +0000)
committerHavoc Pennington <hp@redhat.com>
Fri, 11 Apr 2003 03:45:40 +0000 (03:45 +0000)
* 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.

ChangeLog
bus/dispatch.c
configure.in
dbus/dbus-spawn.c
test/data/valid-service-files/debug-echo.service.in
test/data/valid-service-files/debug-segfault.service.in [new file with mode: 0644]
test/test-segfault.c

index 2f407a46314937c551bdab2e9ffb58d94f4ff921..26aa048f8f33bc226b4e11b3a7b0153477e3326d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
index f6ddc76a46e300a03789904ebca966b9e69ba9ca..29364665e98975a24f789b7b1f8df73140ff7e1e 100644 (file)
@@ -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");
 
index 907d78ca65bfc248aaf6c22cd027d7782797d3b7..cf25b2d9bbc932aaa6316067542ab081bf97197b 100644 (file)
@@ -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 ==========================================================================
index c11dba21c1bac0a43d7fa2dfa12b0eb69f1c6b6a..c36e6000f4e7c93fd228331cc717b4b33d17706a 100644 (file)
@@ -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));
index 62e791617ad2eecf01547d8970476f14d51dde8d..c22735a6f4a14ed657aed879a41bdc5e759552b3 100644 (file)
@@ -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 (file)
index 0000000..73c7b55
--- /dev/null
@@ -0,0 +1,4 @@
+[D-BUS Service]
+Name=org.freedesktop.DBus.TestSuiteSegfaultService
+Exec=@TEST_SEGFAULT_BINARY@
+
index 6c1978237d33b4eb7d23e5d844aa77d0137f7c1a..dad0b58927b794b37d5dabe142196ecb4bcc7537 100644 (file)
@@ -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;