Bug 17716 - [7.7 regression] Backtrace cannot be stopped by 'q' or CTRL-C
Summary: [7.7 regression] Backtrace cannot be stopped by 'q' or CTRL-C
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: cli (show other bugs)
Version: 7.7
: P2 normal
Target Milestone: 8.2
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-15 19:21 UTC by Jan Kratochvil
Modified: 2018-03-31 12:21 UTC (History)
4 users (show)

See Also:
Host: x86_64-linux-gnu
Target: x86_64-linux-gnu
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Kratochvil 2014-12-15 19:21:11 UTC
It is a regression since frame filters have been introduced in 7.7; for some reason it regresses for me in real world only in 7.8, though.

One cannot stop backtrace by 'q' at
  ---Type <return> to continue, or q <return> to quit---
or even by CTRL-C, it always just prints:
  Python Exception <type 'exceptions.KeyboardInterrupt'>
and continue the backtrace dump.

Fedora 21 x86_64:

Make the window height a bit smaller:
stty size
15 129

184d64776bc16fcba7b00e5784e27f52854cc8dd

/home/jkratoch/redhat/gdb-clean/gdb/gdb -data-directory /home/jkratoch/redhat/gdb-clean/gdb/data-directory -iex 'set data-directory /usr/share/gdb' -ex start -ex 'b gtk_widget_draw_marshallerv' -ex c -ex bt gtk3-demo

PASS:
Breakpoint 2, gtk_widget_draw_marshallerv (closure=0x90a490, return_value=0x7fffffffcf70, instance=0xaee2a0, args=0x7fffffffd070, marshal_data=0x3348d32df0 <gtk_window_draw>, n_params=1, param_types=0x90a500) at gtkwidget.c:1087
1087    {
#0  gtk_widget_draw_marshallerv (closure=0x90a490, return_value=0x7fffffffcf70, instance=0xaee2a0, args=0x7fffffffd070, marshal_data=0x3348d32df0 <gtk_window_draw>, n_params=1, param_types=0x90a500) at gtkwidget.c:1087
#1  0x0000003c21a0ff64 in _g_closure_invoke_va (closure=closure@entry=0x90a490, return_value=return_value@entry=0x7fffffffcf70,
---Type <return> to continue, or q <return> to quit---q
iQuit
(gdb)


FAIL:
Breakpoint 2, gtk_widget_draw_marshallerv (closure=0x90a490, return_value=0x7fffffffcf70, instance=0xb26270, args=0x7fffffffd070, marshal_data=0x3348d32df0 <gtk_window_draw>, n_params=1, param_types=0x90a500) at gtkwidget.c:1087
1087    {
#0  0x0000003348d1a020 in gtk_widget_draw_marshallerv (closure=0x90a490, return_value=0x7fffffffcf70, instance=0xb26270, args=0x7fffffffd070, marshal_data=0x3348d32df0 <gtk_window_draw>, n_params=1, param_types=0x90a500) at gtkwidget.c:1087
#1  0x0000003c21a0ff64 in _g_closure_invoke_va (closure=closure@entry=0x90a490, return_value=return_value@entry=0x7fffffffcf70, i---Type <return> to continue, or q <return> to quit---q
Python Exception <type 'exceptions.KeyboardInterrupt'> Quit:
, args=args@entry=0x7fffffffd070, n_params=<optimized out>, param_types=0x90a500#2  0x0000003c21a2962b in g_signal_emit_valist (instance=0xb26270, signal_id=<optimized out>, detail=0, var_args=var_args@entry=0x7fffffffd070) at gsignal.c:3218
#3  0x0000003c21a2a3af in g_signal_emit (instance=instance@entry=0xb26270, signal_id=<optimized out>, detail=detail@entry=0) at gsignal.c:3365
#4  0x0000003348d285d6 in _gtk_widget_draw_internal (widget=widget@entry=0xb26270 [GtkApplicationWindow], cr=cr@entry=0xcada60, clip_to_size=clip_to_size@entry=1, window=window@entry=0x959360 [GdkX11Window]) at gtkwidget.c:6951
Python Exception <type 'exceptions.KeyboardInterrupt'> <type 'exceptions.KeyboardInterrupt'>:
Python Exception <type 'exceptions.KeyboardInterrupt'> :
#5  0x0000003348d29c4f in _gtk_widget_draw_windows (window=0x959360 [GdkX11Window], clip_to_size=1, cr=0xcada60, #6  0x0000003348d29c4f in _gtk_widget_draw_windows (window=window@entry=, cr=cr@entry=0xcada60, window_x=window_x@entry=0, window_y=window_y@entry=0) at gtkwidget.c:7052
#7  0x0000003348d29ecf in _gtk_widget_draw (widget=widget@entry=0xb26270 [GtkApplicationWindow], cr=cr@entry=0xcada60) at gtkwidget.c:7122


It is a pain to debug as due to the FSF GDB HEAD lacking
        [patchv2] Fix 100x slowdown regression on DWZ files
        https://sourceware.org/ml/gdb-patches/2014-10/msg00031.html
the unbreakable backtrace takes several minutes.  Killing GDB leaves runaway inferior etc.

The primary problem is that py_print_single_arg() at its end
  if (except.reason < 0)
    gdbpy_convert_exception (except);
for RETURN_QUIT still returns EXT_LANG_BT_OK.

But EXT_LANG_BT_ERROR is also not helpful as the backtrace correctly tries to recover from errors printing some parameters or frames (it was another regression before it did not recover).

I guess one should create new EXT_LANG_BT_QUIT.
Or is it just safe enough to change py_print_single_arg()'s RETURN_MASK_ALL to RETURN_MASK_ERROR?
Comment 1 Phil Muldoon 2015-01-15 09:02:16 UTC
With a regression, do you mean it has failed since the first implementation of frame filters, or a more recent change has affected it?

The three methods I would think are ok is:

1) Check the Python exception, if it is keyboard interrupt, quit.
2) Define a new constant as Jan mentions
3) Alter the exception mask as Jan mentions.

I don't think this is blocker though.  It is annoying, but I do not think it warrants blocking status
Comment 2 Jan Kratochvil 2015-01-15 09:19:06 UTC
(In reply to Phil Muldoon from comment #1)
> With a regression, do you mean it has failed since the first implementation
> of frame filters, or a more recent change has affected it?

it has failed since the first implementation of frame filters


> The three methods I would think are ok is:
> 
> 1) Check the Python exception, if it is keyboard interrupt, quit.

This does not work as there are line(s)
  TRY_CATCH (except, RETURN_MASK_ALL)
which nullify that quit() attempt.  That's the whole problem.

> 2) Define a new constant as Jan mentions
> 3) Alter the exception mask as Jan mentions.

IMO from my attempt to fix it there needs to be done some rethinking how it should behave for errors vs. quits.
Comment 3 Phil Muldoon 2015-01-15 09:31:29 UTC
The current workaround for this, is to just turn frame filters on and off when needed:

(gdb) disable frame-filter all
(gdb) bt
(gdb) enable frame-filter all

But sure, it is annoying.  I will fix soon
Comment 4 Jan Kratochvil 2015-02-07 14:46:29 UTC
[PATCH 0/6] framefilter quit: PR cli/17716
https://sourceware.org/ml/gdb-patches/2015-02/msg00168.html
Comment 5 Jan Kratochvil 2015-02-11 13:57:50 UTC
It has been partially fixed for 7.9; but more fixes are needed there:
211e7f3c26b39159df2dedd8198148cec60307f9
cf3f71d273c607ecd1e912ce9fe8121da320c6a9
5dea9fe2285fee5d53691856750a0c8960fca04d
46d020960241fcafd7d0ab483746a206829620ea
a9189a245363137825ce02a23202df45b04db179
25a0672ba8b7f4badc682eaf08a1e342b496b483
Comment 6 Sourceware Commits 2018-03-27 04:06:24 UTC
The master branch has been updated by Tom Tromey <tromey@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=92256134f3e5557dcc321c63c48e8175ea90ca27

commit 92256134f3e5557dcc321c63c48e8175ea90ca27
Author: Tom Tromey <tom@tromey.com>
Date:   Mon Apr 24 20:59:37 2017 -0600

    Allow C-c to work in backtrace in more cases
    
    PR cli/17716 notes that it is difficult to C-c (or "q" at a pagination
    prompt) while backtracing using a frame filter.  One reason for this
    is that many places in py-framefilter.c use RETURN_MASK_ALL in a
    try/catch.
    
    This patch changes these spots to use RETURN_MASK_ERROR instead.  This
    is safe to do because this entire file is exception safe now.
    
    gdb/ChangeLog
    2018-03-26  Tom Tromey  <tom@tromey.com>
    
    	PR cli/17716:
    	* python/py-framefilter.c (py_print_type, py_print_value)
    	(enumerate_args, py_print_args, gdbpy_apply_frame_filter): Use
    	RETURN_MASK_ERROR.
Comment 7 Tom Tromey 2018-03-27 04:08:49 UTC
Fixed.

Not sure if that other series had anything that's still needed though.