infinite loop in opkg when installing certain packages

126 views
Skip to first unread message

Koen Kooi

unread,
Feb 27, 2009, 3:52:40 PM2/27/09
to opkg-devel
Hi,

Multiple people have reported that installing coreutils on beagleboard
produces a hang:

root@beagleboard:~# strace -o /tmp/opkg.log opkg install coreutils
Upgrading coreutils on root from 5.3.0-r3.1 to 5.3.0-r4.1...
Downloading http://www.angstrom-distribution.org/feeds/2008/ipk/glibc/armv7a/base/coreutils_5.3.0-r4.1_armv7a.ipk
<hang>

This is with opkg-nogpg r201, the log can be found at
http://dominion.thruhere.net/koen/OE/opkg.log.gz

I'd normally file a bug, but google decided to make code.google.com
readonly due to network issues :(

regards,

Koen

Tick

unread,
Feb 27, 2009, 10:27:04 PM2/27/09
to opkg-...@googlegroups.com
Hi Koen,
Thanks, I am going to look at this. Is this happen only on R201 or
also happen in previous versions?

Regard,
Tick

2009/2/28 Koen Kooi <koen...@gmail.com>:

Tick

unread,
Feb 28, 2009, 12:56:32 AM2/28/09
to opkg-...@googlegroups.com
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>:

Tick

unread,
Feb 28, 2009, 1:18:48 AM2/28/09
to opkg-...@googlegroups.com
Hi Koen,
Last patch commited as R202. Though I am not sure it's the root
cause of your issue, it reduce some memory leaks. if I were right,
it's out of memory issue, this patch may ease your problem.

Hmmm... I should make louder noise when the malloc failed.

If beagle if very sensitive to the usage of memory, I think it can be
a very to be test cases for opkg. :)

Thanks,
Tick

2009/2/28 Tick <tickt...@gmail.com>:

Koen Kooi

unread,
Mar 2, 2009, 9:29:42 AM3/2/09
to opkg-devel
On 28 feb, 07:18, Tick <ticktoc...@gmail.com> wrote:
> Hi Koen,
>   Last patch commited as R202.  Though I am not sure it's the root
> cause of your issue, it reduce some memory leaks.  if I were right,
> it's out of memory issue, this patch may ease your problem.
>
> Hmmm... I should make louder noise when the malloc failed.
>
> If beagle if very sensitive to the usage of memory, I think it can be
> a very to be test cases for opkg. :)

It has 256MB of ram and I have 160MB of swap as well, so it's not
tight on memory :)

regards,

Koen

Koen Kooi

unread,
Mar 4, 2009, 4:40:51 AM3/4/09
to opkg-devel
On 27 feb, 21:52, Koen Kooi <koen.k...@gmail.com> wrote:
> Hi,
>
> Multiple people have reported that installing coreutils on beagleboard
> produces a hang:
>
> root@beagleboard:~# strace -o /tmp/opkg.log opkg install coreutils
> Upgrading coreutils on root from 5.3.0-r3.1 to 5.3.0-r4.1...
> Downloadinghttp://www.angstrom-distribution.org/feeds/2008/ipk/glibc/armv7a/base...
> <hang>
>
> This is with opkg-nogpg r201, the log can be found athttp://dominion.thruhere.net/koen/OE/opkg.log.gz
>
> I'd normally file a bug, but google decided to make code.google.com
> readonly due to network issues :(

Still no backtrace, but here's another datapoint:

https://docs.openmoko.org/trac/ticket/2250

regards,

Koen

Tick

unread,
Mar 4, 2009, 5:00:49 AM3/4/09
to opkg-...@googlegroups.com
Thanks,
I had saw that, and wondering which version he is using.
I guess it's R197

But that means I do able reproduce this issue. :D

Cheers,
Tick

2009/3/4 Koen Kooi <koen...@gmail.com>:

Frans Meulenbroeks

unread,
Mar 8, 2009, 1:31:51 PM3/8/09
to opkg-devel
I have the same problem and I am on R203

On Mar 4, 11:00 am, Tick <ticktoc...@gmail.com> wrote:
> Thanks,
>  I had saw that, and wondering which version he is using.
> I guess it's R197
>
> But that means I do able reproduce this issue. :D
>
> Cheers,
> Tick
>
> 2009/3/4 Koen Kooi <koen.k...@gmail.com>:

Tick

unread,
Mar 8, 2009, 1:44:02 PM3/8/09
to opkg-...@googlegroups.com
Hi Frans,
Thanks, I will try to deal with this tomorrow morning.

Regards,
Tick

2009/3/9 Frans Meulenbroeks <fransmeu...@gmail.com>:

Tick

unread,
Mar 9, 2009, 8:33:10 PM3/9/09
to Opkg devel List
Fowrard back to the mailing list


---------- Forwarded message ----------
From: Frans Meulenbroeks <fransmeu...@gmail.com>
Date: 2009/3/10
Subject: Re: infinite loop in opkg when installing certain packages
To: Tick <tickt...@gmail.com>
副本: Koen Kooi <ko...@beagleboard.org>


Hi Tick,

Just tried R204. opkg upgrade coreutils now goes as expected.
Thanks alot for your help.

Frans.

PS: Koen, I committed the change to R204.

2009/3/9 Tick <tickt...@gmail.com>:
> Hi Frans,
>  Thanks a lot for your help. :)
> R204 is dealing with is issue, iterating the file list more carefully.
> Would you like to test this on the device you encounter this issue?
>
> Thanks


> Tick
>
> 2009/3/9 Frans Meulenbroeks <fransmeu...@gmail.com>:

>> Feel free to email me if you need a tester (I'm not subscribed to the
>> opkg list)
>>
>> Frans


>>
>> On Mar 8, 6:44 pm, Tick <ticktoc...@gmail.com> wrote:
>>> Hi Frans,
>>>  Thanks, I will try to deal with this tomorrow morning.
>>>
>>> Regards,
>>> Tick
>>>

>>> 2009/3/9 Frans Meulenbroeks <fransmeulenbro...@gmail.com>:

Reply all
Reply to author
Forward
0 new messages