This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug threads/12628] New: GDB checkpoint can't/shouldn't be possiblewith multiple threads on Linux


http://sourceware.org/bugzilla/show_bug.cgi?id=12628

           Summary: GDB checkpoint can't/shouldn't be possible with
                    multiple threads on Linux
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: threads
        AssignedTo: unassigned@sourceware.org
        ReportedBy: kevin.pouget@gmail.com


According to the man page of `fork':

A process shall be created with a single thread. If a multi-threaded process
calls fork(), the new process shall contain a replica of the calling thread and
its entire address space, possibly including the states of mutexes and other
resources. Consequently, to avoid errors, the child process may only execute
async-signal-safe operations until such time as one of the exec functions is
called. Fork handlers may be established by means of the pthread_atfork()
function in order to maintain application invariants across fork() calls.


Below is a patch which simply forbids to create a checkpoint when GDB knows
that there are multiple threads in the debuggee.


The Man page obviously assumes a kernel-based thread library, so does my patch
(user-level thread libraries should fork correctly), but do we want to handle
this situation? (linux-thread-db.c is -- at least was, a few years ago -- tight
to GlibC's Pthread implementation, so it might be fine to continue on this way.

Cordially,

Kevin

---

diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index 7f654af..3eddea4 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -628,6 +628,11 @@ checkpoint_command (char *args, int from_tty)
   pid_t retpid;
   struct cleanup *old_chain;

+  /* Ensure that the inferior is not multithreaded. */
+  update_thread_list () ;
+  if (thread_count () > 1)
+    error(_("checkpoint: can't checkpoint multiple threads.")) ;
+  
   /* Make the inferior fork, record its (and gdb's) state.  */

   if (lookup_minimal_symbol ("fork", NULL, NULL) != NULL)

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]