FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian dpkg

 
 
LinkBack Thread Tools
 
Old 11-26-2011, 12:56 AM
Jonathan Nieder
 
Default multiarch: dpkg-query segfaults

Hi Guillem and RaphaŽl,

Being the adventurous sort, I tried building and installing dpkg from
guillem/pu/multiarch/master. "dpkg" seems to work ok, but dpkg-query
is broken (it always segfaults).

Ok, back to dpkg/sid (thanks for the maintainer scripts that make
switching between very easy). Luckily the segfault is reproducible
without installing a new dpkg version:

$ build-tree/src/dpkg-query -l dpkg
Segmentation fault

Also reproducible with raphael/pu/multiarch/full. Bisects to 8c57a40d
(libdpkg: update package sorting logic to take into account the
architecture), which didn't take into account that some callers of
pkg_sorter_by_name leave pkg->installed and pkg->available blank (the
juicy stuff for them seems to be in pkg->set).

The diff below [1] works around it.

We get another segfault in the same spirit (same reproduction recipe)
in 26516da (dpkg-query: Update commands to accept package specifiers
as arguments). It is due to this code:

| for (i = 0; i < array.n_pkgs; i++) {
| pkg = array.pkgs[i];
| for (ip = 0; ip < argc; ip++) {
| - if (!fnmatch(argv[ip], pkg->set->name, 0)) {
| + if (pkg_spec_match_pkg(&ps[ip], pkg, &pkg->installed)) {

"dpkg-query -l dpkg:amd64" seems to work fine.

I guess that is because when the commandline parameter does not
include an architecture specifier, pkgs[i]->installed.arch is examined
to check if it's a native package, and since arch is NULL, segfault.

So the diff below [1] works around that, too.

Another oddity:

$ dpkg-query --search -- /lib/x86_64-linux-gnu/libc.so.6
strcpy: /lib/x86_64-linux-gnu/libc.so.6

Bisects to 3c971ae (dpkg-query: Update --list and --show to output
package specifiers)

Hints?
Jonathan

[1]

lib/dpkg/pkg-spec.c | 4 ++++
lib/dpkg/pkg.c | 7 +++++--
2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/dpkg/pkg-spec.c b/lib/dpkg/pkg-spec.c
index 2859bad8..ee119c78 100644
--- a/lib/dpkg/pkg-spec.c
+++ b/lib/dpkg/pkg-spec.c
@@ -141,6 +141,10 @@ pkg_spec_parse(struct pkg_spec *ps, const char *str)
static bool
pkg_spec_match_arch(struct pkg_spec *ps, const struct dpkg_arch *arch)
{
+ /* These should just never match. */
+ if (!arch)
+ return false;
+
if (ps->arch_is_pattern)
return (fnmatch(ps->arch->name, arch->name, 0) == 0);
else if (ps->arch->type != arch_none) /* !arch_is_pattern */
diff --git a/lib/dpkg/pkg.c b/lib/dpkg/pkg.c
index 2dc00d9b..1495c1d0 100644
--- a/lib/dpkg/pkg.c
+++ b/lib/dpkg/pkg.c
@@ -136,8 +136,8 @@ pkg_sorter_by_name(const void *a, const void *b)
{
const struct pkginfo *pa = *(const struct pkginfo **)a;
const struct pkginfo *pb = *(const struct pkginfo **)b;
- const char *arch_a = pa->installed.arch->name;
- const char *arch_b = pb->installed.arch->name;
+ const char *arch_a;
+ const char *arch_b;
int res;

res = strcmp(pa->set->name, pb->set->name);
@@ -155,5 +155,8 @@ pkg_sorter_by_name(const void *a, const void *b)
pb->installed.arch->type == arch_native)
arch_b = "";

+ arch_b = pb->installed.arch->name;
+ arch_a = pa->installed.arch->name;
+
return strcmp(arch_a, arch_b);
}
--
1.7.8.rc3


--
To UNSUBSCRIBE, email to debian-dpkg-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20111126015617.GA3654@elie.hsd1.il.comcast.net">ht tp://lists.debian.org/20111126015617.GA3654@elie.hsd1.il.comcast.net
 
Old 11-26-2011, 06:41 AM
Raphael Hertzog
 
Default multiarch: dpkg-query segfaults

Hi,

On Fri, 25 Nov 2011, Jonathan Nieder wrote:
> Being the adventurous sort, I tried building and installing dpkg from
> guillem/pu/multiarch/master. "dpkg" seems to work ok, but dpkg-query
> is broken (it always segfaults).

I verified and all thoses issues are fixed in my pu/multiarch/full
branch.

Feel free to run that version to help discover other potential problems.
I keep in pu/multiarch/full the latest version that passes the test-suite.

Cheers,
--
Rapha√ęl Hertzog ‚óą Debian Developer

Pre-order a copy of the Debian Administrator's Handbook and help
liberate it: http://debian-handbook.info/go/ulule-rh/


--
To UNSUBSCRIBE, email to debian-dpkg-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20111126074154.GC6602@rivendell.home.ouaza.com">ht tp://lists.debian.org/20111126074154.GC6602@rivendell.home.ouaza.com
 
Old 11-27-2011, 09:02 AM
Jonathan Nieder
 
Default multiarch: dpkg-query segfaults

Raphael Hertzog wrote:

> I verified and all thoses issues are fixed in my pu/multiarch/full
> branch.

Yes, checked.

BTW, thanks for the new bisectable version of that tree. If I ran the
world, there would be a pu/multiarch/testing branch that is bisectable
and never gets rewinded (aka pu/multiarch/for-jrn ;-)).

> Feel free to run that version to help discover other potential problems.

Doing so. Thanks to both of you for making it.


--
To UNSUBSCRIBE, email to debian-dpkg-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20111127100222.GA22865@elie.hsd1.il.comcast.net">h ttp://lists.debian.org/20111127100222.GA22865@elie.hsd1.il.comcast.net
 
Old 11-27-2011, 10:28 PM
Guillem Jover
 
Default multiarch: dpkg-query segfaults

Hi!

On Fri, 2011-11-25 at 19:56:17 -0600, Jonathan Nieder wrote:
> Being the adventurous sort, I tried building and installing dpkg from
> guillem/pu/multiarch/master. "dpkg" seems to work ok, but dpkg-query
> is broken (it always segfaults).

Sorry! I should have mentioned on my reply to your mail about using
pu/multiarch/master, that I've been generally doing thorough testing on
the things I merge into master, and almost none at all from that branch,
except for some specific changes.

thanks,
guillem


--
To UNSUBSCRIBE, email to debian-dpkg-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20111127232851.GB16825@gaara.hadrons.org">http://lists.debian.org/20111127232851.GB16825@gaara.hadrons.org
 

Thread Tools




All times are GMT. The time now is 09:41 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2007 - 2008, www.linux-archive.org