unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Po Lu <luangruo@yahoo.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: larsi@gnus.org,  emacs-devel@gnu.org
Subject: Re: shr using `make-xwidget' incorrectly
Date: Thu, 11 Nov 2021 15:05:19 +0800	[thread overview]
Message-ID: <87fss3xjdc.fsf@yahoo.com> (raw)
In-Reply-To: <831r3n2n6j.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 11 Nov 2021 08:58:44 +0200")

Eli Zaretskii <eliz@gnu.org> writes:

>> Which reminds me of another problem (in the Emacs 28 xwidget code as
>> well): If an xwidget's buffer is killed, but references to it still
>> exist somewhere, crashes can happen, because the GTK resources allocated
>> to the xwidget are killed in `kill_buffer_xwidgets' and not during
>> garbage collection.
>> 
>> I think the best thing to do in this case would be to introduce a
>> `dead' state for xwidgets, not unlike killed buffers and dead frames,
>> which an xwidget is set to after being killed.
>> 
>> Then, performing any sort of operation on a killed xwidget can either
>> throw an error, or do nothing.

> Why can't we release the GTK resources when such a buffer is killed?

We are releasing the GTK resources when such a buffer is killed.  This
is the problem here: code that uses `CHECK_XWIDGET' won't catch the case
where the GTK resources are released, but there are still references to
the xwidget, which causes use-after-frees when trying to redisplay the
xwidget, or when calling, say, `xwidget-webkit-goto-uri' on the xwidget.

The comment in kill_buffer_xwidgets that says:

      /* TODO free the GTK things in xw.  */

Is probably outdated and likely should be removed.  But I am still
investigating through the history of that file to make sure of that, so
please bear with me for a while.

Thanks.



  reply	other threads:[~2021-11-11  7:05 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87sfw31mok.fsf.ref@yahoo.com>
2021-11-11  1:54 ` shr using `make-xwidget' incorrectly Po Lu
2021-11-11  3:26   ` Lars Ingebrigtsen
2021-11-11  3:38     ` Po Lu
2021-11-11  3:41       ` Lars Ingebrigtsen
2021-11-11  3:43         ` Lars Ingebrigtsen
2021-11-11  4:46         ` Po Lu
2021-11-11  4:56           ` Lars Ingebrigtsen
2021-11-11  5:10             ` Po Lu
2021-11-11 12:33               ` Lars Ingebrigtsen
2021-11-11 12:37                 ` Po Lu
2021-11-11 12:43                   ` Lars Ingebrigtsen
2021-11-11 12:47                     ` Po Lu
2021-11-11  6:37     ` Introduce "killed" state for xwidgets (Re: shr using `make-xwidget' incorrectly) Po Lu
2021-11-11  7:59       ` Eli Zaretskii
2021-11-11  9:28         ` Po Lu
2021-11-11 12:23       ` Lars Ingebrigtsen
2021-11-11 12:25         ` Po Lu
2021-11-11 15:10           ` Eli Zaretskii
2021-11-12  0:18             ` Po Lu
2021-11-11  6:58   ` shr using `make-xwidget' incorrectly Eli Zaretskii
2021-11-11  7:05     ` Po Lu [this message]
2021-11-11  8:01       ` Eli Zaretskii
2021-11-11  9:27         ` Po Lu

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=87fss3xjdc.fsf@yahoo.com \
    --to=luangruo@yahoo.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=larsi@gnus.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).