mkschreder / orangerpcd

Websocket RPC server for OpenWRT
Other
27 stars 11 forks source link

Segmentation fault upon request #2

Closed haveyaseen closed 7 years ago

haveyaseen commented 8 years ago

The server seems to start up just fine but as soon as it receives a request (when JUCI is opened) it segfaults.

RevoRPCD v0.1.0 Copyright (c) 2016 Martin Schröder [1459850244:3084] NOTICE: Initial logging level 7 [1459850244:3093] NOTICE: Libwebsockets version: 1.6.0 3b54f5c [1459850244:3105] NOTICE: IPV6 not compiled in [1459850244:3116] NOTICE: libev support not compiled in [1459850244:3150] NOTICE: mem: platform fd map: 16384 bytes [1459850244:3163] NOTICE: mem: per-conn: 256 bytes + protocol rx buf [1459850244:3173] NOTICE: canonical_hostname = OpenWrt [1459850244:3189] NOTICE: Listening on port 1234 could not load password file from /etc/juci-shadow could not open directory plugins Segmentation fault

mkschreder commented 8 years ago

It seems you don't have all files in place. It is a bug however so I will trace the issue and see if I can reproduce it.

Do you still have it when you set up the shadow file with pairs? On 5 Apr 2016 12:03, "Jason" notifications@github.com wrote:

The server seems to start up just fine but as soon as it receives a request (when JUCI is opened) it segfaults.

RevoRPCD v0.1.0 Copyright (c) 2016 Martin Schröder [1459850244:3084] NOTICE: Initial logging level 7 [1459850244:3093] NOTICE: Libwebsockets version: 1.6.0 3b54f5c [1459850244:3105] NOTICE: IPV6 not compiled in [1459850244:3116] NOTICE: libev support not compiled in [1459850244:3150] NOTICE: mem: platform fd map: 16384 bytes [1459850244:3163] NOTICE: mem: per-conn: 256 bytes + protocol rx buf [1459850244:3173] NOTICE: canonical_hostname = OpenWrt [1459850244:3189] NOTICE: Listening on port 1234 could not load password file from /etc/juci-shadow could not open directory plugins Segmentation fault

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/mkschreder/jucid/issues/2

haveyaseen commented 8 years ago

Yes, same issue. According to https://github.com/mkschreder/jucid/blob/master/src/juci.c#L218 I created the file /etc/juci-shadow with the following contents:

admin a8fdc205a9f19cc1c7507a60c4f01b13d11d7fd0 (empty line)

revorpcd output (still segfaults upon request):

RevoRPCD v0.1.0 Copyright (c) 2016 Martin Schröder [1459869053:1982] NOTICE: Initial logging level 7 [1459869053:1985] NOTICE: Libwebsockets version: 1.6.0 3b54f5c [1459869053:1986] NOTICE: IPV6 not compiled in [1459869053:1988] NOTICE: libev support not compiled in [1459869053:2008] NOTICE: mem: platform fd map: 16384 bytes [1459869053:2011] NOTICE: mem: per-conn: 256 bytes + protocol rx buf [1459869053:2014] NOTICE: canonical_hostname = OpenWrt [1459869053:2018] NOTICE: Listening on port 1234 could not open directory plugins Segmentation fault

JUCI console log:

50-juci-jquery-console.js:3 RPC init 50-juci-jquery-console.js:3 connecting to rpc server at (ws:///websocket/) 50-juci-jquery-console.js:3 RPC connection established! 50-juci-jquery-console.js:3 connection closed! 50-juci-jquery-console.js:3 request timed out 50-juci-jquery-console.js:3 could not initialize rpc interface 50-juci-jquery-console.js:3 request timed out!

mkschreder commented 8 years ago

Does it work better if you specify the plugin dir like this: revorpcd -p /usr/lib/juci/api?

Are you starting and stopping directly or using /etc/init.d/juci?

haveyaseen commented 8 years ago

I started and stopped it directly. /etc/init.d/juci start spawns the process revorpcd -p /usr/lib/juci/api which, when started manually, gives the following output:

~# revorpcd -p /usr/lib/juci/api RevoRPCD v0.1.0 Copyright (c) 2016 Martin Schröder [1459872134:3998] NOTICE: Initial logging level 7 [1459872134:4005] NOTICE: Libwebsockets version: 1.6.0 3b54f5c [1459872134:4007] NOTICE: IPV6 not compiled in [1459872134:4009] NOTICE: libev support not compiled in [1459872134:4029] NOTICE: mem: platform fd map: 16384 bytes [1459872134:4032] NOTICE: mem: per-conn: 256 bytes + protocol rx buf [1459872134:4034] NOTICE: canonical_hostname = OpenWrt [1459872134:4038] NOTICE: Listening on port 1234 could not run plugin: /usr/lib/juci/api/juci/netmode.lua:4: module 'luv.fs' not found: no field package.preload['luv.fs'] no file '/usr/lib/juci/lib//luv/fs.lua' no file '/usr/lib/juci/lib//juci/luv/fs.lua' no file './luv/fs.lua' no file '/usr/share/lua/luv/fs.lua' no file '/usr/share/lua/luv/fs/init.lua' no file '/usr/lib/lua/luv/fs.lua' no file '/usr/lib/lua/luv/fs/init.lua' no file 'luv/fs.lua' no file './luv/fs.so' no file '/usr/lib/lua/luv/fs.so' no file '/usr/lib/lua/loadall.so' no file './luv.so' no file '/usr/lib/lua/luv.so' no file '/usr/lib/lua/loadall.so' ERR: could not load plugin /usr/lib/juci/api/juci/netmode.lua Segmentation fault

When started using the init script, it just dies after opening/reloading JUCI.

mkschreder commented 8 years ago

Why do you have netmode.lua there? That is not an openwrt-compatible plugin and it is not in latest default build either. Did you select all juci plugins instead of just selecting juci-full-openwrt and jucid?

haveyaseen commented 8 years ago

Yes, all plugins were selected during build. I'll unselect them and try again. Is juci-router-openwrt as important as its name suggests?

mkschreder commented 8 years ago

You should not select any inteno plugins. They are only for iopsys builds. I will remove them in next version to avoid such confusion..

mkschreder commented 8 years ago

It has been removed. I have just removed it from the menu as well. It was going to provide a "router" object, but most of that functionality has been put across the different other subsystems instead (such as network for instance)..

On Tue, Apr 5, 2016 at 6:13 PM, Jason notifications@github.com wrote:

Yes, all plugins were selected during build. I'll unselect them and try again. Is juci-router-openwrt as important as its name suggests?

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/mkschreder/jucid/issues/2#issuecomment-205877227

mk-f commented 8 years ago

I have the same problem with a clean build:

root@OpenWrt:~# revorpcd -p /usr/lib/juci/api
RevoRPCD v0.1.0
Copyright (c) 2016 Martin Schröder
[1459952132:5967] NOTICE: Initial logging level 7
[1459952132:5976] NOTICE: Libwebsockets version: 1.6.0 unknown-build-hash
[1459952132:5988] NOTICE: IPV6 not compiled in
[1459952132:5999] NOTICE: libev support not compiled in
[1459952132:6033] NOTICE:  mem: platform fd map: 16384 bytes
[1459952132:6044] NOTICE:  mem: per-conn:          256 bytes + protocol rx buf
[1459952132:6056] NOTICE:  canonical_hostname = OpenWrt
[1459952132:6070] NOTICE:  Listening on port 1234
Segmentation fault

Packages generated by build:

agetty_2.25.2-4_at91.ipk
blkdiscard_2.25.2-4_at91.ipk
blkid_2.25.2-4_at91.ipk
cal_2.25.2-4_at91.ipk
cfdisk_2.25.2-4_at91.ipk
dmesg_2.25.2-4_at91.ipk
dropbear_2015.71-2_at91.ipk
dropbearconvert_2015.71-2_at91.ipk
fdisk_2.25.2-4_at91.ipk
findfs_2.25.2-4_at91.ipk
flock_2.25.2-4_at91.ipk
getopt_2.25.2-4_at91.ipk
hwclock_2.25.2-4_at91.ipk
iwinfo_2016-01-25-e4aca3910dff532ed878d0ceaf1ab6e8ad7719bf_at91.ipk
jshn_2016-02-26-5326ce1046425154ab715387949728cfb09f4083_at91.ipk
juci-full-openwrt_2.0.3-3_at91.ipk
juci_2.16.03-2.16.03-eda7ee991f6a7cfbdd7742b6e956a6b802b3e594_at91.ipk
jucid_49c573252ed8a1c0972d241a30364d717237b31a_at91.ipk
libatomic_5.3.0-1_at91.ipk
libblkid_2.25.2-4_at91.ipk
libblobmsg-json_2016-02-26-5326ce1046425154ab715387949728cfb09f4083_at91.ipk
libblobpack_1.0.1-1_at91.ipk
libc_1.1.14-1_at91.ipk
libgcc_5.3.0-1_at91.ipk
libiwinfo-lua_2016-01-25-e4aca3910dff532ed878d0ceaf1ab6e8ad7719bf_at91.ipk
libiwinfo_2016-01-25-e4aca3910dff532ed878d0ceaf1ab6e8ad7719bf_at91.ipk
libjson-c_0.12-1_at91.ipk
libjson-script_2016-02-26-5326ce1046425154ab715387949728cfb09f4083_at91.ipk
liblua_5.1.5-1_at91.ipk
libmount_2.25.2-4_at91.ipk
libncurses_5.9-3_at91.ipk
libncursesw_5.9-3_at91.ipk
libnl-tiny_0.1-5_at91.ipk
libopenssl_1.0.2g-1_at91.ipk
libpcre16_8.38-2_at91.ipk
libpcre_8.38-2_at91.ipk
libpcrecpp_8.38-2_at91.ipk
libpthread_1.1.14-1_at91.ipk
libreadline_6.3-1_at91.ipk
librt_1.1.14-1_at91.ipk
libsmartcols_2.25.2-4_at91.ipk
libsqlite3_3120000-1_at91.ipk
libstdcpp_5.3.0-1_at91.ipk
libubox-lua_2016-02-26-5326ce1046425154ab715387949728cfb09f4083_at91.ipk
libubox_2016-02-26-5326ce1046425154ab715387949728cfb09f4083_at91.ipk
libubus-lua_2016-01-26-619f3a160de4f417226b69039538882787b3811c_at91.ipk
libubus_2016-01-26-619f3a160de4f417226b69039538882787b3811c_at91.ipk
libuci-lua_2016-02-02.1-1_at91.ipk
libuci_2016-02-02.1-1_at91.ipk
libusys_27c5f81c80a3ea113378f56d4fc0e8fd903e7abe-1.0.0_at91.ipk
libutype_7a5c74c80c037ffebd4f10c61b31b186c8a22fed-1.0.0_at91.ipk
libuuid_2.25.2-4_at91.ipk
libwebsockets_0c7e5a94182b8bf5b5be2fc58141466bf54d5812-1_at91.ipk
libxml2_2.9.3-1_at91.ipk
lighttpd-mod-access_1.4.33-2_at91.ipk
lighttpd-mod-accesslog_1.4.33-2_at91.ipk
lighttpd-mod-alias_1.4.33-2_at91.ipk
lighttpd-mod-auth_1.4.33-2_at91.ipk
lighttpd-mod-cgi_1.4.33-2_at91.ipk
lighttpd-mod-cml_1.4.33-2_at91.ipk
lighttpd-mod-compress_1.4.33-2_at91.ipk
lighttpd-mod-evasive_1.4.33-2_at91.ipk
lighttpd-mod-evhost_1.4.33-2_at91.ipk
lighttpd-mod-expire_1.4.33-2_at91.ipk
lighttpd-mod-extforward_1.4.33-2_at91.ipk
lighttpd-mod-fastcgi_1.4.33-2_at91.ipk
lighttpd-mod-flv-streaming_1.4.33-2_at91.ipk
lighttpd-mod-magnet_1.4.33-2_at91.ipk
lighttpd-mod-proxy_1.4.33-2_at91.ipk
lighttpd-mod-redirect_1.4.33-2_at91.ipk
lighttpd-mod-rewrite_1.4.33-2_at91.ipk
lighttpd-mod-rrdtool_1.4.33-2_at91.ipk
lighttpd-mod-scgi_1.4.33-2_at91.ipk
lighttpd-mod-secdownload_1.4.33-2_at91.ipk
lighttpd-mod-setenv_1.4.33-2_at91.ipk
lighttpd-mod-simple-vhost_1.4.33-2_at91.ipk
lighttpd-mod-ssi_1.4.33-2_at91.ipk
lighttpd-mod-status_1.4.33-2_at91.ipk
lighttpd-mod-trigger-b4-dl_1.4.33-2_at91.ipk
lighttpd-mod-userdir_1.4.33-2_at91.ipk
lighttpd-mod-usertrack_1.4.33-2_at91.ipk
lighttpd-mod-webdav_1.4.33-2_at91.ipk
lighttpd-mod-websocket_1.4.33-2_at91.ipk
lighttpd_1.4.33-2_at91.ipk
logger_2.25.2-4_at91.ipk
look_2.25.2-4_at91.ipk
losetup_2.25.2-4_at91.ipk
lsblk_2.25.2-4_at91.ipk
lua-examples_5.1.5-1_at91.ipk
lua_5.1.5-1_at91.ipk
luabitop_1.0.2-1_at91.ipk
luac_5.1.5-1_at91.ipk
luaposix33_v33.3.1-1_at91.ipk
luci-bwc_2015-01-10-105d5b36ce5c3e75891c30cd67722372bce997ab_at91.ipk
mcookie_2.25.2-4_at91.ipk
mount-utils_2.25.2-4_at91.ipk
namei_2.25.2-4_at91.ipk
openssl-util_1.0.2g-1_at91.ipk
partx-utils_2.25.2-4_at91.ipk
prlimit_2.25.2-4_at91.ipk
rename_2.25.2-4_at91.ipk
rpcd-mod-file_2015-01-10-f00890cd6eb47ad9bb5da0fb6c50aedc8406e7c5_at91.ipk
rpcd-mod-iwinfo_2015-01-10-f00890cd6eb47ad9bb5da0fb6c50aedc8406e7c5_at91.ipk
rpcd-mod-rpcsys_2015-01-10-f00890cd6eb47ad9bb5da0fb6c50aedc8406e7c5_at91.ipk
rpcd_2015-01-10-f00890cd6eb47ad9bb5da0fb6c50aedc8406e7c5_at91.ipk
script-utils_2.25.2-4_at91.ipk
setterm_2.25.2-4_at91.ipk
sfdisk_2.25.2-4_at91.ipk
sqlite3-cli_3120000-1_at91.ipk
swap-utils_2.25.2-4_at91.ipk
terminfo_5.9-3_at91.ipk
ubus_2016-01-26-619f3a160de4f417226b69039538882787b3811c_at91.ipk
ubusd_2016-01-26-619f3a160de4f417226b69039538882787b3811c_at91.ipk
uci_2016-02-02.1-1_at91.ipk
uuidd_2.25.2-4_at91.ipk
uuidgen_2.25.2-4_at91.ipk
wall_2.25.2-4_at91.ipk
whereis_2.25.2-4_at91.ipk
wipefs_2.25.2-4_at91.ipk
zlib-dev_1.2.8-1_at91.ipk
zlib_1.2.8-1_at91.ipk

strace: https://github.com/mk-f/logs/blob/master/revorpcd_strace

mk-f commented 8 years ago

GDB-Trace:

(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: playground/OpenWrt-SDK-at91-legacy_gcc-5.3.0_musl-1.1.14_eabi.Linux-x86_64/build_dir/target-arm_arm926ej-s_musl-1.1.14_eabi/jucid-49c573252ed8a1c0972d241a30364d717237b31a/src/revorpcd -p /usr/lib/juci/api
[New Thread 4894.4895]

Thread 2 "revorpcd" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 4894.4895]
0xb6f693f4 in JSON_DecodeObject (
    dec=<error reading variable: Cannot access memory at address 0xb6e4878c>, 
    buffer=<error reading variable: Cannot access memory at address 0xb6e48788>, 
    cbBuffer=<error reading variable: Cannot access memory at address 0xb6e48784>)
    at ujsondec.c:865
865 {
(gdb) 
mkschreder commented 8 years ago

what does "bt" say?

I was not able to reproduce your bug. I did fix a few bugs in the json parser that would make it crash on invalid input, however I think there could be more. It looks like you get the crash when decoding an invalid json string. It would be helpful to know the content of that string.

You can also run with "-vvv" to print more information.

On Thu, Apr 7, 2016 at 4:14 PM, Fabian Müller-Knapp < notifications@github.com> wrote:

GDB-Trace:

(gdb) run The program being debugged has been started already. Start it from the beginning? (y or n) y Starting program: playground/OpenWrt-SDK-at91-legacy_gcc-5.3.0_musl-1.1.14_eabi.Linux-x86_64/build_dir/target-arm_arm926ej-s_musl-1.1.14_eabi/jucid-49c573252ed8a1c0972d241a30364d717237b31a/src/revorpcd -p /usr/lib/juci/api [New Thread 4894.4895]

Thread 2 "revorpcd" received signal SIGSEGV, Segmentation fault. [Switching to Thread 4894.4895] 0xb6f693f4 in JSON_DecodeObject ( dec=<error reading variable: Cannot access memory at address 0xb6e4878c>, buffer=<error reading variable: Cannot access memory at address 0xb6e48788>, cbBuffer=<error reading variable: Cannot access memory at address 0xb6e48784>) at ujsondec.c:865 865 { (gdb)

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/mkschreder/jucid/issues/2#issuecomment-206925674

mk-f commented 8 years ago

Thanks for the reply, i'm currently not in town, i will look in to this next week.

mk-f commented 8 years ago

Here comes the gdb-output:

RevoRPCD v0.1.0
Copyright (c) 2016 Martin Schröder
[1460462360:1679] NOTICE: Initial logging level 7
[1460462360:1680] NOTICE: Libwebsockets version: 1.6.0 faa984a
[1460462360:1681] NOTICE: IPV6 not compiled in
[1460462360:1682] NOTICE: libev support not compiled in
[1460462360:1734] NOTICE:  mem: platform fd map: 16384 bytes
[1460462360:1744] NOTICE:  mem: per-conn:          256 bytes + protocol rx buf
[1460462360:1756] NOTICE:  canonical_hostname = OpenWrt
[1460462360:1769] NOTICE:  Listening on port 1234
loading passwords from /etc/juci-shadow
loading plugin /file of /usr/lib/juci/api/file.lua at base /usr/lib/juci/api
loading plugin /uci of /usr/lib/juci/api/uci.lua at base /usr/lib/juci/api
loading plugin /network.interface of /usr/lib/juci/api/network.interface.lua at base /usr/lib/juci/api
loading plugin /juci/upnpd of /usr/lib/juci/api/juci/upnpd.lua at base /usr/lib/juci/api
loading plugin /juci/usb of /usr/lib/juci/api/juci/usb.lua at base /usr/lib/juci/api
loading plugin /juci/ddns of /usr/lib/juci/api/juci/ddns.lua at base /usr/lib/juci/api
loading plugin /juci/firewall.dmz of /usr/lib/juci/api/juci/firewall.dmz.lua at base /usr/lib/juci/api
loading plugin /juci/logs of /usr/lib/juci/api/juci/logs.lua at base /usr/lib/juci/api
loading plugin /juci/iptv of /usr/lib/juci/api/juci/iptv.lua at base /usr/lib/juci/api
loading plugin /juci/ui of /usr/lib/juci/api/juci/ui.lua at base /usr/lib/juci/api
loading plugin /juci/wireless of /usr/lib/juci/api/juci/wireless.lua at base /usr/lib/juci/api
loading plugin /juci/network of /usr/lib/juci/api/juci/network.lua at base /usr/lib/juci/api
loading plugin /juci/samba of /usr/lib/juci/api/juci/samba.lua at base /usr/lib/juci/api
loading plugin /juci/macdb of /usr/lib/juci/api/juci/macdb.lua at base /usr/lib/juci/api
loading plugin /juci/minidlna of /usr/lib/juci/api/juci/minidlna.lua at base /usr/lib/juci/api
loading plugin /juci/dropbear of /usr/lib/juci/api/juci/dropbear.lua at base /usr/lib/juci/api
loading plugin /juci/rtgraphs of /usr/lib/juci/api/juci/rtgraphs.lua at base /usr/lib/juci/api
loading plugin /juci/system.conf of /usr/lib/juci/api/juci/system.conf.lua at base /usr/lib/juci/api
loading plugin /juci/ethernet of /usr/lib/juci/api/juci/ethernet.lua at base /usr/lib/juci/api
loading plugin /juci/dhcp of /usr/lib/juci/api/juci/dhcp.lua at base /usr/lib/juci/api
loading plugin /juci/network.status of /usr/lib/juci/api/juci/network.status.lua at base /usr/lib/juci/api
loading plugin /juci/system.service of /usr/lib/juci/api/juci/system.service.lua at base /usr/lib/juci/api
loading plugin /juci/modems of /usr/lib/juci/api/juci/modems.lua at base /usr/lib/juci/api
loading plugin /juci/swconfig of /usr/lib/juci/api/juci/swconfig.lua at base /usr/lib/juci/api
loading plugin /juci/system.time of /usr/lib/juci/api/juci/system.time.lua at base /usr/lib/juci/api
loading plugin /juci/system of /usr/lib/juci/api/juci/system.lua at base /usr/lib/juci/api
loading plugin /juci/diagnostics of /usr/lib/juci/api/juci/diagnostics.lua at base /usr/lib/juci/api
loading plugin /juci/system.upgrade of /usr/lib/juci/api/juci/system.upgrade.lua at base /usr/lib/juci/api
loading plugin /juci/system.process of /usr/lib/juci/api/juci/system.process.lua at base /usr/lib/juci/api
loading plugin /juci/system.user of /usr/lib/juci/api/juci/system.user.lua at base /usr/lib/juci/api
loading plugin /system of /usr/lib/juci/api/system.lua at base /usr/lib/juci/api
loading plugin /session of /usr/lib/juci/api/session.lua at base /usr/lib/juci/api
connection established! localhost 127.0.0.1 8 73331be8
received fragment of 91 bytes
GNU gdb (GDB) 7.11
Copyright (C) 2016 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 "--host=x86_64-linux-gnu --target=arm-openwrt-linux-muslgnueabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from build_dir/target-arm_arm926ej-s_musl-1.1.14_eabi/jucid-49c573252ed8a1c0972d241a30364d717237b31a/src/revorpcd...done.
(gdb) set args -p /usr/lib/juci/api -vvv
(gdb) run
Starting program: /home/fabian/playground/openwrt/build_dir/target-arm_arm926ej-s_musl-1.1.14_eabi/jucid-49c573252ed8a1c0972d241a30364d717237b31a/src/revorpcd -p /usr/lib/juci/api -vvv
[New Thread 1140.1141]

Thread 2 "revorpcd" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1140.1141]
JSON_DecodeObject (dec=dec@entry=0xb6e7c888, 
    buffer=buffer@entry=0x380170 "{\"jsonrpc\":\"2.0\",\"id\":2,\"method\":\"list\",\"params\":[\"", '0' <repeats 32 times>, "\",\"*\"]}\n", cbBuffer=<optimized out>) at ujsondec.c:873
873     ds.end = ds.start + cbBuffer;
(gdb) bt
#0  JSON_DecodeObject (dec=dec@entry=0xb6e7c888, 
    buffer=buffer@entry=0x380170 "{\"jsonrpc\":\"2.0\",\"id\":2,\"method\":\"list\",\"params\":[\"", '0' <repeats 32 times>, "\",\"*\"]}\n", cbBuffer=<optimized out>) at ujsondec.c:873
#1  0xb6f6883c in blob_put_json (self=<optimized out>, 
    json=json@entry=0x380170 "{\"jsonrpc\":\"2.0\",\"id\":2,\"method\":\"list\",\"params\":[\"", '0' <repeats 32 times>, "\",\"*\"]}\n") at blob_ujson.c:159
#2  0x00015ec8 in _ubus_socket_callback (wsi=wsi@entry=0xb6f3c490, reason=LWS_CALLBACK_RECEIVE, 
    _user=0x36f2b0, in=0x380170, in@entry=0x15ad4 <_ubus_socket_callback>, len=91, 
    len@entry=3069330172) at juci_ws_server.c:221
#3  0xb6f21be4 in user_callback_handle_rxflow (callback_function=0x15ad4 <_ubus_socket_callback>, 
    wsi=0xb6f3c490, reason=<optimized out>, user=<optimized out>, in=0x380170, len=91)
    at /home/fabian/playground/openwrt/build_dir/target-arm_arm926ej-s_musl-1.1.14_eabi/libwebsockets-0c7e5a94182b8bf5b5be2fc58141466bf54d5812/lib/libwebsockets.c:665
#4  0xb6f242fc in lws_rx_sm (wsi=wsi@entry=0xb6f3c490, c=<optimized out>)
    at /home/fabian/playground/openwrt/build_dir/target-arm_arm926ej-s_musl-1.1.14_eabi/libwebsockets-0c7e5a94182b8bf5b5be2fc58141466bf54d5812/lib/parsers.c:1151
#5  0xb6f28e50 in lws_interpret_incoming_packet (wsi=wsi@entry=0xb6f3c490, 
    buf=0x29050 "\201\333\063\221GiH\263-\032\\\377\065\031P\263}K\001\277wK\037\263.\r\021\253uE\021\374\"\035[\376#K\t\263+", len=len@entry=97)
    at /home/fabian/playground/openwrt/build_dir/target-arm_arm926ej-s_musl-1.1.14_eabi/libwebsockets-0c7e5a94182b8bf5b5be2fc58141466bf54d5812/lib/server.c:964
#6  0xb6f20cf4 in lws_read (wsi=wsi@entry=0xb6f3c490, 
    buf=0x29010 "\275\343\fW\224u\362\266lu\362\266tu\362\266\fu\362\266<u\362\266\220'\003", 
    len=97)
    at /home/fabian/playground/openwrt/build_dir/target-arm_arm926ej-s_musl-1.1.14_eabi/libwebsockets-0c7e5a94182b8bf5b5be2fc58141466bf54d5812/lib/handshake.c:188
#7  0xb6f222c0 in lws_service_fd (context=context@entry=0x29010, pollfd=0x327a0)
    at /home/fabian/playground/openwrt/build_dir/target-arm_arm926ej-s_musl-1.1.14_eabi/libwebsockets-0c7e5a94182b8bf5b5be2fc58141466bf54d5812/lib/service.c:582
---Type <return> to continue, or q <return> to quit---
#8  0xb6f2784c in lws_plat_service (context=0x29010, timeout_ms=timeout_ms@entry=10)
    at /home/fabian/playground/openwrt/build_dir/target-arm_arm926ej-s_musl-1.1.14_eabi/libwebsockets-0c7e5a94182b8bf5b5be2fc58141466bf54d5812/lib/lws-plat-unix.c:187
#9  0xb6f22378 in lws_service (context=<optimized out>, timeout_ms=timeout_ms@entry=10)
    at /home/fabian/playground/openwrt/build_dir/target-arm_arm926ej-s_musl-1.1.14_eabi/libwebsockets-0c7e5a94182b8bf5b5be2fc58141466bf54d5812/lib/service.c:679
#10 0x000154b0 in _websocket_server_thread (ptr=0xb6f4ee50) at juci_ws_server.c:339
#11 0xb6fd64a8 in start (p=0xb6e7cd20) at src/thread/pthread_create.c:145
#12 0xb6fd4c94 in __clone () at src/thread/arm/clone.s:25

in a fresh run:

(gdb) p ds
Cannot access memory at address 0xb6e5c84c
(gdb) i f
Stack level 0, frame at 0xb6e7c888:
 pc = 0xb6f6aa00 in JSON_DecodeObject (ujsondec.c:873); saved pc = 0xb6f6883c
 called by frame at 0xb6e7c8e0
 source language c.
 Arglist at 0xb6e5c848, args: dec=dec@entry=0xb6e7c888, 
    buffer=buffer@entry=0x380170 "{\"jsonrpc\":\"2.0\",\"id\":2,\"method\":\"list\",\"params\":[\"", '0' <repeats 32 times>, "\",\"*\"]}\n", cbBuffer=<optimized out>
 Locals at 0xb6e5c848, Previous frame's sp is 0xb6e7c888
 Saved registers:
  r4 at 0xb6e7c874, r5 at 0xb6e7c878, r6 at 0xb6e7c87c, r7 at 0xb6e7c880, lr at 0xb6e7c884
mk-f commented 8 years ago

Okay, for some reason struct DecoderState ds; and wchar_t escBuffer of JSON_DecodeObject in libblobpack are not accessible as long as they are in local scope. Making them both global in ujsondec.c does remove the segfault (but i'm still not able to use juci, and there is no ubus-scriptd). Could this be a threading-issue?

mkschreder commented 8 years ago

no. If it was a threading issue, making them global would certainly not make things better unless proper locking is also used. I think it is happening because memory that is being accessed has probably been freed already. I have not had the chance to do any testing using info from your previous email. What I did notice though was a stray " in the json input. I don't know whether it was just a glitch in the email formatting or if that was the input it was really parsing. Make sure you're also using v2.16.04 of juci feed and not master. I will look into this as soon as I have time. On 14 Apr 2016 16:36, "Fabian Müller-Knapp" notifications@github.com wrote:

Okay, for some reason struct DecoderState ds; and wchar_t escBuffer of JSON_DecodeObject in libblobpack are not accessible as long as they are in local scope. Making them both global in ujsondec.c does remove the segfault (but i'm still not able to use juci, and there is no ubus-scriptd). Could this be a threading-issue?

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/mkschreder/jucid/issues/2#issuecomment-209974355

mk-f commented 8 years ago

I tried with v2.16.04 which crashed the same as master. After making the same changes to ujsondec.c im still not able to log in:

root@OpenWrt:/etc/config# revorpcd -p /usr/lib/juci/api/ -v
vv
RevoRPCD v0.1.0
Copyright (c) 2016 Martin Schröder
[1461065367:2197] NOTICE: Initial logging level 7
[1461065367:2205] NOTICE: Libwebsockets version: 1.6.0 281aefa
[1461065367:2216] NOTICE: IPV6 not compiled in
[1461065367:2226] NOTICE: libev support not compiled in
[1461065367:2254] NOTICE:  mem: platform fd map: 16384 bytes
[1461065367:2264] NOTICE:  mem: per-conn:          256 bytes + protocol rx buf
[1461065367:2274] NOTICE:  canonical_hostname = OpenWrt
[1461065367:2286] NOTICE:  Listening on port 1234
loading passwords from /etc/juci-shadow
loading plugin /file of /usr/lib/juci/api//file.lua at base /usr/lib/juci/api/
loading plugin /uci of /usr/lib/juci/api//uci.lua at base /usr/lib/juci/api/
loading plugin /network.interface of /usr/lib/juci/api//network.interface.lua at base /usr/lib/juci/api/
loading plugin /juci/upnpd of /usr/lib/juci/api//juci/upnpd.lua at base /usr/lib/juci/api/
loading plugin /juci/usb of /usr/lib/juci/api//juci/usb.lua at base /usr/lib/juci/api/
loading plugin /juci/ddns of /usr/lib/juci/api//juci/ddns.lua at base /usr/lib/juci/api/
loading plugin /juci/firewall.dmz of /usr/lib/juci/api//juci/firewall.dmz.lua at base /usr/lib/juci/api/
loading plugin /juci/logs of /usr/lib/juci/api//juci/logs.lua at base /usr/lib/juci/api/
loading plugin /juci/iptv of /usr/lib/juci/api//juci/iptv.lua at base /usr/lib/juci/api/
loading plugin /juci/ui of /usr/lib/juci/api//juci/ui.lua at base /usr/lib/juci/api/
loading plugin /juci/wireless of /usr/lib/juci/api//juci/wireless.lua at base /usr/lib/juci/api/
loading plugin /juci/network of /usr/lib/juci/api//juci/network.lua at base /usr/lib/juci/api/
loading plugin /juci/samba of /usr/lib/juci/api//juci/samba.lua at base /usr/lib/juci/api/
loading plugin /juci/macdb of /usr/lib/juci/api//juci/macdb.lua at base /usr/lib/juci/api/
loading plugin /juci/minidlna of /usr/lib/juci/api//juci/minidlna.lua at base /usr/lib/juci/api/
loading plugin /juci/dropbear of /usr/lib/juci/api//juci/dropbear.lua at base /usr/lib/juci/api/
loading plugin /juci/rtgraphs of /usr/lib/juci/api//juci/rtgraphs.lua at base /usr/lib/juci/api/
loading plugin /juci/system.conf of /usr/lib/juci/api//juci/system.conf.lua at base /usr/lib/juci/api/
loading plugin /juci/ethernet of /usr/lib/juci/api//juci/ethernet.lua at base /usr/lib/juci/api/
loading plugin /juci/dhcp of /usr/lib/juci/api//juci/dhcp.lua at base /usr/lib/juci/api/
loading plugin /juci/network.status of /usr/lib/juci/api//juci/network.status.lua at base /usr/lib/juci/api/
loading plugin /juci/system.service of /usr/lib/juci/api//juci/system.service.lua at base /usr/lib/juci/api/
loading plugin /juci/modems of /usr/lib/juci/api//juci/modems.lua at base /usr/lib/juci/api/
loading plugin /juci/swconfig of /usr/lib/juci/api//juci/swconfig.lua at base /usr/lib/juci/api/
loading plugin /juci/system.time of /usr/lib/juci/api//juci/system.time.lua at base /usr/lib/juci/api/
loading plugin /juci/system of /usr/lib/juci/api//juci/system.lua at base /usr/lib/juci/api/
loading plugin /juci/diagnostics of /usr/lib/juci/api//juci/diagnostics.lua at base /usr/lib/juci/api/
loading plugin /juci/system.upgrade of /usr/lib/juci/api//juci/system.upgrade.lua at base /usr/lib/juci/api/
loading plugin /juci/system.process of /usr/lib/juci/api//juci/system.process.lua at base /usr/lib/juci/api/
loading plugin /juci/system.user of /usr/lib/juci/api//juci/system.user.lua at base /usr/lib/juci/api/
loading plugin /system of /usr/lib/juci/api//system.lua at base /usr/lib/juci/api/
loading plugin /session of /usr/lib/juci/api//session.lua at base /usr/lib/juci/api/
connection established! localhost 127.0.0.1 8 63eb04ca
received fragment of 59 bytes
waited 0s 7504377ns for message
got message from 63eb04ca: [{"jsonrpc":"2.0","id":45,"method":"challenge","params":[]}]
sending back: [{"jsonrpc":"2.0","id":45,"result":{"token":"63eb04ca"}}]
sent 57 out of 57 bytes
received fragment of 96 bytes
waited 0s 4215632ns for message
got message from 63eb04ca: [{"jsonrpc":"2.0","id":46,"method":"authenticate","params":["00000000000000000000000000000000"]}]
sending back: [{"jsonrpc":"2.0","id":46,"error":"Access Denied"}]
sent 51 out of 51 bytes
received fragment of 105 bytes
waited 0s 5302241ns for message
got message from 63eb04ca: [{"jsonrpc":"2.0","id":47,"method":"login","params":["admin","4afe9637dfee32211bbf1945ede1362582946725"]}]
sending back: [{"jsonrpc":"2.0","id":47,"result":{"error":"EACCESS"}}]
sent 56 out of 56 bytes
received fragment of 96 bytes
waited 0s 4939118ns for message
got message from 63eb04ca: [{"jsonrpc":"2.0","id":48,"method":"authenticate","params":["00000000000000000000000000000000"]}]
sending back: [{"jsonrpc":"2.0","id":48,"error":"Access Denied"}]
sent 51 out of 51 bytes
received fragment of 96 bytes
waited 0s 14477991ns for message
got message from 63eb04ca: [{"jsonrpc":"2.0","id":49,"method":"authenticate","params":["00000000000000000000000000000000"]}]
sending back: [{"jsonrpc":"2.0","id":49,"error":"Access Denied"}]
mkschreder commented 8 years ago

Looks like you don't have a password setup. Check /etc/juci-shadow for a line like "admin "

On Tue, Apr 19, 2016 at 1:58 PM, Fabian Müller-Knapp < notifications@github.com> wrote:

I tried with v2.16.04 which crashed the same as master. After making the same changes to ujsondec.c im still not able to log in:

root@OpenWrt:/etc/config# revorpcd -p /usr/lib/juci/api/ -v vv RevoRPCD v0.1.0 Copyright (c) 2016 Martin Schröder [1461065367:2197] NOTICE: Initial logging level 7 [1461065367:2205] NOTICE: Libwebsockets version: 1.6.0 281aefa [1461065367:2216] NOTICE: IPV6 not compiled in [1461065367:2226] NOTICE: libev support not compiled in [1461065367:2254] NOTICE: mem: platform fd map: 16384 bytes [1461065367:2264] NOTICE: mem: per-conn: 256 bytes + protocol rx buf [1461065367:2274] NOTICE: canonical_hostname = OpenWrt [1461065367:2286] NOTICE: Listening on port 1234 loading passwords from /etc/juci-shadow loading plugin /file of /usr/lib/juci/api//file.lua at base /usr/lib/juci/api/ loading plugin /uci of /usr/lib/juci/api//uci.lua at base /usr/lib/juci/api/ loading plugin /network.interface of /usr/lib/juci/api//network.interface.lua at base /usr/lib/juci/api/ loading plugin /juci/upnpd of /usr/lib/juci/api//juci/upnpd.lua at base /usr/lib/juci/api/ loading plugin /juci/usb of /usr/lib/juci/api//juci/usb.lua at base /usr/lib/juci/api/ loading plugin /juci/ddns of /usr/lib/juci/api//juci/ddns.lua at base /usr/lib/juci/api/ loading plugin /juci/firewall.dmz of /usr/lib/juci/api//juci/firewall.dmz.lua at base /usr/lib/juci/api/ loading plugin /juci/logs of /usr/lib/juci/api//juci/logs.lua at base /usr/lib/juci/api/ loading plugin /juci/iptv of /usr/lib/juci/api//juci/iptv.lua at base /usr/lib/juci/api/ loading plugin /juci/ui of /usr/lib/juci/api//juci/ui.lua at base /usr/lib/juci/api/ loading plugin /juci/wireless of /usr/lib/juci/api//juci/wireless.lua at base /usr/lib/juci/api/ loading plugin /juci/network of /usr/lib/juci/api//juci/network.lua at base /usr/lib/juci/api/ loading plugin /juci/samba of /usr/lib/juci/api//juci/samba.lua at base /usr/lib/juci/api/ loading plugin /juci/macdb of /usr/lib/juci/api//juci/macdb.lua at base /usr/lib/juci/api/ loading plugin /juci/minidlna of /usr/lib/juci/api//juci/minidlna.lua at base /usr/lib/juci/api/ loading plugin /juci/dropbear of /usr/lib/juci/api//juci/dropbear.lua at base /usr/lib/juci/api/ loading plugin /juci/rtgraphs of /usr/lib/juci/api//juci/rtgraphs.lua at base /usr/lib/juci/api/ loading plugin /juci/system.conf of /usr/lib/juci/api//juci/system.conf.lua at base /usr/lib/juci/api/ loading plugin /juci/ethernet of /usr/lib/juci/api//juci/ethernet.lua at base /usr/lib/juci/api/ loading plugin /juci/dhcp of /usr/lib/juci/api//juci/dhcp.lua at base /usr/lib/juci/api/ loading plugin /juci/network.status of /usr/lib/juci/api//juci/network.status.lua at base /usr/lib/juci/api/ loading plugin /juci/system.service of /usr/lib/juci/api//juci/system.service.lua at base /usr/lib/juci/api/ loading plugin /juci/modems of /usr/lib/juci/api//juci/modems.lua at base /usr/lib/juci/api/ loading plugin /juci/swconfig of /usr/lib/juci/api//juci/swconfig.lua at base /usr/lib/juci/api/ loading plugin /juci/system.time of /usr/lib/juci/api//juci/system.time.lua at base /usr/lib/juci/api/ loading plugin /juci/system of /usr/lib/juci/api//juci/system.lua at base /usr/lib/juci/api/ loading plugin /juci/diagnostics of /usr/lib/juci/api//juci/diagnostics.lua at base /usr/lib/juci/api/ loading plugin /juci/system.upgrade of /usr/lib/juci/api//juci/system.upgrade.lua at base /usr/lib/juci/api/ loading plugin /juci/system.process of /usr/lib/juci/api//juci/system.process.lua at base /usr/lib/juci/api/ loading plugin /juci/system.user of /usr/lib/juci/api//juci/system.user.lua at base /usr/lib/juci/api/ loading plugin /system of /usr/lib/juci/api//system.lua at base /usr/lib/juci/api/ loading plugin /session of /usr/lib/juci/api//session.lua at base /usr/lib/juci/api/ connection established! localhost 127.0.0.1 8 63eb04ca received fragment of 59 bytes waited 0s 7504377ns for message got message from 63eb04ca: [{"jsonrpc":"2.0","id":45,"method":"challenge","params":[]}] sending back: [{"jsonrpc":"2.0","id":45,"result":{"token":"63eb04ca"}}] sent 57 out of 57 bytes received fragment of 96 bytes waited 0s 4215632ns for message got message from 63eb04ca: [{"jsonrpc":"2.0","id":46,"method":"authenticate","params":["00000000000000000000000000000000"]}] sending back: [{"jsonrpc":"2.0","id":46,"error":"Access Denied"}] sent 51 out of 51 bytes received fragment of 105 bytes waited 0s 5302241ns for message got message from 63eb04ca: [{"jsonrpc":"2.0","id":47,"method":"login","params":["admin","4afe9637dfee32211bbf1945ede1362582946725"]}] sending back: [{"jsonrpc":"2.0","id":47,"result":{"error":"EACCESS"}}] sent 56 out of 56 bytes received fragment of 96 bytes waited 0s 4939118ns for message got message from 63eb04ca: [{"jsonrpc":"2.0","id":48,"method":"authenticate","params":["00000000000000000000000000000000"]}] sending back: [{"jsonrpc":"2.0","id":48,"error":"Access Denied"}] sent 51 out of 51 bytes received fragment of 96 bytes waited 0s 14477991ns for message got message from 63eb04ca: [{"jsonrpc":"2.0","id":49,"method":"authenticate","params":["00000000000000000000000000000000"]}] sending back: [{"jsonrpc":"2.0","id":49,"error":"Access Denied"}]

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/mkschreder/jucid/issues/2#issuecomment-211881528

mk-f commented 8 years ago

I have:

root@OpenWrt:~# cat /etc/juci-shadow 
admin 098f6bcd4621d373cade4e832627b4f6

which is the result of: printf 'test' | md5sum | awk '{printf $1}' I also tried sha1sum instead.

mkschreder commented 8 years ago

admin a94a8fe5ccb19ba61c4c0873d391e987982fbbd3

You can only use sha1sum. md5sum was a typo.

mkschreder commented 8 years ago

Server sends you a token which is unique for each connection. Your browser does sha1(token + sha1(password)) and sends back the result (which is what you are seeing up there 4afe9637dfee32211bbf1945ede1362582946725). Server does the same thing but using the hash in the shadow file. If both are the same you will be logged in. Looks like something goes wrong somewhere inbetween for you. Are you sure it is not the changes you have made to json library?

mk-f commented 8 years ago

I tried with sha1 already - same result. Actually im not sure if this also concerns the json-library, ill keep digging.

mk-f commented 8 years ago

As valgrind is not available for armv5, i have build jucid against d.u.m.a (http://duma.sourceforge.net/) in hope of caching some memory corruptions but i had no luck. Jucid does now segfault as soon as it tries to load plugins:


root@OpenWrt:~# ./start_gdb_revorpcd.sh 
Process revorpcd created; pid = 1191
Listening on port 9000
Remote debugging from host 192.168.3.151
DUMA 2.5.15 (shared library, NO_LEAKDETECTION)
Copyright (C) 2006 Michael Eddington <meddington@gmail.com>
Copyright (C) 2002-2008 Hayati Ayguen <h_ayguen@web.de>, Procitec GmbH
Copyright (C) 1987-1999 Bruce Perens <bruce@perens.com>

RevoRPCD v0.1.0
Copyright (c) 2016 Martin Schröder
[1463033414:4294] NOTICE: Initial logging level 7
[1463033414:4296] NOTICE: Libwebsockets version: 1.6.0 cda52dc
[1463033414:4297] NOTICE: IPV6 not compiled in
[1463033414:4299] NOTICE: libev support not compiled in
[1463033414:4441] NOTICE:  mem: platform fd map: 16384 bytes
[1463033414:4450] NOTICE:  mem: per-conn:          256 bytes + protocol rx buf
[1463033414:4455] NOTICE:  canonical_hostname = OpenWrt
[1463033414:4477] NOTICE:  Listening on port 1234
loading passwords from /etc/juci-shadow
loading plugin /network.interface of /usr/lib/juci/api/network.interface.lua at base /usr/lib/juci/api
[New Thread 1191.1192]

Thread 1 "revorpcd" received signal SIGSEGV, Segmentation fault.
luaS_newlstr (L=0xb6ca2e80, str=0xb6ecfbcd "__le", l=4) at lstring.c:86
86      if (ts->tsv.len == l && (memcmp(str, getstr(ts), l) == 0)) {
(gdb) bt
#0  luaS_newlstr (L=0xb6ca2e80, str=0xb6ecfbcd "__le", l=4) at lstring.c:86
#1  0xb6ec257c in luaT_init (L=L@entry=0xb6ca2e80) at ltm.c:39
#2  0xb6ec10cc in f_luaopen (L=0xb6ca2e80, ud=<optimized out>) at lstate.c:77
#3  0xb6eba808 in luaD_rawrunprotected (L=0xb6eba808 <luaD_rawrunprotected+64>, L@entry=0xb6ca2e80, f=0xbefffbd0, 
    ud=0xb6ca2e80, ud@entry=0x0) at ldo.c:116
#4  0xb6ec13e8 in lua_newstate (f=0xb6ec5ac8 <l_alloc>, ud=ud@entry=0x0) at lstate.c:182
#5  0xb6ec6cfc in luaL_newstate () at lauxlib.c:658
#6  0x00012f58 in juci_luaobject_new (name=name@entry=0xbefffbe0 "/network.interface") at juci_luaobject.c:29
#7  0x00014934 in juci_load_plugins (self=self@entry=0xb6c84fa0, path=0xb6c9afee "/usr/lib/juci/api", 
    base_path=0xb6c9afee "/usr/lib/juci/api", base_path@entry=0x0) at juci.c:76
#8  0x00014dbc in juci_new (plugin_path=0xb6c84fd8 "\330Oȶ\330Oȶ", 
    plugin_path@entry=0xbeffff70 "/usr/lib/juci/api", pwfile=pwfile@entry=0x174c5 "/etc/juci-shadow") at juci.c:171
#9  0x000122b4 in main (argc=-1090519660, argv=0xbefffe74) at main.c:147
(gdb) i lo
ts = 0xe8b6cb2f
o = 0xe8b6cb2f
h = 7405070
step = 1
l1 = <optimized out>
(gdb) i f
Stack level 0, frame at 0xbefff8a8:
 pc = 0xb6ec15b8 in luaS_newlstr (lstring.c:86); saved pc = 0xb6ec257c
 called by frame at 0xbefff8c8
 source language c.
 Arglist at 0xbefff888, args: L=0xb6ca2e80, str=0xb6ecfbcd "__le", l=4
 Locals at 0xbefff888, Previous frame's sp is 0xbefff8a8
 Saved registers:
  r4 at 0xbefff888, r5 at 0xbefff88c, r6 at 0xbefff890, r7 at 0xbefff894, r8 at 0xbefff898, r9 at 0xbefff89c,
  r10 at 0xbefff8a0, lr at 0xbefff8a4
(gdb) p ts->tsv.len
Cannot access memory at address 0xe8b6cb3b

I doubt that luaS_* is realy the culprit - again this looks like touching already freed memory, ts is somehow not accessible. Do you have any idea what could cause this?

juci-openwrt-feed v2.16.05

mk-f commented 8 years ago

Full backtrace:

(gdb) thread apply all where

Thread 2 (Thread 1191.1192):
#0  __cp_begin () at src/thread/arm/syscall_cp.s:23
#1  0xb6fd5858 in __syscall_cp_c (nr=162, u=<optimized out>, v=<optimized out>, w=<optimized out>, x=-1224907740, 
    y=-1228567288, z=120) at src/thread/pthread_cancel.c:35
#2  0xb6c62f78 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 1 (Thread 1191.1191):
#0  luaS_newlstr (L=0xb6ca2e80, str=0xb6ecfbcd "__le", l=4) at lstring.c:86
#1  0xb6ec257c in luaT_init (L=L@entry=0xb6ca2e80) at ltm.c:39
#2  0xb6ec10cc in f_luaopen (L=0xb6ca2e80, ud=<optimized out>) at lstate.c:77
#3  0xb6eba808 in luaD_rawrunprotected (L=0xb6eba808 <luaD_rawrunprotected+64>, L@entry=0xb6ca2e80, f=0xbefffbd0, 
    ud=0xb6ca2e80, ud@entry=0x0) at ldo.c:116
#4  0xb6ec13e8 in lua_newstate (f=0xb6ec5ac8 <l_alloc>, ud=ud@entry=0x0) at lstate.c:182
#5  0xb6ec6cfc in luaL_newstate () at lauxlib.c:658
#6  0x00012f58 in juci_luaobject_new (name=name@entry=0xbefffbe0 "/network.interface") at juci_luaobject.c:29
#7  0x00014934 in juci_load_plugins (self=self@entry=0xb6c84fa0, path=0xb6c9afee "/usr/lib/juci/api", 
    base_path=0xb6c9afee "/usr/lib/juci/api", base_path@entry=0x0) at juci.c:76
#8  0x00014dbc in juci_new (plugin_path=0xb6c84fd8 "\330Oȶ\330Oȶ", 
    plugin_path@entry=0xbeffff70 "/usr/lib/juci/api", pwfile=pwfile@entry=0x174c5 "/etc/juci-shadow") at juci.c:171
#9  0x000122b4 in main (argc=-1090519660, argv=0xbefffe74) at main.c:147
(gdb) 
mkschreder commented 8 years ago

That does not say much. It could be a faulty lua plugin. I have run it through valgrind before though. It should be pretty clear but the json parser is buggy right now when it gets invalid input. You can build it locally too and run it through valgrind if you want. On 31 May 2016 19:09, "Fabian Müller-Knapp" notifications@github.com wrote:

Full backtrace:

(gdb) thread apply all where

Thread 2 (Thread 1191.1192):

0 __cp_begin () at src/thread/arm/syscall_cp.s:23

1 0xb6fd5858 in __syscall_cp_c (nr=162, u=, v=, w=, x=-1224907740,

y=-1228567288, z=120) at src/thread/pthread_cancel.c:35

2 0xb6c62f78 in ?? ()

Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 1 (Thread 1191.1191):

0 luaS_newlstr (L=0xb6ca2e80, str=0xb6ecfbcd "__le", l=4) at lstring.c:86

1 0xb6ec257c in luaT_init (L=L@entry=0xb6ca2e80) at ltm.c:39

2 0xb6ec10cc in f_luaopen (L=0xb6ca2e80, ud=) at lstate.c:77

3 0xb6eba808 in luaD_rawrunprotected (L=0xb6eba808 <luaD_rawrunprotected+64>, L@entry=0xb6ca2e80, f=0xbefffbd0,

ud=0xb6ca2e80, ud@entry=0x0) at ldo.c:116

4 0xb6ec13e8 in lua_newstate (f=0xb6ec5ac8 , ud=ud@entry=0x0) at lstate.c:182

5 0xb6ec6cfc in luaL_newstate () at lauxlib.c:658

6 0x00012f58 in juci_luaobject_new (name=name@entry=0xbefffbe0 "/network.interface") at juci_luaobject.c:29

7 0x00014934 in juci_load_plugins (self=self@entry=0xb6c84fa0, path=0xb6c9afee "/usr/lib/juci/api",

base_path=0xb6c9afee "/usr/lib/juci/api", base_path@entry=0x0) at juci.c:76

8 0x00014dbc in juci_new (plugin_path=0xb6c84fd8 "\330Oȶ\330Oȶ",

plugin_path@entry=0xbeffff70 "/usr/lib/juci/api", pwfile=pwfile@entry=0x174c5 "/etc/juci-shadow") at juci.c:171

9 0x000122b4 in main (argc=-1090519660, argv=0xbefffe74) at main.c:147

(gdb)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mkschreder/jucid/issues/2#issuecomment-222754753, or mute the thread https://github.com/notifications/unsubscribe/AERqiVvpBuNFHvvQupTNrmt-CpZUzSG8ks5qHGtFgaJpZM4H_6Vl .

mk-f commented 8 years ago

That does not say much. It could be a faulty lua plugin.

I don't think so. The same error happens for each plugin if i disable them consecutively

mk-f commented 8 years ago

Okay, this has nothing to do with lua or the json-parsing. Musl assigns by default 80k stack-space to new threads which is just not enough for juci, resulting in inaccessible memory and segfaults.

Increasing the stack-size to 128k fixes this (#5)

mkschreder commented 8 years ago

Ah nice. Actually the extra memory can be freed up if necessary, it is mostly precompiled lua bytecode taking up space. I did it that way so it does not have to reinterpret lua scripts upon each request.. On 1 Jun 2016 16:50, "Fabian Müller-Knapp" notifications@github.com wrote:

Okay, this has nothing to do with lua or the json-parsing. Musl assigns by default 80k stack-space to new threads which is just not enough for juci, resulting inaccessible memory and segfaults.

Increasing the stack-size to 128k fixes this (#5 https://github.com/mkschreder/jucid/pull/5)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mkschreder/jucid/issues/2#issuecomment-223017258, or mute the thread https://github.com/notifications/unsubscribe/AERqiR61oKmCFq21pF5Gj8lAqRbMUf8pks5qHZxPgaJpZM4H_6Vl .