Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 701470 - app-portage/portage-utils-0.82: qsearch: free(): invalid pointer
Summary: app-portage/portage-utils-0.82: qsearch: free(): invalid pointer
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Tools (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Fabian Groffen
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-11-29 10:28 UTC by Guilherme Amadio
Modified: 2020-03-08 08:00 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Guilherme Amadio gentoo-dev 2019-11-29 10:28:51 UTC
gentoo-prefix ~ $ qsearch -S portage-utils
free(): invalid pointer
Aborted
gentoo-prefix ~ $ qsearch portage-utils
app-portage/portage-utils: Small and fast Portage helper tools written in C
free(): invalid pointer
Aborted

(happens outside prefix as well)

Does not happen with 0.81.
Comment 1 Fabian Groffen gentoo-dev 2019-11-29 11:42:30 UTC
interesting, thanks
Comment 2 Larry the Git Cow gentoo-dev 2019-11-29 13:22:09 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=50b70d7c6696903440adde3a945af8bf298e1a0b

commit 50b70d7c6696903440adde3a945af8bf298e1a0b
Author:     Fabian Groffen <grobian@gentoo.org>
AuthorDate: 2019-11-29 13:18:37 +0000
Commit:     Fabian Groffen <grobian@gentoo.org>
CommitDate: 2019-11-29 13:18:37 +0000

    libq/tree: fix crash in tree_close_meta, bug #701470
    
    _data member was used differently before, make sure we can free it
    
    Bug: https://bugs.gentoo.org/701470
    Signed-off-by: Fabian Groffen <grobian@gentoo.org>

 libq/tree.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)
Comment 3 Andrei F. 2019-12-26 04:02:47 UTC
I'm experiencing the same issue, except that 'q search' without arguments does not return any results, see last example:

portage-utils version:

ndrei@x230 ~ $ equery l portage-utils
 * Searching for portage-utils ...
[IP-] [  ] app-portage/portage-utils-0.82:0



xxx@yyy ~ $ q search -S portage-utils
free(): invalid pointer
[1]    1688187 abort (core dumped)  q search -S portage-utils

xxx@yyy ~ $ q search -a
app-admin/aws-cli: Universal Command Line Interface for Amazon Web Services
free(): invalid pointer
[1]    1688377 abort (core dumped)  q search -a


xxx@yyy ~ $ q search portage-utils
xxx@yyy ~ $
Comment 4 Fabian Groffen gentoo-dev 2019-12-26 10:19:42 UTC
could you try and confirm that portage-utils-9999 works for your in this regard?
Comment 5 Larry the Git Cow gentoo-dev 2019-12-28 09:42:52 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ccbfbff3ffb51a9e7783458c9dad3e6d2cb49e29

commit ccbfbff3ffb51a9e7783458c9dad3e6d2cb49e29
Author:     Fabian Groffen <grobian@gentoo.org>
AuthorDate: 2019-12-28 09:42:05 +0000
Commit:     Fabian Groffen <grobian@gentoo.org>
CommitDate: 2019-12-28 09:42:23 +0000

    app-portage/portage-utils-0.83: version bump with bugfixes
    
    Drop overshadowed testing versions.
    
    Closes: https://bugs.gentoo.org/701968
    Closes: https://bugs.gentoo.org/701470
    Bug: https://bugs.gentoo.org/701402
    Closes: https://bugs.gentoo.org/701392
    Closes: https://bugs.gentoo.org/701386
    Closes: https://bugs.gentoo.org/700850
    Closes: https://bugs.gentoo.org/699558
    Package-Manager: Portage-2.3.79, Repoman-2.3.16
    Signed-off-by: Fabian Groffen <grobian@gentoo.org>

 app-portage/portage-utils/Manifest                 |  3 +-
 .../portage-utils/portage-utils-0.74-r1.ebuild     | 38 ----------
 .../portage-utils/portage-utils-0.81.ebuild        | 87 ----------------------
 ...utils-0.82.ebuild => portage-utils-0.83.ebuild} |  0
 4 files changed, 1 insertion(+), 127 deletions(-)
Comment 6 Guilherme Amadio gentoo-dev 2020-02-03 12:37:10 UTC
This bug seems to be back with portage-utils-0.85, so I'm reopening this.
Comment 7 Fabian Groffen gentoo-dev 2020-02-03 12:40:03 UTC
hmmm, odd, seem not to be able to reproduce
Comment 8 Guilherme Amadio gentoo-dev 2020-02-03 12:54:35 UTC
Here's my configuration:

app-portage/portage-utils-0.85::gentoo  USE="nls openmp qmanifest qtegrity -libressl -static"

And here is a backtrace:

(gdb) run portage-utils
Starting program: /usr/bin/qsearch portage-utils
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
app-portage/portage-utils: Small and fast Portage helper tools written in C
double free or corruption (out)

Program received signal SIGABRT, Aborted.
0x00007ffff7a324aa in raise () from /lib64/libc.so.6
(gdb) bt
#0  0x00007ffff7a324aa in raise () from /lib64/libc.so.6
#1  0x00007ffff7a1a55f in abort () from /lib64/libc.so.6
#2  0x00007ffff7a79c26 in __libc_message () from /lib64/libc.so.6
#3  0x00007ffff7a8316b in malloc_printerr () from /lib64/libc.so.6
#4  0x00007ffff7a85240 in _int_free () from /lib64/libc.so.6
#5  0x000055555559c6a2 in tree_close_meta (cache=0x55555560b560) at tree.c:1032
#6  0x000055555559d0f8 in tree_close_pkg (pkg_ctx=0x5555555f62c0) at tree.c:1233
#7  0x000055555559d941 in tree_foreach_pkg (ctx=0x5555555e3130, callback=0x555555585042 <qsearch_cb>, priv=0x7fffffffc460, sort=true, query=0x0)
    at tree.c:1401
#8  0x0000555555585644 in qsearch_main (argc=2, argv=0x7fffffffd788) at qsearch.c:177
#9  0x000055555556a5e5 in q_main (argc=2, argv=0x7fffffffd788) at q.c:116
#10 0x000055555556a289 in main (argc=2, argv=0x7fffffffd788) at main.c:1056


Let me know if you need more information.
Comment 9 Fabian Groffen gentoo-dev 2020-02-03 12:59:46 UTC
hmm, can you paste me your q -ov?
Comment 10 Larry the Git Cow gentoo-dev 2020-02-03 13:09:52 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=a7182e09e90bcd37cca9f56639f604a809ab4c1d

commit a7182e09e90bcd37cca9f56639f604a809ab4c1d
Author:     Fabian Groffen <grobian@gentoo.org>
AuthorDate: 2020-02-03 13:07:47 +0000
Commit:     Fabian Groffen <grobian@gentoo.org>
CommitDate: 2020-02-03 13:07:47 +0000

    libq/tree: ensure meta fields are clear when not set
    
    For some reason we went with uncleared pointers.  Probably because we
    only requested things that should/would exist.  However, for sanity, and
    probably bug #701470, return NULL pointers for anything not set (in
    metadata).
    
    Bug: https://bugs.gentoo.org/show_bug.cgi?id=701470
    Signed-off-by: Fabian Groffen <grobian@gentoo.org>

 libq/tree.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Comment 11 Guilherme Amadio gentoo-dev 2020-02-03 13:13:17 UTC
$ q -ov
gentoo: /home/amadio/gentoo/gentoo (main) [/etc/portage/repos.conf/gentoo]
amadio: /home/amadio/gentoo/amadio [/etc/portage/repos.conf/gentoo]

If this is relevant, I use both gentoo and my own overlay from git + hasufell scripts to update metadata after emerge --sync.
Comment 12 Fabian Groffen gentoo-dev 2020-02-03 13:18:52 UTC
qsearch is traversing all repos, indeed.  I was wondering if you for instance had a repo without metadata in use, but you have answered that question already.  I think my fix I just did solves this issue.
Comment 13 Larry the Git Cow gentoo-dev 2020-03-08 08:00:12 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=79b140be686c76a38301525c52e49a177d718d1d

commit 79b140be686c76a38301525c52e49a177d718d1d
Author:     Fabian Groffen <grobian@gentoo.org>
AuthorDate: 2020-03-08 07:59:56 +0000
Commit:     Fabian Groffen <grobian@gentoo.org>
CommitDate: 2020-03-08 07:59:56 +0000

    app-portage/portage-utils-0.86: version bump
    
    Closes: https://bugs.gentoo.org/711830
    Closes: https://bugs.gentoo.org/701470
    Closes: https://bugs.gentoo.org/710372
    Package-Manager: Portage-2.3.89, Repoman-2.3.20
    Signed-off-by: Fabian Groffen <grobian@gentoo.org>

 app-portage/portage-utils/Manifest                                      | 2 +-
 .../{portage-utils-0.85.ebuild => portage-utils-0.86.ebuild}            | 0
 2 files changed, 1 insertion(+), 1 deletion(-)