New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A runtime error occured: /usr/lib/lua/luci/model/network.lua:187: attempt to index a nil value #2027
Comments
The weird thing is that The only condition under which |
Yep, understand that and have already trawled through that code. So by putting that debug in place I never see a failure backtrace. I only see the "is nil wlan0" as it will fail on the debug line and the next test passes. As I said in the previous issue, I'm fairly sure it's not a memory related issue : root@WRT32x:~# free This box literally does nothing other than shunt packets between the wireless and wired LAN. It's a very expensive AP. It has me stuffed, but as long as I have a web tab with the status overview up it happens pretty much every day. I'll put some instrumentation in ip.so to find out which allocation is failing and compile up a new image to test. Debug printing from lua is easy enough. Is there a reference for getting a debug print out of the linked library you could point me towards? |
It should be enough to use I suspect the problem can be "fixed" with a change like this: diff --git a/libs/luci-lib-ip/src/ip.c b/libs/luci-lib-ip/src/ip.c
index 854a0c09c..7cf3cd444 100644
--- a/libs/luci-lib-ip/src/ip.c
+++ b/libs/luci-lib-ip/src/ip.c
@@ -1517,8 +1517,10 @@ static int link_get(lua_State *L)
struct nl_cb *cb = nl_cb_alloc(NL_CB_DEFAULT);
struct ifinfomsg ifm = { .ifi_index = if_nametoindex(dev) };
+ lua_newtable(L);
+
if (!msg || !cb)
- return 0;
+ return 1;
nlmsg_append(msg, &ifm, sizeof(ifm), 0);
@@ -1526,8 +1528,6 @@ static int link_get(lua_State *L)
nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, cb_done, &st);
nl_cb_err(cb, NL_CB_CUSTOM, cb_error, &st);
- lua_newtable(L);
-
nl_send_auto_complete(sock, msg);
while (st.pending > 0)
But Ideally I'd like to understand the underlying problem first. Maybe its not the amount of free memory but memory fragmentation, or some bad caching / allocation behaviour in libnl-tiny. |
Ok, failure to allocate isn't the problem. I put the fprintf in and got the lua error 3 times last night, but never once triggered the print in ip.c. So the error is not due to a failure to allocate those structures. |
Ok, the error is failure in nl_connect(). On failure it is returning -6 : Fri Aug 3 16:16:33 2018 daemon.err uhttpd[2337]: no nl_connect -6 In libnl, -6 is NLE_EXIST "Object exists". Plenty of instances splattered across google of similar errors using libnl. Some bletcherous examples of workarounds using loops and waits. I'll keep poking. |
Yeah, one common pattern for returning errors in Lua library function is |
Amusingly I updated the WRT1900ACv2 to OpenWrt 18.06.1 r7258-5eb055306f (from the repositories, not compiled locally) a couple of weeks ago and I'm periodically seeing exactly the same error at the same location in the logs. That router is actually working as a router and is considerably more busy with a completely different configuration, but precisely the same error. Odd that I'm apparently the only person seeing this. I suppose I'd better take a look at the lua->C call chain and figure out how to gracefully fail that call. |
I just encountered this error about 20 minutes ago, on a R7800 running
Line 203 is the above mentioned Memory is also not an issue on my device, taken shortly after discovery.
|
Just to add another potential data point in the event it has any relation:
LuCI Master (git-19.058.07653) / OpenWrt SNAPSHOT r9456 |
This issue has been bugging me for a while since my monitoring system alerts me on errors from the router. Adding the latest message in my system log as well:
Linksys WRT1900AC |
I just ran into this issue while running OpenWrt SNAPSHOT r9019-0e8d5ff0fc / LuCI Master (git-19.079.18950-11e64f8) on MikroTik RouterBOARD 750Gr3.
|
Master / 19.07 do not use this code anymore |
For whatever reason I am unable to re-open : #1649
I am again running a recent git head build :
commit 2a598bb
Author: Rafał Miłecki rafal@milecki.pl
Date: Fri Jul 27 21:54:08 2018 +0200
I have tracked this down to luci.ip returning nil for the the ipc.link(ifname) call.
I inserted debugging code in network.lua prior to the failing line (local phy_only = force_phy_only or (ipc.link(ifname).type ~= 1)) :
And got : Tue Jul 31 18:59:46 2018 daemon.err uhttpd[2337]: ipc.link(ifname) is nil wlan0
The subsequent call (ipc.link(ifname).type ~= 1) then succeeded.
So for whatever reason on this device, very intermittently (like once a day) that call will fail and return nil, which network.lua then attempts to index with the .type call and it fails.
I attached the requested network interface dump to that report, but as I've been unable to re-open it I'll reference it here : https://github.com/openwrt/luci/files/1897666/network.interface.dump.txt
I'm now not sure where to go next. Anyone have any ideas?
The text was updated successfully, but these errors were encountered: