Bug 362009 - Valgrind dumps core on unimplemented functionality before threads are created
Summary: Valgrind dumps core on unimplemented functionality before threads are created
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: 3.12 SVN
Platform: Compiled Sources Solaris
: NOR minor
Target Milestone: ---
Assignee: Ivo Raisr
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-20 18:05 UTC by Ivo Raisr
Modified: 2016-04-23 19:35 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
proposed patch (5.79 KB, patch)
2016-04-20 18:11 UTC, Ivo Raisr
Details
proposed patch v2 (5.73 KB, patch)
2016-04-21 04:49 UTC, Ivo Raisr
Details

Note You need to log in before you can comment on or make changes to this bug.
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.