[pacman-dev] [BUG] alpm_list_remove need an initalized pointer for void **data

Xavier shiningxc at gmail.com
Fri Aug 8 07:32:37 EDT 2008


On Thu, Aug 7, 2008 at 3:41 PM, Dan McGee <dpmcgee at gmail.com> wrote:
>
> I think the problem is something different; note the problem occurs in db_cmp:
>
> Program received signal SIGSEGV, Segmentation fault.
> _alpm_db_cmp (d1=0x97b60f0, d2=0x97b60f0) at db.c:363
> 363             return(strcmp(db1->treename, db2->treename));
> (gdb) bt
> #0  _alpm_db_cmp (d1=0x97b60f0, d2=0x97b60f0) at db.c:363
> #1  0xb8006a8c in alpm_list_remove (haystack=0x97b6140, needle=0x97b60f0,
>    fn=0xb800d5b0 <_alpm_db_cmp>, data=0xbf841064) at alpm_list.c:314
> #2  0xb800ead2 in alpm_db_unregister (db=0x97b60f0) at db.c:149
> #3  0x08048770 in main () at test.c:17
> (gdb) p d1
> $1 = (const void *) 0x97b60f0
> (gdb) p d2
> $2 = (const void *) 0x97b60f0
> (gdb) p d1->treename
> Attempt to dereference a generic pointer.
> (gdb) p ((pmdb_t)d1)->treename
> $3 = 0x97b60f0 "\020a{\t0a{\t\220p{\t"
> (gdb) p ((pmdb_t)d2)->treename
> $4 = 0x0
>

-int _alpm_db_cmp(const void *db1, const void *db2)
+int _alpm_db_cmp(const void *d1, const void *d2)
 {
-       ALPM_LOG_FUNC;
-       return(strcmp(((pmdb_t *)db1)->treename, ((pmdb_t *)db2)->treename));
+       pmdb_t *db1 = (pmdb_t *)db1;
+       pmdb_t *db2 = (pmdb_t *)db2;
+       return(strcmp(db1->treename, db2->treename));
 }

Oh my god, who could have wrote such a stupid code :@

commit f43805d875ad5c672afbbfff48bded2087204773
Author: Chantry Xavier <shiningxc at gmail.com>
Date:   Sat May 10 18:47:42 2008 +0200

Oh my god, it was me.
/me bangs his head against the wall 100 times.



More information about the pacman-dev mailing list