Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 893424 - app-portage/portage-utils: qmerge: fix segfault
Summary: app-portage/portage-utils: qmerge: fix segfault
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Fabian Groffen
URL:
Whiteboard:
Keywords: InVCS, PATCH
Depends on:
Blocks:
 
Reported: 2023-02-06 22:26 UTC by sfrolov
Modified: 2023-02-22 20:17 UTC (History)
3 users (show)

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


Attachments
prevents segafaults with uninitialized sets (q-iset-init.patch,471 bytes, patch)
2023-02-06 22:26 UTC, sfrolov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description sfrolov 2023-02-06 22:26:41 UTC
Created attachment 850012 [details, diff]
prevents segafaults with uninitialized sets

Patch in attachment prevents qmerge segfault with uninitialized _Q_ISET
Comment 1 Fabian Groffen gentoo-dev 2023-02-07 07:35:22 UTC
can you explain how/where this caused a crash?
Comment 2 Larry the Git Cow gentoo-dev 2023-02-07 08:10:11 UTC
The bug has been referenced in the following commit(s):

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

commit e2ebb44db31d4e0e9bfc0a9974d36eff63c8b2b1
Author:     Fabian Groffen <grobian@gentoo.org>
AuthorDate: 2023-02-07 08:08:13 +0000
Commit:     Fabian Groffen <grobian@gentoo.org>
CommitDate: 2023-02-07 08:08:13 +0000

    set: ensure NULL is empty behaviour is retained throughout
    
    Not all set functions respected NULL is empty behaviour, changed
    add_set_value signature to return a set instead so it can conform.
    
    Bug: https://bugs.gentoo.org/893424
    Signed-off-by: Fabian Groffen <grobian@gentoo.org>

 libq/set.c  | 47 +++++++++++++++++++++++++++++++++++++++--------
 libq/set.h  |  4 ++--
 libq/tree.c |  5 +++--
 main.c      |  6 ++++--
 qkeyword.c  |  6 +++---
 qlop.c      | 12 ++++++++----
 6 files changed, 59 insertions(+), 21 deletions(-)
Comment 3 sfrolov 2023-02-07 23:09:07 UTC
Here's gdb output, minus some irrelevant info from the first `run` command.

```
(gdb) r
...
(null)/usr/bin/qmerge(null): ignoring parent with unknown repo in profile profilename
...

Program received signal SIGSEGV, Segmentation fault.
contains_set (name=0x55555555ba12 "strict", q=0x0) at set.c:165
165	set.c: No such file or directory.
(gdb) bt
#0  contains_set (name=0x55555555ba12 "strict", q=0x0) at set.c:165
#1  0x0000555555577b2f in qmerge_main (argc=argc@entry=134, argv=argv@entry=0x7fffffffbda8)
    at qmerge.c:2027
#2  0x000055555556aa3a in q_main (argc=argc@entry=134, argv=argv@entry=0x7fffffffbda8)
    at q.c:116
#3  0x00005555555694d6 in main (argc=134, argv=0x7fffffffbda8) at main.c:1177
(gdb) list qmerge.c:2027
2022	
2023		/* default to install if no action given */
2024		if (!install && !uninstall)
2025			install = 1;
2026	
2027		qmerge_strict = contains_set("strict", features) ? 1 : 0;
2028	
2029		/* Short circut this. */
2030		if (install && !pretend) {
2031			if (follow_rdepends && getenv("QMERGE") == NULL) {
```

So, at the following line:
```
2027		qmerge_strict = contains_set("strict", features) ? 1 : 0;
```
`features` is NULL
Comment 4 Fabian Groffen gentoo-dev 2023-02-08 07:43:29 UTC
ok, thanks, e2ebb44db31d4e0e9bfc0a9974d36eff63c8b2b1 addresses that
Comment 5 Larry the Git Cow gentoo-dev 2023-02-22 20:17:20 UTC
The bug has been closed via the following commit(s):

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

commit 1fa248843038ffe79d7fce8b51e7f16c65667c7e
Author:     Fabian Groffen <grobian@gentoo.org>
AuthorDate: 2023-02-22 20:15:43 +0000
Commit:     Fabian Groffen <grobian@gentoo.org>
CommitDate: 2023-02-22 20:17:16 +0000

    app-portage/portage-utils-0.95: version bump
    
    Closes: https://bugs.gentoo.org/893424
    Closes: https://bugs.gentoo.org/892533
    Closes: https://bugs.gentoo.org/885801
    Signed-off-by: Fabian Groffen <grobian@gentoo.org>

 app-portage/portage-utils/Manifest                 |  2 +-
 .../portage-utils/portage-utils-0.94.1.ebuild      | 67 -------------------
 .../portage-utils/portage-utils-0.95.ebuild        | 75 ++++++++++++++++++++++
 3 files changed, 76 insertions(+), 68 deletions(-)