Bug 362009

Summary: Valgrind dumps core on unimplemented functionality before threads are created
Product: [Developer tools] valgrind Reporter: Ivo Raisr <ivosh>
Component: generalAssignee: Ivo Raisr <ivosh>
Status: RESOLVED FIXED    
Severity: minor CC: ivosh, philippe.waroquiers
Priority: NOR    
Version: 3.12 SVN   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Solaris   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: proposed patch
proposed patch v2

Description Ivo Raisr 2016-04-20 18:05:24 UTC
If VG_(unimplemented)() is called early during the main initialization, before the threads are created,
Valgrind dumps core in show_sched_status_wrk().
That's because VG_(threads) is still NULL and it is dereferenced via VG_(threads)[i].os_state...

This happens for example on Solaris when VG_(unimplemented)() is called from VG_(load_ELF)() which is used during client image initialization.

Fix attached, regression testing went fine.
Comment 1 Ivo Raisr 2016-04-20 18:11:15 UTC
Created attachment 98481 [details]
proposed patch

The patch consists mainly of whitespace changes due to different indentation.
Comment 2 Philippe Waroquiers 2016-04-20 20:10:34 UTC
If show sched status is called before the threads are implemented, then nothing will be
visible.
Maybe it would be better to do something like:

   if (VG_(threads) == NULL) {
      VG_(printf) ("cannot show sched status : scheduler not yet initialised\");
      return;
  }
  ... here the old code ...
rather than report nothing ?
Comment 3 Ivo Raisr 2016-04-21 04:49:48 UTC
Created attachment 98489 [details]
proposed patch v2

Addresses Philippe's comment.
Comment 4 Ivo Raisr 2016-04-21 04:50:21 UTC
You are right, Philippe, that's very good remark.
I have attached new patch.
Comment 5 Ivo Raisr 2016-04-23 19:35:35 UTC
Fixed in SVN r15867.