Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Doug Evans <dje@google.com>
Cc: Philippe Waroquiers <philippe.waroquiers@skynet.be>,
	       gdb-patches <gdb-patches@sourceware.org>
Subject: Re: RFA: fix gdb_assert caused by 'catch signal ...' and fork
Date: Fri, 10 May 2013 17:18:00 -0000	[thread overview]
Message-ID: <518D2BF4.6090401@redhat.com> (raw)
In-Reply-To: <CADPb22TKv1ohVo751c3YD0oD2YakVtRvM9kcT32-8QUZmtzvwg@mail.gmail.com>

On 05/10/2013 05:39 PM, Doug Evans wrote:
> On Thu, May 9, 2013 at 2:56 PM, Philippe Waroquiers
> <philippe.waroquiers@skynet.be> wrote:
>> The attached patch fixes a gdb_assert caused by the combination of catch
>> signal and fork:
>>   break-catch-sig.c:152: internal-error: signal_catchpoint_remove_location: Assertion `signal_catch_counts[iter] > 0' failed.
>>
>> The problem is that the signal_catch_counts is decremented by detach_breakpoints.
>> The fix consists in not detaching breakpoint locations of type bp_loc_other.
>> The patch introduces a new test.
>>
>> Ok to commit ?
>>
>> Index: gdb/ChangeLog
>> ===================================================================
>> RCS file: /cvs/src/src/gdb/ChangeLog,v
>> retrieving revision 1.15539
>> diff -u -p -r1.15539 ChangeLog
>> --- gdb/ChangeLog       9 May 2013 18:03:27 -0000       1.15539
>> +++ gdb/ChangeLog       9 May 2013 21:46:32 -0000
>> @@ -1,3 +1,8 @@
>> +2013-05-09  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
>> +
>> +       * breakpoints.c (detach_breakpoints): Do not
>> +       detach breakpoints locations with loc_type bp_loc_other.
>> +
>>  2013-05-09  Doug Evans  <dje@google.com>
>>
>>         * symfile.c (syms_from_objfile_1): Delete args offsets, num_offsets.
>> Index: gdb/breakpoint.c
>> ===================================================================
>> RCS file: /cvs/src/src/gdb/breakpoint.c,v
>> retrieving revision 1.761
>> diff -u -p -r1.761 breakpoint.c
>> --- gdb/breakpoint.c    7 May 2013 17:04:28 -0000       1.761
>> +++ gdb/breakpoint.c    9 May 2013 21:46:33 -0000
>> @@ -3537,6 +3537,9 @@ detach_breakpoints (ptid_t ptid)
>>      if (bl->pspace != inf->pspace)
>>        continue;
>>
>> +    if (bl->loc_type == bp_loc_other)
>> +      continue;
>> +
>>      if (bl->inserted)
>>        val |= remove_breakpoint_1 (bl, mark_inserted);
>>    }
> 
> I think a comment is required here explaining *why* we continue for
> bp_loc_other.
> [Assuming the patch is correct ...]
> 
> However, there's nothing in "bp_loc_other" that says we should always
> continue there.
> Other breakpoint kinds are marked bp_loc_other too.

The other breakpoint kinds (software watchpoints, catchpoints,
tracepoints) don't require detaching.  The state of bp_loc_other
breakpoints, at least at present, is always on the GDB side.
Detaching is required for those breakpoints that is assumed
get auto-cloned by the target/kernel to forked children.

> Plus avoiding calling remove_breakpoint_1 feels like working around the problem.
> This doesn't feel like the right fix.

GDB doesn't have an inferior or any other state corresponding
to the process whose breakpoints are being detached.

An alternative I imagine would be something like adding
"detach breakpoint" target methods (and bl->owner->ops->detach_location,
etc.) and call that instead of remove_breakpoint_1, though it
seems like we'd get the same result (with the present state).  But
I won't object to trying that.

-- 
Pedro Alves


  reply	other threads:[~2013-05-10 17:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-09 21:56 Philippe Waroquiers
2013-05-10 16:39 ` Doug Evans
2013-05-10 17:18   ` Pedro Alves [this message]
2013-05-10 22:14     ` Philippe Waroquiers
2013-05-11  9:10       ` Pedro Alves
2013-05-10 17:20 ` Pedro Alves
2013-05-16 20:30   ` Philippe Waroquiers
2013-05-17 18:18     ` Pedro Alves
2013-05-21 18:49       ` Philippe Waroquiers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=518D2BF4.6090401@redhat.com \
    --to=palves@redhat.com \
    --cc=dje@google.com \
    --cc=gdb-patches@sourceware.org \
    --cc=philippe.waroquiers@skynet.be \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox