Hello Julian,

There is a small inconsistency in the Valgrind core with regard to the
value of VG_(running_tid) concerning client memory accesses: this
variable contains a valid thread ID for all client memory accesses,
except for some accesses triggered from coregrind/m_main.c. The
attached patch fixes this and also contains some exp-drd
simplifications that became possible because of the fix in the core.
Can you please evaluate this patch and apply it if you consider it
acceptable ? Regression test results are unaffected by the patch --
the results below are for the x86_64 platform.

== 357 tests, 7 stderr failures, 2 stdout failures, 0 post failures ==
memcheck/tests/malloc_free_fill          (stderr)
memcheck/tests/pointer-trace             (stderr)
memcheck/tests/vcpu_fnfns                (stdout)
memcheck/tests/writev                    (stderr)
memcheck/tests/x86/scalar                (stderr)
memcheck/tests/x86/scalar_exit_group     (stderr)
memcheck/tests/x86/scalar_supp           (stderr)
none/tests/mremap                        (stderr)
none/tests/mremap2                       (stdout)

Regards,

Bart Van Assche.
Index: exp-drd/drd_thread.c
===================================================================
--- exp-drd/drd_thread.c	(revision 7303)
+++ exp-drd/drd_thread.c	(working copy)
@@ -424,17 +424,14 @@
 
 DrdThreadId thread_get_running_tid(void)
 {
-   // HACK. To do: remove the if-statement and keep the assert.
-   if (VG_(get_running_tid)() != VG_INVALID_THREADID)
-      tl_assert(VG_(get_running_tid)() == s_vg_running_tid);
+   tl_assert(VG_(get_running_tid)() == s_vg_running_tid);
    tl_assert(s_drd_running_tid != DRD_INVALID_THREADID);
    return s_drd_running_tid;
 }
 
 void thread_set_vg_running_tid(const ThreadId vg_tid)
 {
-   // HACK. To do: uncomment the line below.
-   // tl_assert(vg_tid != VG_INVALID_THREADID);
+   tl_assert(vg_tid != VG_INVALID_THREADID);
 
    if (vg_tid != s_vg_running_tid)
    {
@@ -447,10 +444,6 @@
 
 void thread_set_running_tid(const ThreadId vg_tid, const DrdThreadId drd_tid)
 {
-   // HACK. To do: remove the next two lines.
-   if (vg_tid == VG_INVALID_THREADID)
-      return;
-
    tl_assert(vg_tid != VG_INVALID_THREADID);
    tl_assert(drd_tid != DRD_INVALID_THREADID);
    
Index: exp-drd/TODO.txt
===================================================================
--- exp-drd/TODO.txt	(revision 7303)
+++ exp-drd/TODO.txt	(working copy)
@@ -39,8 +39,8 @@
 
 Documentation
 ~~~~~~~~~~~~~
+- Document how to use the tool.
 - Document the code.
-- Document how to use the tool.
 
 
 Known bugs
Index: exp-drd/drd_main.c
===================================================================
--- exp-drd/drd_main.c	(revision 7303)
+++ exp-drd/drd_main.c	(working copy)
@@ -321,13 +321,6 @@
    const DrdThreadId drd_creator = VgThreadIdToDrdThreadId(creator);
    tl_assert(created != VG_INVALID_THREADID);
    thread_pre_create(drd_creator, created);
-#if 1
-   // Hack: compensation for code missing in coregrind/m_main.c.
-   if (created == 1)
-   {
-      thread_set_running_tid(1, 1);
-   }
-#endif
    if (IsValidDrdThreadId(drd_creator))
    {
       thread_new_segment(drd_creator);
Index: coregrind/m_main.c
===================================================================
--- coregrind/m_main.c	(revision 7303)
+++ coregrind/m_main.c	(working copy)
@@ -1720,6 +1720,9 @@
 #    error Unknown OS
 #  endif
 
+   tl_assert(VG_(running_tid) == VG_INVALID_THREADID);
+   VG_(running_tid) = 1;
+
    //--------------------------------------------------------------
    // Tell aspacem of ownership change of the asm helpers, so that
    // m_translate allows them to be translated.  However, only do this
@@ -1821,6 +1824,9 @@
                True   /* executable? */ );
    }
 
+   VG_(running_tid) = VG_INVALID_THREADID;
+   tl_assert(VG_(running_tid) == VG_INVALID_THREADID);
+
    //--------------------------------------------------------------
    // Initialise the scheduler (phase 2)
    //   p: Initialise the scheduler (phase 1) [for tid_main]
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Valgrind-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-developers

Reply via email to