Is there possible to get the backtrace where opkg hangs.
reading the strace gave me some clue. I am highly doubt the the
infinite loop took place at
check_data_file_clashes_change but I am not quite sure.
If it really happens there, in my system it works well.
I think there must be some nasty bug there. maybe out of memory.
stat64("(null)", 0xbecfe3c0) = -1 ENOENT (No such file or directory)
means the pointer 0xbecfe3c0 is pointing to null in which allocated
from root_filename_alloc
I found some memory leak here. When the flag is force-overwrite and
replaces it will cause memory leaks. I think it may eat all the memory
and cause malloc failed.
I think the following patch may help, if my guess was right.
----------------------------------------------------------
diff --git a/libopkg/opkg_install.c b/libopkg/opkg_install.c
index a60b75f..f9bf732 100644
--- a/libopkg/opkg_install.c
+++ b/libopkg/opkg_install.c
@@ -1306,12 +1306,17 @@ static int
check_data_file_clashes_change(opkg_conf_t *conf, pkg_t *pkg, pkg_t *
str_list_t *files_list;
str_list_elt_t *iter;
+ char *root_filename = NULL;
+
int clashes = 0;
files_list = pkg_get_installed_files(pkg);
for (iter = str_list_first(files_list); iter; iter =
str_list_next(files_list, iter)) {
- char *root_filename;
char *filename = (char *) iter->data;
+ if (root_filename) {
+ free(root_filename);
+ root_filename = NULL;
+ }
root_filename = root_filename_alloc(conf, filename);
if (file_exists(root_filename) && (! file_is_dir(root_filename))) {
pkg_t *owner;
@@ -1336,7 +1341,10 @@ static int
check_data_file_clashes_change(opkg_conf_t *conf, pkg_t *pkg, pkg_t *
}
}
- free(root_filename);
+ }
+ if (root_filename) {
+ free(root_filename);
+ root_filename = NULL;
}
pkg_free_installed_files(pkg);
------------------------------------------------------------------------------------------
----- my gdb log----
/home/tick $ opkg-cl -o /home/tick/box/ remove coreutils
Removing package coreutils from root...
(offline root mode: not running coreutils.prerm)
/home/tick $ strace -o opkg.log gdb --args opkg-cl -o /home/tick/box/
install coreutils
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <
http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu"...
(gdb) b check_data_file_clashes_change
Breakpoint 1 at 0x80537af: file opkg_install.c, line 1309.
(gdb) r
Starting program: /home/tick/opkg-cl -o /home/tick/box/ install coreutils
[Thread debugging using libthread_db enabled]
Installing coreutils (5.3.0-r4.1) to root...
Downloading
http://www.angstrom-distribution.org/feeds/2008/ipk/glibc/armv7a/base//coreutils_5.3.0-r4.1_armv7a.ipk
[New Thread 0xb7bab6d0 (LWP 8428)]
[Switching to Thread 0xb7bab6d0 (LWP 8428)]
Breakpoint 1, check_data_file_clashes_change (conf=0xbff6e66c, pkg=0x96adcc8,
old_pkg=0x0) at opkg_install.c:1309
1309 int clashes = 0;
(gdb) n
1311 files_list = pkg_get_installed_files(pkg);
(gdb)
1312 for (iter = str_list_first(files_list); iter; iter =
str_list_next(files_list, iter)) {
(gdb) n
1314 char *filename = (char *) iter->data;
(gdb) print filena,e
No symbol "filena" in current context.
(gdb) print filename
$1 = 0x0
(gdb) n
1315 root_filename = root_filename_alloc(conf, filename);
(gdb) print filename
$2 = 0x929a428 "/home/tick/box//"
(gdb) n
1316 if (file_exists(root_filename) && (! file_is_dir(root_filename))) {
(gdb) n
1339 free(root_filename);
(gdb) print root_filename
$3 = 0x9e63590 "/home/tick/box//home/tick/box//"
(gdb) n
1312 for (iter = str_list_first(files_list); iter; iter =
str_list_next(files_list, iter)) {
(gdb)
1314 char *filename = (char *) iter->data;
(gdb)
1315 root_filename = root_filename_alloc(conf, filename);
(gdb) display root_filename
1: root_filename = 0x9e63590 "p\001շp\001շck/box//home/tick/box//"
(gdb) n
1316 if (file_exists(root_filename) && (! file_is_dir(root_filename))) {
1: root_filename = 0x9e63590 "/home/tick/box//home/tick/box//usr/"
(gdb)
1339 free(root_filename);
1: root_filename = 0x9e63590 "/home/tick/box//home/tick/box//usr/"
(gdb)
1312 for (iter = str_list_first(files_list); iter; iter =
str_list_next(files_list, iter)) {
(gdb)
1314 char *filename = (char *) iter->data;
1: root_filename = 0x9e63590 "p\001շp\001շck/box//home/tick/box//usr/"
(gdb)
1315 root_filename = root_filename_alloc(conf, filename);
1: root_filename = 0x9e63590 "p\001շp\001շck/box//home/tick/box//usr/"
(gdb)
1316 if (file_exists(root_filename) && (! file_is_dir(root_filename))) {
1: root_filename = 0x9e63590 "/home/tick/box//home/tick/box//usr/sbin/"
(gdb)
1339 free(root_filename);
1: root_filename = 0x9e63590 "/home/tick/box//home/tick/box//usr/sbin/"
(gdb)
1312 for (iter = str_list_first(files_list); iter; iter =
str_list_next(files_list, iter)) {
(gdb)
1314 char *filename = (char *) iter->data;
1: root_filename = 0x9e63590 "p\001շp\001շck/box//home/tick/box//usr/sbin/"
(gdb)
1315 root_filename = root_filename_alloc(conf, filename);
1: root_filename = 0x9e63590 "p\001շp\001շck/box//home/tick/box//usr/sbin/"
(gdb)
1316 if (file_exists(root_filename) && (! file_is_dir(root_filename))) {
1: root_filename = 0x9e63590
"/home/tick/box//home/tick/box//usr/sbin/chroot.coreutils"
(gdb)
1339 free(root_filename);
1: root_filename = 0x9e63590
"/home/tick/box//home/tick/box//usr/sbin/chroot.coreutils"
(gdb)
1312 for (iter = str_list_first(files_list); iter; iter =
str_list_next(files_list, iter)) {
(gdb)
1314 char *filename = (char *) iter->data;
1: root_filename = 0x9e63590
"p\001շp\001շck/box//home/tick/box//usr/sbin/chroot.coreutils"
(gdb)
1315 root_filename = root_filename_alloc(conf, filename);
1: root_filename = 0x9e63590
"p\001շp\001շck/box//home/tick/box//usr/sbin/chroot.coreutils"
(gdb)
1316 if (file_exists(root_filename) && (! file_is_dir(root_filename))) {
1: root_filename = 0x9e63590 "/home/tick/box//home/tick/box//usr/bin/"
(gdb)
1339 free(root_filename);
1: root_filename = 0x9e63590 "/home/tick/box//home/tick/box//usr/bin/"
(gdb)
1312 for (iter = str_list_first(files_list); iter; iter =
str_list_next(files_list, iter)) {
(gdb)
1314 char *filename = (char *) iter->data;
1: root_filename = 0x9e63590 "p\001շp\001շck/box//home/tick/box//usr/bin/"
(gdb)
1315 root_filename = root_filename_alloc(conf, filename);
1: root_filename = 0x9e63590 "p\001շp\001շck/box//home/tick/box//usr/bin/"
(gdb)
1316 if (file_exists(root_filename) && (! file_is_dir(root_filename))) {
1: root_filename = 0x9e63590
"/home/tick/box//home/tick/box//usr/bin/pathchk.coreutils"
(gdb)
1339 free(root_filename);
1: root_filename = 0x9e63590
"/home/tick/box//home/tick/box//usr/bin/pathchk.coreutils"
(gdb)
1312 for (iter = str_list_first(files_list); iter; iter =
str_list_next(files_list, iter)) {
(gdb)
1314 char *filename = (char *) iter->data;
1: root_filename = 0x9e63590
"p\001շp\001շck/box//home/tick/box//usr/bin/pathchk.coreutils"
(gdb)
1315 root_filename = root_filename_alloc(conf, filename);
1: root_filename = 0x9e63590
"p\001շp\001շck/box//home/tick/box//usr/bin/pathchk.coreutils"
(gdb)
1316 if (file_exists(root_filename) && (! file_is_dir(root_filename))) {
1: root_filename = 0x9e63590
"/home/tick/box//home/tick/box//usr/bin/sha1sum.coreutils"
(gdb)
1339 free(root_filename);
1: root_filename = 0x9e63590
"/home/tick/box//home/tick/box//usr/bin/sha1sum.coreutils"
(gdb)
1312 for (iter = str_list_first(files_list); iter; iter =
str_list_next(files_list, iter)) {
(gdb)
1314 char *filename = (char *) iter->data;
1: root_filename = 0x9e63590
"p\001շp\001շck/box//home/tick/box//usr/bin/sha1sum.coreutils"
(gdb)
1315 root_filename = root_filename_alloc(conf, filename);
1: root_filename = 0x9e63590
"p\001շp\001շck/box//home/tick/box//usr/bin/sha1sum.coreutils"
(gdb)
1316 if (file_exists(root_filename) && (! file_is_dir(root_filename))) {
1: root_filename = 0x9e63590
"/home/tick/box//home/tick/box//usr/bin/tail.coreutils"
(gdb)
1339 free(root_filename);
1: root_filename = 0x9e63590
"/home/tick/box//home/tick/box//usr/bin/tail.coreutils"
2009/2/28 Tick <
tickt...@gmail.com>: