Memory leak

Bug #2012978 reported by Vladimir
20
This bug affects 2 people
Affects Status Importance Assigned to Milestone
gjs (Ubuntu)
Fix Released
High
Marco Trevisan (Treviño)
Jammy
Fix Released
High
Marco Trevisan (Treviño)
Kinetic
Won't Fix
High
Unassigned

Bug Description

[ Impact ]

High Memory Usage 3.1gb in 2h after reboot

[ Test case ]

Run:
  env G_SLICE=always-malloc valgrind --leak-check=full \
    --suppressions=/usr/share/glib-2.0/valgrind/glib.supp \
    gjs -c "const GLib=imports.gi['GLib'];function leak(){const l=GLib.Variant['new']('i',1)};leak();imports.system.gc();"

No leak should be detected

Running more installed tests under valgrind should output no leaks (unless those caused by gobject-introspection):

sudo apt install gjs-tests
env GJS_DEBUG_TOPICS= valgrind --leak-check=full \
  --suppressions=/usr/share/glib-2.0/valgrind/glib.supp \
  /usr/libexec/installed-tests/gjs/minijasmine \
  /usr/libexec/installed-tests/gjs/js/testGIMarshalling.js

There may be only two leaks caused by gi_marshalling_tests_garray_boxed_struct_full_return and a gbytes one after a ObjectInstance::prop_setter_impl call (these are leaks in the test library that are expected with gobject-introspection 42, but fixed in later versions).

env GJS_DEBUG_TOPICS= valgrind --leak-check=full \
  --suppressions=/usr/share/glib-2.0/valgrind/glib.supp \
  /usr/libexec/installed-tests/gjs/minijasmine \
  /usr/libexec/installed-tests/gjs/js/testRegress.js

No leak expected

[ Regression potential ]

Gjs applications (including gnome Shell) using GVariant may misbehave

---

ProblemType: BugDistroRelease: Ubuntu 22.04
Package: gnome-shell 42.5-0ubuntu1
Uname: Linux 6.2.8-060208-generic x86_64
ApportVersion: 2.20.11-0ubuntu82.3
Architecture: amd64
CasperMD5CheckResult: unknown
CurrentDesktop: ubuntu:GNOME
Date: Mon Mar 27 22:46:07 2023
DisplayManager: gdm3
InstallationDate: Installed on 2022-03-25 (366 days ago)
InstallationMedia: Ubuntu 20.04.4 LTS "Focal Fossa" - Release amd64 (20220223)
RelatedPackageVersions: mutter-common 42.5-0ubuntu1SourcePackage: gnome-shell
UpgradeStatus: Upgraded to jammy on 2022-09-03 (205 days ago)

Revision history for this message
Vladimir (zimkaru) wrote :
Revision history for this message
Vladimir (zimkaru) wrote :

the cmd:
gnome-extensions list --enabled

shows:
<email address hidden>
<email address hidden>
<email address hidden>

disabling extensions does not make effects

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Thanks for the bug report.

When the problem is happening next, please run:

  ps auxw | grep gnome-shell > psgs.txt

and attach the resulting text file here.

tags: added: gnome-shell-leak
Changed in gnome-shell (Ubuntu):
status: New → Incomplete
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Also it looks like you are experiencing bug 1988791.

affects: gnome-shell (Ubuntu) → gjs (Ubuntu)
Changed in gjs (Ubuntu):
status: Incomplete → In Progress
importance: Undecided → High
assignee: nobody → Marco Trevisan (Treviño) (3v1n0)
Changed in gjs (Ubuntu Jammy):
importance: Undecided → High
status: New → Triaged
Changed in gjs (Ubuntu):
status: In Progress → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package gjs - 1.76.0-3

---------------
gjs (1.76.0-3) experimental; urgency=medium

  * debian/patches: Drop patch causing GNOME Characters not to show emojis
    (LP: #2015948)

gjs (1.76.0-2) experimental; urgency=medium

  [ Daniel van Vugt ]
  * Add context-Clear-all-vectors-of-JS-Heap-on-dispose.patch (LP: #1974293)

  [ Marco Trevisan (Treviño) ]
  * debian/patches: Do not leak GVariants and other handled objects
    (LP: #1991709, #2012978)

 -- Marco Trevisan (Treviño) <email address hidden> Wed, 12 Apr 2023 05:40:15 +0200

Changed in gjs (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
Roman Shipovskij (roman-shipovskij) wrote :

What about 22.04 LTS? This bug fixed for 23.04 but not for 22.04.

Revision history for this message
Daniel van Vugt (vanvugt) wrote (last edit ):

I'm not sure this generic leak bug should have been declared fixed in the absence of additional information. Maybe Marco knew what it was from the repeating log message:

  <email address hidden>[3923]: unable to update icon for multiload

If you experience any other problems (including leaks) then please open new bugs of your own. Don't assume existing bugs that sound similar to your experience are the same issue.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote (last edit ):

Gjs was definitely leak from 22.04 any GVariant, so that will be backported to jammy too but it requires some more testing in interim release first.

description: updated
Jeremy Bícha (jbicha)
Changed in gjs (Ubuntu Kinetic):
status: New → Triaged
importance: Undecided → High
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :
Download full text (4.2 KiB)

Currently we're getting

❯ env G_SLICE=always-malloc valgrind --leak-check=full --suppressions=/usr/share/glib-2.0/valgrind/glib.supp gjs -c "const GLib=imports.gi['GLib'];function leak(){const l=GLib.Variant['new']('i',1)};leak();imports.system.gc();"
==131398== Memcheck, a memory error detector
==131398== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==131398== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==131398== Command: gjs -c const\ GLib=imports.gi['GLib'];function\ leak(){const\ l=GLib.Variant['new']('i',1)};leak();imports.system.gc();
==131398==
==131398== Warning: set address range perms: large range [0x1663bc3af000, 0x16643bfaf000) (noaccess)
==131398== Warning: set address range perms: large range [0x1663bc3af000, 0x16643bfaf000) (noaccess)
==131398==
==131398== HEAP SUMMARY:
==131398== in use at exit: 191,779 bytes in 2,483 blocks
==131398== total heap usage: 18,733 allocs, 16,250 frees, 8,376,620 bytes allocated
==131398==
==131398== 108 (64 direct, 44 indirect) bytes in 1 blocks are definitely lost in loss record 1,885 of 2,041
==131398== at 0x4844899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==131398== by 0x4A22948: g_malloc (gmem.c:130)
==131398== by 0x4A6598F: UnknownInlinedFun (gvariant-core.c:565)
==131398== by 0x4A6598F: g_variant_new_from_bytes (gvariant-core.c:608)
==131398== by 0x4A65EF3: UnknownInlinedFun (gvariant.c:327)
==131398== by 0x4A65EF3: g_variant_new_int32 (gvariant.c:491)
==131398== by 0x51B8E2D: ??? (in /usr/lib/x86_64-linux-gnu/libffi.so.8.1.0)
==131398== by 0x51B5492: ??? (in /usr/lib/x86_64-linux-gnu/libffi.so.8.1.0)
==131398== by 0x48C8198: ??? (in /usr/lib/x86_64-linux-gnu/libgjs.so.0.0.0)
==131398== by 0x48C8A06: ??? (in /usr/lib/x86_64-linux-gnu/libgjs.so.0.0.0)
==131398== by 0x532FC81: js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct, js::CallReason) (Interpreter.cpp:420)
==131398== by 0x533A46B: UnknownInlinedFun (Interpreter.cpp:574)
==131398== by 0x533A46B: UnknownInlinedFun (Interpreter.cpp:578)
==131398== by 0x533A46B: Interpret(JSContext*, js::RunState&) [clone .lto_priv.0] (Interpreter.cpp:3314)
==131398== by 0x532F692: js::RunScript(JSContext*, js::RunState&) (Interpreter.cpp:389)
==131398== by 0x532FA8E: js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct, js::CallReason) (Interpreter.cpp:539)
==131398==
==131398== 352 bytes in 1 blocks are possibly lost in loss record 1,999 of 2,041
==131398== at 0x4849A83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==131398== by 0x4012949: calloc (rtld-malloc.h:44)
==131398== by 0x4012949: allocate_dtv (dl-tls.c:375)
==131398== by 0x4012949: _dl_allocate_tls (dl-tls.c:634)
==131398== by 0x5019F99: allocate_stack (allocatestack.c:423)
==131398== by 0x5019F99: pthread_create@@GLIBC_2.34 (pthread_create.c:650)
==131398== by 0x5A97B54: mozilla::TimeStamp::ComputeProcessUptime() (TimeStamp_posix.cpp:275)
==131398== by 0x5A97BE7: mozilla::TimeStamp::ProcessCreation() (TimeStamp.cpp:62)
==131398== by 0x53FD5FC: JS::detail::Init...

Read more...

Changed in gjs (Ubuntu Jammy):
assignee: nobody → Marco Trevisan (Treviño) (3v1n0)
description: updated
Changed in gjs (Ubuntu Kinetic):
status: Triaged → Won't Fix
Revision history for this message
Robie Basak (racb) wrote : Please test proposed package

Hello Vladimir, or anyone else affected,

Accepted gjs into jammy-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/gjs/1.72.4-0ubuntu0.22.04.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-jammy to verification-done-jammy. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-jammy. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in gjs (Ubuntu Jammy):
status: Triaged → Fix Committed
tags: added: verification-needed verification-needed-jammy
Revision history for this message
Ubuntu SRU Bot (ubuntu-sru-bot) wrote : Autopkgtest regression report (gjs/1.72.4-0ubuntu0.22.04.1)

All autopkgtests for the newly accepted gjs (1.72.4-0ubuntu0.22.04.1) for jammy have finished running.
The following regressions have been reported in tests triggered by the package:

gjs/1.72.4-0ubuntu0.22.04.1 (amd64)

Please visit the excuses page listed below and investigate the failures, proceeding afterwards as per the StableReleaseUpdates policy regarding autopkgtest regressions [1].

https://people.canonical.com/~ubuntu-archive/proposed-migration/jammy/update_excuses.html#gjs

[1] https://wiki.ubuntu.com/StableReleaseUpdates#Autopkgtest_Regressions

Thank you!

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :
Download full text (12.2 KiB)

❯ apt-cache policy gjs
gjs:
  Installed: 1.72.4-0ubuntu0.22.04.1
  Candidate: 1.72.4-0ubuntu0.22.04.1
  Version table:
 *** 1.72.4-0ubuntu0.22.04.1 400
        400 http://archive.ubuntu.com/ubuntu jammy-proposed/main amd64 Packages
        100 /var/lib/dpkg/status
     1.72.2-0ubuntu2 500
        500 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
     1.72.0-1 500
        500 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages

No variant leak (the other detected is a mozjs issue, but likely a wrong valgrind detection):

❯ env G_SLICE=always-malloc valgrind --leak-check=full \
    --suppressions=/usr/share/glib-2.0/valgrind/glib.supp \
    gjs -c "const GLib=imports.gi['GLib'];function leak(){const l=GLib.Variant['new']('i',1)};leak();imports.system.gc();"
==356489== Memcheck, a memory error detector
==356489== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==356489== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==356489== Command: gjs -c const\ GLib=imports.gi['GLib'];function\ leak(){const\ l=GLib.Variant['new']('i',1)};leak();imports.system.gc();
==356489==
==356489== Warning: set address range perms: large range [0x2204b34b7000, 0x2205330b7000) (noaccess)
==356489== Warning: set address range perms: large range [0x2204b34b7000, 0x2205330b7000) (noaccess)
==356489==
==356489== HEAP SUMMARY:
==356489== in use at exit: 193,115 bytes in 2,445 blocks
==356489== total heap usage: 19,931 allocs, 17,486 frees, 9,251,399 bytes allocated
==356489==
==356489== 352 bytes in 1 blocks are possibly lost in loss record 1,965 of 2,008
==356489== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==356489== by 0x40147D9: calloc (rtld-malloc.h:44)
==356489== by 0x40147D9: allocate_dtv (dl-tls.c:375)
==356489== by 0x40147D9: _dl_allocate_tls (dl-tls.c:634)
==356489== by 0x5008834: allocate_stack (allocatestack.c:430)
==356489== by 0x5008834: pthread_create@@GLIBC_2.34 (pthread_create.c:647)
==356489== by 0x5A36794: mozilla::TimeStamp::ComputeProcessUptime() (in /usr/lib/x86_64-linux-gnu/libmozjs-91.so.91.10.0)
==356489== by 0x5A36856: mozilla::TimeStamp::ProcessCreation(bool*) (in /usr/lib/x86_64-linux-gnu/libmozjs-91.so.91.10.0)
==356489== by 0x5444A7F: JS::detail::InitWithFailureDiagnostic(bool) (in /usr/lib/x86_64-linux-gnu/libmozjs-91.so.91.10.0)
==356489== by 0x48A2363: ??? (in /usr/lib/x86_64-linux-gnu/libgjs.so.0.0.0)
==356489== by 0x400647D: call_init.part.0 (dl-init.c:70)
==356489== by 0x4006567: call_init (dl-init.c:33)
==356489== by 0x4006567: _dl_init (dl-init.c:117)
==356489== by 0x40202E9: ??? (in /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
==356489== by 0x2: ???
==356489== by 0x1FFEFFFBBE: ???
==356489==
==356489== LEAK SUMMARY:
==356489== definitely lost: 0 bytes in 0 blocks
==356489== indirectly lost: 0 bytes in 0 blocks
==356489== possibly lost: 352 bytes in 1 blocks
==356489== still reachable: 77,254 bytes in 965 blocks
==356489== suppressed: 97,829 bytes in 1,292 blocks
==356489== Reachable blocks (those to which a pointer was...

tags: added: verification-done
removed: verification-needed
tags: added: verification-done-jammy
removed: verification-needed-jammy
Revision history for this message
Łukasz Zemczak (sil2100) wrote : Update Released

The verification of the Stable Release Update for gjs has completed successfully and the package is now being released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package gjs - 1.72.4-0ubuntu0.22.04.1

---------------
gjs (1.72.4-0ubuntu0.22.04.1) jammy; urgency=medium

  * New upstream stable release (LP: #2023572)
  * debian/patches: Drop, they've been all applied upstream

gjs (1.72.3-0ubuntu0.22.04.1) jammy; urgency=medium

  * New upstream release (LP: #2023572):
  * debian/patches: Refresh teardown patch, replacing it with the one landed
    upstream (LP: #1974293)
  * debian/patches: Cherry-pick upstream fixes to address various memory leaks
    (LP: #2012978)

 -- Marco Trevisan (Treviño) <email address hidden> Thu, 15 Jun 2023 17:23:40 +0200

Changed in gjs (Ubuntu Jammy):
status: Fix Committed → Fix Released
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

It was reverted from the archive. Jammy is back on 1.72.2-0ubuntu2 now.

> @sil2100: Hey! The package was phased to 0 instantly from 10% with a lot of error reports

Changed in gjs (Ubuntu Jammy):
status: Fix Released → Triaged
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package gjs - 1.72.4-0ubuntu0.22.04.1

---------------
gjs (1.72.4-0ubuntu0.22.04.1) jammy; urgency=medium

  * New upstream stable release (LP: #2023572)
  * debian/patches: Drop, they've been all applied upstream

gjs (1.72.3-0ubuntu0.22.04.1) jammy; urgency=medium

  * New upstream release (LP: #2023572):
  * debian/patches: Refresh teardown patch, replacing it with the one landed
    upstream (LP: #1974293)
  * debian/patches: Cherry-pick upstream fixes to address various memory leaks
    (LP: #2012978)

 -- Marco Trevisan (Treviño) <email address hidden> Thu, 15 Jun 2023 17:23:40 +0200

Changed in gjs (Ubuntu Jammy):
status: Triaged → Fix Released
Revision history for this message
Kira Backes (kira-backes) wrote (last edit ):

@vanvugt is this bug still supposed to be in Triaged and did the janitor erroneously move it back to Fix Released? The package is still held back on our machines (Jammy) and still on 1.72.2

The following packages have been kept back:
gjs libgjs0g
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Although jammy-updates has gjs at version 1.72.4-0ubuntu0.22.04.1, you probably won't receive it because crashes have been detected and so the rollout stopped:

  https://ubuntu-archive-team.ubuntu.com/phased-updates.html

You can still install the update files manually from:

  https://launchpad.net/ubuntu/+source/gjs/1.72.4-0ubuntu0.22.04.1/+build/26344571

Revision history for this message
Kira Backes (kira-backes) wrote (last edit ):

Thank you for the explanation, now I understand. People who freshly install Ubuntu 22.04 will get the updated package (and might get crashes). Existing Ubuntu users are protected from the crashes by the phasing system.

And this bug is actually "fix released", because the memory leaks were fixed and the patched package is now in the Ubuntu repository. (While the crashes are a new issue.)

PS: The link showing the phased update status is very handy, thanks for that as well.

PPS: In case someone searches for this in 2023. When you get the following message in apt in Ubuntu 22.04

The following packages have been kept back: gjs libgjs0g

This is the reason.

(can appear in apt upgrade, apt dist-upgrade, apt full-upgrade and probably also in apt-get and aptitude)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.