[LEDE-DEV] [PATCH] libubus: initialize list member for ubus_auto_conn's timer

Alexandru Ardelean ardeleanalex at gmail.com
Mon Dec 12 23:41:27 PST 2016


Every once in a while, we'll get stacktrace:
```
(gdb) bt
\#0  0xb7bc4668 in _list_del (entry=0x10015688 <conn+116>) at /home/sandu/work/Wrt/openwrt/build_dir/target-powerpc_8540_uClibc-0.9.33.2_ewok/libubox-2015-06-29/list.h:83
\#1  list_del (entry=0x10015688 <conn+116>) at /home/sandu/work/Wrt/openwrt/build_dir/target-powerpc_8540_uClibc-0.9.33.2_ewok/libubox-2015-06-29/list.h:90
\#2  uloop_timeout_cancel (timeout=timeout at entry=0x10015688 <conn+116>) at /home/sandu/work/Wrt/openwrt/build_dir/target-powerpc_8540_uClibc-0.9.33.2_ewok/libubox-2015-06-29/uloop.c:474
\#3  0x10003794 in ubus_auto_shutdown (conn=0x10015614 <conn>) at /home/sandu/work/Wrt/openwrt/staging_dir/target-powerpc_8540_uClibc-0.9.33.2_ewok/usr/include/libubus.h:249
\#4  module_ubus_fini () at ubus.c:64
\#5  0x100013fc in main (argc=<optimized out>, argv=<optimized out>) at module.c:128
```

In our code, `ubus_auto_connect()` is called, then due to some logic,
the module has to quickly stop, calling ubus_auto_shutdown().

It seems that there is case in where the `timer` timeout, is not yet
registered with the internal list of timeouts from uloop, which
ends up trying to delete an invalid list.

So, one solution is to init the list element of the `timer` of
the `ubus_auto_conn` struct.

Signed-off-by: Alexandru Ardelean <ardeleanalex at gmail.com>
---
 libubus.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libubus.c b/libubus.c
index 8163ff7..faa30d3 100644
--- a/libubus.c
+++ b/libubus.c
@@ -337,6 +337,7 @@ static void ubus_auto_connect_cb(struct uloop_timeout *timeout)
 void ubus_auto_connect(struct ubus_auto_conn *conn)
 {
 	conn->timer.cb = ubus_auto_connect_cb;
+	INIT_LIST_HEAD(&conn->timer.list);
 	ubus_auto_connect_cb(&conn->timer);
 }
 
-- 
2.6.6




More information about the Lede-dev mailing list