unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Keith David Bershatsky <esq@lawlist.com>
To: Emacs Devel <emacs-devel@gnu.org>
Subject: Debugging printing to stderr prior glyph row values ....
Date: Wed, 22 May 2019 21:14:01 -0700	[thread overview]
Message-ID: <m2woihzu2e.wl%esq@lawlist.com> (raw)

I am working on feature requests 22873 (multiple fake cursors) and 17684 (crosshairs that track the cursor position).

I am having trouble preventing Emacs from occasionally crashing when printing messages to stderr while update_window is occurring, which makes debugging other issues more difficult than necessary.

update_window processes one glyph row at a time using the w->desired_matrix; and, feature requests 22873/17684 use both the desired/current matrices.

My best guess is that the problem lies here:

(gdb) print previous_row__last_glyph
$9 = (struct glyph *) 0x11f7fffb0

(gdb) print previous_row__last_glyph->charpos
Cannot access memory at address 0x11f7fffd0

Some suggestions regarding how to prevent Emacs from crashing would be greatly appreciated.  A full bt of frame 0 follows at the end of this post.

  struct glyph *previous_row__penultimate_glyph
    = (vpos == 0)
        ? NULL
      : (!(row - 1)->enabled_p)
        ? NULL
      : ((row - 1)->used[TEXT_AREA] > 1)
        ? (row - 1)->glyphs[TEXT_AREA] + (row - 1)->used[TEXT_AREA] - 2
      : NULL;

  struct glyph *previous_row__last_glyph
    = (vpos == 0)
        ? NULL
      : (!(row - 1)->enabled_p)
        ? NULL
      : (row - 1)->glyphs[TEXT_AREA] + (row - 1)->used[TEXT_AREA] - 1;

  struct glyph *penultimate_glyph
    = (row->used[TEXT_AREA] < 1)
      ? row->glyphs[TEXT_AREA] + row->used[TEXT_AREA] - 2
      : NULL;

  struct glyph *last_glyph
    = row->glyphs[TEXT_AREA] + row->used[TEXT_AREA] - 1;

  fprintf (stderr, "\nA.  vpos (%d) | glyph->charpos (%d) | posint (%d) | mc_zv (%d) | mc_zv_byte (%d)\n\
  row - 1:  penultimate_charpos (%d) | last_charpos (%d) | ends_at_zv_p (%s)\n\
  row - 1:  start/end_bytepos (%d/%d) | start/end_charpos (%d/%d)\n\
  row_at_zv_p (%s) | row_beyond_zv_p (%s)\n\
  row:  penultimate_charpos (%d) | last_charpos (%d) | ends_at_zv_p (%s)\n\
  row:  start/end_bytepos (%d/%d) | start/end_charpos (%d/%d)\n",
    vpos, start->charpos, posint, mc_zv, mc_zv_byte,
    previous_row__penultimate_glyph != NULL
      ? previous_row__penultimate_glyph->charpos
      : -1,
    previous_row__last_glyph != NULL
      ? previous_row__last_glyph->charpos
      : -1,
      (row - 1)->ends_at_zv_p ? "y" : "n",
    MATRIX_ROW_START_BYTEPOS (row - 1), MATRIX_ROW_END_BYTEPOS (row - 1),
      MATRIX_ROW_START_CHARPOS (row - 1), MATRIX_ROW_END_CHARPOS (row - 1),
    row_at_zv_p ? "y" : "n", row_beyond_zv_p ? "y" : "n",
    penultimate_glyph != NULL
      ? penultimate_glyph->charpos
      : -1,
    last_glyph->charpos, row->ends_at_zv_p ? "y" : "n",
    MATRIX_ROW_START_BYTEPOS (row), MATRIX_ROW_END_BYTEPOS (row),
      MATRIX_ROW_START_CHARPOS (row), MATRIX_ROW_END_CHARPOS (row));

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(gdb) print previous_row__penultimate_glyph
$8 = (struct glyph *) 0x0

(gdb) print previous_row__last_glyph
$9 = (struct glyph *) 0x11f7fffb0

(gdb) print previous_row__last_glyph->charpos
Cannot access memory at address 0x11f7fffd0

(gdb) print *previous_row__last_glyph
Cannot access memory at address 0x11f7fffb0

(gdb) print last_glyph
$10 = (struct glyph *) 0x11fa46200

(gdb) print last_glyph->charpos
$11 = -1

(gdb) print penultimate_glyph
$12 = (struct glyph *) 0x0

(gdb) bt full

#0  0x0000000100045d1b in mc_draw_row (w=0x1088ef048, matrix=0x106ddb0a0, 
    row=0x11d1b2e00, start=0x11fa46200, x=0, hpos_length=1, vpos=8, 
    bottom_vpos=113, active_p=true, cursor_matrix=0x106be6580, fc_x=770, 
    ch_foreground=..., fc_foreground=..., mc_zv=16, mc_zv_byte=16, 
    draw_p=true, from_where=SCRIBE_ONE) at xdisp.c:4604
        hpos = 0
        previous_glyph = 0x0
        skip_p = false
        posint = -1
        specs = {
          i = 0
        }
        hpos_start = 0
        window = {
          i = 4438552653
        }
        f = 0x10388f1a0
        buf = {
          i = 4354225669
        }
        b = 0x103883600
        opoint_fx = 1
        opoint_fy = 143585352
        opoint_wd = 1
        opoint_h = 488320512
        text_area_width = 975
        header_line_format = 24
        previous_row__penultimate_glyph = 0x0
        previous_row__last_glyph = 0x11f7fffb0
        penultimate_glyph = 0x0
        last_glyph = 0x11fa46200
        row_at_zv_p = false
        row_beyond_zv_p = true
        cursor_row = 0x11fa17100
        cursor_glyph = 0x11fa236b0
        cursor_at_fringe_p = false
        cursor_beyond_fringe_p = false
        bg_face_id = DEFAULT_FACE_ID
        cursor_bg = {
          red = 0, 
          green = 0, 
          blue = 0
        }
        lisp_type = {
          i = 24336
        }
        cursor_type = MC_HOLLOW_BOX
        cursor_width = -1
        cursor_face_id = 36
        cursor_face = 0x100f0fc30
        cursor_color = {
          i = 4299532436
        }
        cursor_fg = {
          red = 0, 
          green = 1, 
          blue = 1
        }
        fill_column_trumps_p = false



             reply	other threads:[~2019-05-23  4:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-23  4:14 Keith David Bershatsky [this message]
2019-05-23 14:43 ` Debugging printing to stderr prior glyph row values Eli Zaretskii
  -- strict thread matches above, loose matches on Subject: below --
2019-05-23 17:23 Keith David Bershatsky
2019-05-23 18:38 ` Eli Zaretskii
2019-05-23 22:01 Keith David Bershatsky
2019-05-24  0:03 Keith David Bershatsky
2019-05-24  6:45 ` Eli Zaretskii
2019-05-24 14:56 Keith David Bershatsky

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=m2woihzu2e.wl%esq@lawlist.com \
    --to=esq@lawlist.com \
    --cc=emacs-devel@gnu.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).