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: sig != GDB_SIGNAL_0 failed assertion stepping program on GNU/Linux


On 08/04/2015 07:07 PM, Joel Brobecker wrote:
> 
> Back to our program. At this point, we attempt a "next" (from thread 1),
> and here is what happens:

If the "next" is for thread 1,

> That's when we get an event from a different thread (thread 3):
> 
>     infrun: target_wait (-1.0.0, status) =
>     infrun:   28370.28378.0 [Thread 0xb7c5aba0 (LWP 28378)],
>     infrun:   status->kind = stopped, signal = GDB_SIGNAL_TRAP
>     infrun: TARGET_WAITKIND_STOPPED
>     infrun: stop_pc = 0x80782d0
>     infrun: context switch
>     infrun: Switching context from Thread 0xb7ea18c0 (LWP 28370) to Thread 0xb7c5aba0 (LWP 28378)
> 
> ... which we find to be at the address where we set a breakpoint
> on "the unwinder debug hook" (namely "_Unwind_DebugHook"). That's
> why GDB reports for this event that this is...
> 
>     infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME

Why are we getting this?  longjmp/exception/step-resume breakpoints
are thread-specific.

I'd guess that the bug is in bpstat_what:

struct bpstat_what
bpstat_what (bpstat bs_head)
{
...
	case bp_longjmp:
	case bp_longjmp_call_dummy:
	case bp_exception:
	  this_action = BPSTAT_WHAT_SET_LONGJMP_RESUME;
	  retval.is_longjmp = bptype != bp_exception;
	  break;
...

This bit is not considering "if (bs->stop)" like e.g.,
the bp_step_resume case.

I've seen something like this trigger before, and have a patch
somewhere to rewrite bpstat_what differently which fixes that.
I never managed to write a testcase for it so never submitted
it.  But, could you try the simpler approach?  Try making that:

	  if (bs->stop)
	    {
	       this_action = BPSTAT_WHAT_SET_LONGJMP_RESUME;
	       retval.is_longjmp = bptype != bp_exception;
	    }
	  else
	    this_action = BPSTAT_WHAT_SINGLE;
	  break;

Thanks,
Pedro Alves


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