thread/patch ...

View: New views
1 Messages — Rating Filter:   Alert me  

thread/patch ...

by michael meeks :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi there,

        So - memprof is proving horribly unstable with OO.o for reasons that I
don't completely understand; either way - adding atomic operations for
'seq' seems to have fixed one bug I saw [ with an exploding queue -
waiting for a seqno that never arrived ].

        My other problems tend to end up with memprof just doing a blocking
read forever on a socket - which, since the other end is pumping data
down (another?) socket via send() just shouldn't happen. We just block
in g_io_channel_read_chars.

        The attached patch adds atomic seqno bits, and adds a load more error
conditions to listen for on the pipe.

        I'm still really rather unsure as to how memprof can possibly be
blocking; is it possible that data is getting corrupted - mi_write seems
to have no protection, and multiple threads could (in theory) send
partial chunks of buffer in an interleaved way (?) - or is that
impossible in practice ?

        Advice appreciated;

        HTH,

                Michael.

--
 michael.meeks@...  <><, Pseudo Engineer, itinerant idiot

[memprof.diff]

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/memprof/ChangeLog,v
retrieving revision 1.129
diff -u -r1.129 ChangeLog
--- ChangeLog 1 Apr 2005 23:09:59 -0000 1.129
+++ ChangeLog 13 Jun 2005 15:26:27 -0000
@@ -1,3 +1,13 @@
+2005-06-13  Michael Meeks  <michael.meeks@...>
+
+ * server.c (ensure_cleanup, mp_server_init),
+ * process.c (process_start_input): use a fuller set
+ of G_IO_ flags for various conditions.
+
+ * intercept.c (exit_wait, mi_write_stack): use atomic
+ increment for seqno - if we get out of step process.c
+ bombs with an ever-growing sorted GList.
+
 2005-04-01  Steve Murphy  <murf@...>
 
         * configure.in: Added "rw" to ALL_LINGUAS.
Index: intercept.c
===================================================================
RCS file: /cvs/gnome/memprof/intercept.c,v
retrieving revision 1.5
diff -u -r1.5 intercept.c
--- intercept.c 3 Sep 2004 22:29:47 -0000 1.5
+++ intercept.c 13 Jun 2005 15:26:27 -0000
@@ -72,8 +72,8 @@
 static ThreadInfo threads[MAX_THREADS];
 static char *socket_path = NULL;
 static char socket_buf[64];
-static unsigned int seqno = 0;
+static uint32_t seqno = 0;
 
 #undef ENABLE_DEBUG
 
 #ifdef ENABLE_DEBUG
@@ -331,7 +332,7 @@
 
  info->alloc.stack_size = n_frames;
  info->alloc.pid = getpid();
- info->alloc.seqno = seqno++;
+ info->alloc.seqno = mi_atomic_increment (&seqno) - 1;
 
  thread = find_thread (info->alloc.pid);
 
@@ -490,7 +491,7 @@
  int count;
  char response;
  info.any.operation = MI_EXIT;
- info.any.seqno = seqno++;
+ info.any.seqno = mi_atomic_increment (&seqno) - 1;
  info.any.pid = getpid();
 
  mi_stop ();
Index: process.c
===================================================================
RCS file: /cvs/gnome/memprof/process.c,v
retrieving revision 1.37
diff -u -r1.37 process.c
--- process.c 13 Sep 2004 18:43:52 -0000 1.37
+++ process.c 13 Jun 2005 15:26:29 -0000
@@ -667,7 +667,7 @@
  if (!process->input_tag && process->input_channel)
  process->input_tag = g_io_add_watch_full (process->input_channel,
   G_PRIORITY_LOW,
-  G_IO_IN | G_IO_HUP,
+  G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
   input_func, process, NULL);
 }
 
Index: server.c
===================================================================
RCS file: /cvs/gnome/memprof/server.c,v
retrieving revision 1.14
diff -u -r1.14 server.c
--- server.c 20 Sep 2003 21:02:18 -0000 1.14
+++ server.c 13 Jun 2005 15:26:29 -0000
@@ -164,7 +164,8 @@
  channel = g_io_channel_unix_new (server->socket_fd);
  g_io_channel_set_encoding (channel, NULL, NULL);
 
- server->control_watch = g_io_add_watch (channel, G_IO_IN | G_IO_HUP, control_func, server);
+ server->control_watch = g_io_add_watch (channel, G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
+ control_func, server);
  g_io_channel_unref (channel);
 
  g_object_ref (G_OBJECT (server));
@@ -366,7 +367,7 @@
  channel = g_io_channel_unix_new (terminate_pipe[0]);
  g_io_channel_set_encoding (channel, NULL, NULL);
 
- g_io_add_watch (channel, G_IO_IN, terminate_io_handler, NULL);
+ g_io_add_watch (channel, G_IO_IN | G_IO_PRI, terminate_io_handler, NULL);
  g_io_channel_unref (channel);
 
  added_cleanup = TRUE;


_______________________________________________
memprof-list mailing list
memprof-list@...
http://mail.gnome.org/mailman/listinfo/memprof-list