public inbox for gdb-testers@sourceware.org
help / color / mirror / Atom feed
From: gdb-buildbot@sergiodj.net
To: gdb-testers@sourceware.org
Subject: [binutils-gdb] libctf: fix refcount leak in ctf_import
Date: Thu, 10 Oct 2019 07:01:00 -0000	[thread overview]
Message-ID: <ad613f1d0693e02bdc86047c479315d5f969e2f7@gdb-build> (raw)

*** TEST RESULTS FOR COMMIT ad613f1d0693e02bdc86047c479315d5f969e2f7 ***

commit ad613f1d0693e02bdc86047c479315d5f969e2f7
Author:     Nick Alcock <nick.alcock@oracle.com>
AuthorDate: Tue Sep 17 06:59:31 2019 +0100
Commit:     Nick Alcock <nick.alcock@oracle.com>
CommitDate: Thu Oct 3 17:04:56 2019 +0100

    libctf: fix refcount leak in ctf_import
    
    Calling ctf_import (fp, NULL) to cancel out a pre-existing import leaked
    the refcnt increment on the parent, so it could never be freed.
    
    New in v4.
    
    libctf/
            * ctf-open.c (ctf_import): Do not leak a ctf_file_t ref on every
            ctf_import after the first for a given file.

diff --git a/libctf/ChangeLog b/libctf/ChangeLog
index b7f12d8e09..982c335569 100644
--- a/libctf/ChangeLog
+++ b/libctf/ChangeLog
@@ -1,3 +1,8 @@
+2019-09-23  Nick Alcock  <nick.alcock@oracle.com>
+
+	* ctf-open.c (ctf_import): Do not leak a ctf_file_t ref on every
+	ctf_import after the first for a given file.
+
 2019-09-23  Nick Alcock  <nick.alcock@oracle.com>
 
 	* ctf-impl.h (ctf_str_append_noerr): Declare.
diff --git a/libctf/ctf-open.c b/libctf/ctf-open.c
index 4a95b7f38a..aedf39086a 100644
--- a/libctf/ctf-open.c
+++ b/libctf/ctf-open.c
@@ -1778,6 +1778,7 @@ ctf_import (ctf_file_t *fp, ctf_file_t *pfp)
 
   if (fp->ctf_parent != NULL)
     {
+      fp->ctf_parent->ctf_refcnt--;
       ctf_file_close (fp->ctf_parent);
       fp->ctf_parent = NULL;
     }
@@ -1793,6 +1794,7 @@ ctf_import (ctf_file_t *fp, ctf_file_t *pfp)
       fp->ctf_flags |= LCTF_CHILD;
       pfp->ctf_refcnt++;
     }
+
   fp->ctf_parent = pfp;
   return 0;
 }


             reply	other threads:[~2019-10-10  7:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-10  7:01 gdb-buildbot [this message]
2019-10-10  7:01 ` Failures on Ubuntu-Aarch64-m64, branch master gdb-buildbot
2019-10-10  8:31 ` Failures on Ubuntu-Aarch64-native-extended-gdbserver-m64, " gdb-buildbot
2019-10-10  9:13 ` Failures on Ubuntu-Aarch64-native-gdbserver-m64, " gdb-buildbot
2019-10-13  2:05 ` Failures on Fedora-x86_64-m32, " gdb-buildbot
2019-10-13  2:32 ` Failures on Fedora-x86_64-m64, " gdb-buildbot
2019-10-13  2:59 ` Failures on Fedora-x86_64-native-extended-gdbserver-m32, " gdb-buildbot
2019-10-13  3:30 ` Failures on Fedora-x86_64-native-extended-gdbserver-m64, " gdb-buildbot
2019-10-13  3:44 ` Failures on Fedora-x86_64-native-gdbserver-m32, " gdb-buildbot
2019-10-13  4:20 ` Failures on Fedora-x86_64-native-gdbserver-m64, " gdb-buildbot

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

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

  git send-email \
    --in-reply-to=ad613f1d0693e02bdc86047c479315d5f969e2f7@gdb-build \
    --to=gdb-buildbot@sergiodj.net \
    --cc=gdb-testers@sourceware.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.
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).