From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Milan =?UTF-8?Q?Stanojevi=C4=87?= Newsgroups: gmane.emacs.bugs Subject: bug#42482: 27.0.91; emacs modules memory leak Date: Wed, 22 Jul 2020 19:25:19 -0400 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="000000000000c1150f05ab100fe0" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3184"; mail-complaints-to="usenet@ciao.gmane.io" To: 42482@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jul 23 01:27:26 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jyO90-0000iI-Ke for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 23 Jul 2020 01:27:26 +0200 Original-Received: from localhost ([::1]:48764 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jyO8z-0003OR-50 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 22 Jul 2020 19:27:25 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49200) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jyO8c-0003MC-Sh for bug-gnu-emacs@gnu.org; Wed, 22 Jul 2020 19:27:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60051) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jyO8c-00046m-JQ for bug-gnu-emacs@gnu.org; Wed, 22 Jul 2020 19:27:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jyO8c-0000u4-FZ for bug-gnu-emacs@gnu.org; Wed, 22 Jul 2020 19:27:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Milan =?UTF-8?Q?Stanojevi=C4=87?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 22 Jul 2020 23:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 42482 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.15954603653402 (code B ref -1); Wed, 22 Jul 2020 23:27:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 22 Jul 2020 23:26:05 +0000 Original-Received: from localhost ([127.0.0.1]:43364 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jyO7h-0000so-5n for submit@debbugs.gnu.org; Wed, 22 Jul 2020 19:26:05 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:35656) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jyO7e-0000sf-MW for submit@debbugs.gnu.org; Wed, 22 Jul 2020 19:26:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48894) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jyO7e-000367-ES for bug-gnu-emacs@gnu.org; Wed, 22 Jul 2020 19:26:02 -0400 Original-Received: from mxout5.mail.janestreet.com ([64.215.233.18]:52002) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jyO7b-0003bT-Qi for bug-gnu-emacs@gnu.org; Wed, 22 Jul 2020 19:26:01 -0400 X-JS-Received: from [30.40.81.8] (helo=tot-qpr-mailcore1) by mxout5.mail.janestreet.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.94) (envelope-from ) id 1jyO7a-0005Ed-Cc for bug-gnu-emacs@gnu.org; Wed, 22 Jul 2020 19:25:58 -0400 X-JS-Flow: external X-JS-Received: by tot-qpr-mailcore1 with ocaml/mailcore/main_production (a856a1269fd0) (envelope-from ) id BfGMsG-tJ-cQA-JV; 2020-07-22 19:25:58.360399-04:00 X-JS-Scanner-attachment: create_global_refs.c: not scanned (internal mail); create_global_refs_test.el: not scanned (internal mail) X-JS-Scanner-esets: Not scanned (internal mail) Original-Received: from mail-wm1-f69.google.com ([209.85.128.69]) by mxgoog2.mail.janestreet.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.94) id 1jyO7Y-0007e1-TZ for bug-gnu-emacs@gnu.org; Wed, 22 Jul 2020 19:25:57 -0400 Original-Received: by mail-wm1-f69.google.com with SMTP id v8so1181537wma.6 for ; Wed, 22 Jul 2020 16:25:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=google; h=mime-version:from:date:message-id:subject:to; bh=hkrqcp1OsKm/xvDymqnxL+hv0G6jer/AIFnTmzTsfjc=; b=iokl3FxvK9wMxh+RvjYhowga4K+6ebcdznYGm+EWBEBKsTX47p/u9gBViZHY//Vg8Z H0RJIVMD9myw6PpEZ5w9ViirFtlw/EncBMHRYX+ISGYFk/hzgRDlV4msaAtJpSXQ4TVB bFO0FHXZuD71TfMqMkXqwrVX2dpPHX2uD1Df4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=hkrqcp1OsKm/xvDymqnxL+hv0G6jer/AIFnTmzTsfjc=; b=IU33oTXDFQUDMGWCDOt45+/rAvqhHiYGI5Nq54tS5iYq769pDkIbSwIJvL8KHRJm6R t6Sht2ukNh05rz8kxT8hJgcW3Ti2jYMETW8sYjrlFebI5Koh3GWJZGUFRxiPUlyOHIWG Lr7Bt0BWzXBvfsr/iAZF0Pbr/MrXcjKT7o/Hh8MFcSoY0gXLq6dpApKpjwR95Yn4Ohwg jRpPg8+1z9gXXGYo7ZhKvSRTfBeKW9VSuBe6D8/KDFQX8NOYK8Gg8foIjXcHQOgJZwjs dIyk2RZD2jx8yj9cKU3oBb3y2o2N/0MekVGd7sdpYksYHxSsZiveAA9Mk+4Bz8sSW4RM bQTw== X-Gm-Message-State: AOAM531EFn3X83B2TjWzttybfwzLlyjEYaDpMYMXyvthxcflBH7PoNZL xG073oc55GL/rbV/xKn/TC3hye9QsxEJ+yjdMbGxSJu1opWcJHWQYKYWv8TXB3IU6jLRq5ZwalU qBmOFxqVbM4x75HFnIC4CgJFI1Ebtng== X-Received: by 2002:adf:dfc8:: with SMTP id q8mr1459224wrn.231.1595460356016; Wed, 22 Jul 2020 16:25:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWG3QV74NnMbu8A0c+q+Zf9+wUHERX7MCj9rwy7AfaqPTV4gYgsWSU7sfXsYgxUSVQ3J0Zg7CLbhIDhHDOH2M= X-Received: by 2002:adf:dfc8:: with SMTP id q8mr1459211wrn.231.1595460355673; Wed, 22 Jul 2020 16:25:55 -0700 (PDT) X-JS-Exim-Data-Received: 2020-07-22 19:25:57-0400 X-JS-Processed-by: mailcore Received-SPF: pass client-ip=64.215.233.18; envelope-from=mstanojevic@janestreet.com; helo=mxout5.mail.janestreet.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/22 19:25:58 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:183392 Archived-At: --000000000000c1150f05ab100fe0 Content-Type: text/plain; charset="UTF-8" env-make_global_ref adds a reference to the underlying Lisp_Object and allocates emacs_value from the global storage. env->free_global_ref on the other hand will only remove a reference to the underlying Lisp_Object and not free the emacs_value. Here is a simple recipe to reproduce the problem (I only tested this on linux). I'm attaching the necessary files. $ gcc -shared -fpic -std=c99 -I create_global_refs.c -o create_global_refs.so $ emacs --no-splash -q -l create_global_refs.so -l create_global_refs_test.el If you look at the memory usage of emacs (for example in htop) you'll see that with emacs-26 it is constant but with emacs-27 the resident memory quickly grows. --000000000000c1150f05ab100fe0 Content-Type: text/x-csrc; charset="US-ASCII"; name="create_global_refs.c" Content-Disposition: attachment; filename="create_global_refs.c" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_kcxzsbuv0 I2luY2x1ZGUgPHN0cmluZy5oPgojaW5jbHVkZSA8ZW1hY3MtbW9kdWxlLmg+CgppbnQgcGx1Z2lu X2lzX0dQTF9jb21wYXRpYmxlOwoKc3RhdGljIGVtYWNzX3ZhbHVlIGNyZWF0ZV9sb29wIChlbWFj c19lbnYgKmVudiwgcHRyZGlmZl90IF9uYXJncywgZW1hY3NfdmFsdWUgX2FyZ3NbXSwgdm9pZCog X2RhdGEpCnsKICBmb3IgKGludCBpID0gMDsgaSA8IDEwMDAwMDA7IGkrKykKICAgIGVudi0+ZnJl ZV9nbG9iYWxfcmVmCiAgICAgIChlbnYsCiA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c1150f05ab100fe0 Content-Type: text/x-emacs-lisp; charset="US-ASCII"; name="create_global_refs_test.el" Content-Disposition: attachment; filename="create_global_refs_test.el" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_kcxzsizl1 KHJlcXVpcmUgJ2NyZWF0ZS1nbG9iYWwtcmVmcykKCihkZWZ1biBydW4tb25lLWl0ZXJhdGlvbi1h bmQtZ2MgKCkKICAoY3JlYXRlLXJlZnMtbG9vcCkKICAoZ2FyYmFnZS1jb2xsZWN0KSkKCihzd2l0 Y2gtdG8tYnVmZmVyIChnZXQtYnVmZmVyLWNyZWF0ZSAiKk1lc3NhZ2VzKiIpKQoKKHJ1bi13aXRo LXRpbWVyIDAuMSAxICdydW4tb25lLWl0ZXJhdGlvbi1hbmQtZ2MpCg== --000000000000c1150f05ab100fe0--