From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jess Balint Newsgroups: gmane.emacs.bugs Subject: bug#22737: 25.1; Finalizer should be optional in dynamic modules Date: Tue, 23 Feb 2016 16:47:12 -0600 Message-ID: References: <87a8mxsn2g.fsf@oracle.com> <83lh6hrqm4.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=94eb2c06b69cec431c052c77ba3e X-Trace: ger.gmane.org 1456267703 21175 80.91.229.3 (23 Feb 2016 22:48:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 23 Feb 2016 22:48:23 +0000 (UTC) Cc: 22737@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Feb 23 23:48:17 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aYLke-0002Mb-SH for geb-bug-gnu-emacs@m.gmane.org; Tue, 23 Feb 2016 23:48:17 +0100 Original-Received: from localhost ([::1]:60371 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYLke-00069X-53 for geb-bug-gnu-emacs@m.gmane.org; Tue, 23 Feb 2016 17:48:16 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47383) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYLkZ-00069D-Kw for bug-gnu-emacs@gnu.org; Tue, 23 Feb 2016 17:48:12 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aYLkW-0000Vn-Bt for bug-gnu-emacs@gnu.org; Tue, 23 Feb 2016 17:48:11 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:44627) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYLkW-0000Vj-8H for bug-gnu-emacs@gnu.org; Tue, 23 Feb 2016 17:48:08 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1aYLkP-0004Ji-IY for bug-gnu-emacs@gnu.org; Tue, 23 Feb 2016 17:48:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Jess Balint Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 23 Feb 2016 22:48:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22737 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 22737-submit@debbugs.gnu.org id=B22737.145626764016534 (code B ref 22737); Tue, 23 Feb 2016 22:48:01 +0000 Original-Received: (at 22737) by debbugs.gnu.org; 23 Feb 2016 22:47:20 +0000 Original-Received: from localhost ([127.0.0.1]:41754 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aYLjk-0004Ic-3T for submit@debbugs.gnu.org; Tue, 23 Feb 2016 17:47:20 -0500 Original-Received: from mail-io0-f174.google.com ([209.85.223.174]:36039) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aYLjh-0004IO-Tp for 22737@debbugs.gnu.org; Tue, 23 Feb 2016 17:47:18 -0500 Original-Received: by mail-io0-f174.google.com with SMTP id l127so5766811iof.3 for <22737@debbugs.gnu.org>; Tue, 23 Feb 2016 14:47:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=D2o9Im5OiCGGlm498cTQYd5ZH7itTh4HI5XkwHO4Fi4=; b=JsD/65IJsjzgcMhFQo6Q5IbsDgutZZ+KAAgWSqekoJIUD+k4e0zLmOBGoiUymZysxi ARmUQo2i1RUUMkNv26ZXU0ruqyxwBqw3RIFNFcuQiiTlpAQhrsChN8FSBm5jiB6lZSsN 7C0/JY7pdzTcrL/rgwaE07Lbgxurz/FLoPgV7wV058sUDBTsxi2Z3+jK3rJfxtKNL3rZ 2lCvbMY5Fnm34V2e+gs6c4J7oTrIXnsS0ne53+YiIDcOltkLAtvqZFKwCOHx7ty7cFRP Q22nB3aUO0OspQGe2EVu/68miPRPwvIh3VdHRGFoGuYDw8CfUnWqYJhWPChQLa3VKJNq 8Kcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=D2o9Im5OiCGGlm498cTQYd5ZH7itTh4HI5XkwHO4Fi4=; b=Rm7aRDfYUBIt9ulaQy1yBTzGXnTeZ1xBL2qSVKxJkEWIl9fWUdjBbL4lBEdSbbEGUa ePMoj527Z4zdWsv/0O9H3LLtJqtxZt13QipAewGAn+zY2DAD9qFFXHOOkyh4G9yynm7y 5ru9vScobYubv2jttXPJ14LCrzXDapA1lV8Q2uxk36xeJ44FQ9/BfD+lxNXF2kviNAax B/Q0gpvnYJIRNGjpdTXtnryq9zDGQhztrslm9v2nhJWtxGZIZdP1qW9KdmNnHeRkrMhZ e9SNJp2hQdIDY4B9Aq51+dru6UvBw56hhhJisK4An33o/ilC2hSkNeQn2vAhPQ4l+3rx deQA== X-Gm-Message-State: AG10YOTXWN4t7t+yG47hhteBY5zB7vmvwnrzVirVsqjfI4pbj6PnZ547vkfvnUl6uCFKkEdmbikrvw3Bs1ruig== X-Received: by 10.107.63.2 with SMTP id m2mr41415541ioa.7.1456267632320; Tue, 23 Feb 2016 14:47:12 -0800 (PST) Original-Received: by 10.64.223.105 with HTTP; Tue, 23 Feb 2016 14:47:12 -0800 (PST) In-Reply-To: <83lh6hrqm4.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:113616 Archived-At: --94eb2c06b69cec431c052c77ba3e Content-Type: text/plain; charset=UTF-8 If the data is unspecified it doesn't *necessarily* need to be freed. If I return a pointer to some global data then I need to create a no-op finalizer just to please this GC code. In some cases I will be managing memory a bit more manually and don't care to have Emacs doing anything for me. Thx. Jess On Fri, Feb 19, 2016 at 3:33 AM, Eli Zaretskii wrote: > > From: Jess Balint > > Date: Thu, 18 Feb 2016 15:52:55 -0600 > > > > Dynamic modules are really cool so far, but I think finalizers should > > not be mandatory for user pointers (alloc.c): > > > > #ifdef HAVE_MODULES > > else if (mblk->markers[i].m.u_any.type == Lisp_Misc_User_Ptr) > > { > > struct Lisp_User_Ptr *uptr = > &mblk->markers[i].m.u_user_ptr; > > uptr->finalizer (uptr->p); <----- should NULL-check first > > } > > #endif > > > > c.f. https://github.com/emacs-mirror/emacs/blob/master/src/alloc.c#L6893 > > Can you tell more about the use case where you needed this change? A > user-pointer holds a pointer to some unspecified data, and that data > needs to be free'd when the user-pointer object is GC'ed; failure to > do so will cause memory leaks. When is the above incorrect, or gets > in your way? > > Thanks. > --94eb2c06b69cec431c052c77ba3e Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
If the data is unspecified it doesn't *necessarily* ne= ed to be freed. If I return a pointer to some global data then I need to cr= eate a no-op finalizer just to please this GC code. In some cases I will be= managing memory a bit more manually and don't care to have Emacs doing= anything for me.

Thx.

Jess

On Fri, Feb 19, 2016= at 3:33 AM, Eli Zaretskii <eliz@gnu.org> wrote:
> From: Jess Balint <jbalint@gmail.com>
> Date: Thu, 18 Feb 2016 15:52:55 -0600
>
> Dynamic modules are really cool so far, but I think finalizers should<= br> > not be mandatory for user pointers (alloc.c):
>
> #ifdef HAVE_MODULES
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0else if (mblk->marke= rs[i].m.u_any.type =3D=3D Lisp_Misc_User_Ptr)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0struct Li= sp_User_Ptr *uptr =3D &mblk->markers[i].m.u_user_ptr;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0uptr->= finalizer (uptr->p); <----- should NULL-check first
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
> #endif
>
> c.f. https://github.com/emac= s-mirror/emacs/blob/master/src/alloc.c#L6893

Can you tell more about the use case where you needed this change?=C2=A0 A<= br> user-pointer holds a pointer to some unspecified data, and that data
needs to be free'd when the user-pointer object is GC'ed; failure t= o
do so will cause memory leaks.=C2=A0 When is the above incorrect, or gets in your way?

Thanks.

--94eb2c06b69cec431c052c77ba3e--