This is the mail archive of the gdb-patches@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]

Re: [PATCH] Fix PR 21337 v2: segfault when re-reading symbols with remote debugging.


On 2017-04-29 13:12, Doug Gilmore wrote:
On 04/28/17 18:41, Simon Marchi wrote:
On 2017-04-28 19:44, Doug Gilmore wrote:
Hi Simon,

After thinking about it my comment and code placement wasn't
particularly good.  Something along the line's of Luis's change
is better.

Does Luis's comment address the question you have?

If so, Luis: Should is it OK we incorporate your changes in the patch?

I attached a diff for the change.

Thanks,

Doug

Hi Doug,

The comment certainly helps, but in the commit log I'd like to see a
more detailed list of events that leads to the crash.

Now that I look into it again, I think I understand.  The
objfile_pspace_info::sections array/vector is a list of obj_section
pointers (in C++ we'd probably use an std::vector<obj_section*>).
That list contains pointers to all the sections from all the
objfiles sorted in order of increasing address.  They point directly
to the sections allocated by the objfile in their obstacks (and
accessible through objfile::sections).  So when the obstack is freed
in reread_symbols, the sorted list contains stale pointers.  Is that
it?
Right.

If that's what's happening, then I'm more convinced the fix is
right.  Is this behaviour caught by a test?  If not, could you write
one?
...
I'll need to take a look.  Last time I tried I it was more difficult
to expose the problem on the native build of GDB.

reread_symbols is called when using the run (run_command_1), attach (attach_post_wait which then calls setup_inferior) and load (load_command) commands. So maybe something like this would reproduce it?

- compile test program
- launch gdb with test program
- touch test program
- run

Simon


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