• 10 dec 2017: forum version update. In case of issues use this topic.
  • 30 nov 2017: pilight moved servers. In case of issues use this topic.
Hello There, Guest! Login Register


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bug report: segmentation fault using rule with AFTER
#1
Bug 
Hi there,

I received a segmentation fault when starting pilight.
I was trying to follow this good hint from @terrar by writing
Code:
"rule": "IF ping_smartphone_A.state IS disconnected THEN switch DEVICE general_A_present TO off AFTER 3 MINUTES",
when I stumbled upon this.
I reduced & changed my config.json to
Code:
{
    "rules": {
        "y": {
            "rule": "IF a THEN switch DEVICE b TO c AFTER d e",
            "active": 0
        }
    }
}
the result is (still):
Code:
[....] Starting : pilight-- STACKTRACE (1 FRAMES) --
segmentation fault
failed!
but these are OK:
Code:
"rule": "IF a THEN switch DEVICE b TO c AFTER d",
"rule": "IF a THEN switch DEVICE b TO c AFTER d e f",


Also this (taken from the documentation) is OK:
Code:
"rule": "IF 1 == 1 THEN switch DEVICE light TO on AFTER 30 MILLISECOND",
but this also gives a segmentation fault:
Code:
"rule": "IF 1 == 1 THEN switch DEVICE light TO on AFTER 30 MILISECOND",
also this (taken from the same documentation) gives a segmentation fault: (EDIT: corrected typo on wiki)
Code:
"rule": "IF 1 == 1 THEN switch DEVICE light TO off FOR 10 SECOND AFTER 30 MINUTES",
So apparently a typo in the unit leads to this error.


All this using version
Code:
pilight-control -V
pilight-control v7.0

And using
Code:
pilight-daemon version 6c2f21a
I received this result containing more info:
Code:
[....] Starting : pilight-- STACKTRACE (12 FRAMES) --
__default_sa_restorer_v2       ip = 0xb6d30b20, sp = 0xbec68f78
checkArguments                 ip =    0x7a42c, sp = 0xbec69268
event_parse_action             ip =    0x6c360, sp = 0xbec692f8
event_parse_rule               ip =    0x6d05c, sp = 0xbec693b8
rules_parse                    ip =    0x65160, sp = 0xbec69428
config_parse                   ip =    0x316ac, sp = 0xbec69470
config_read                    ip =    0x31a78, sp = 0xbec69490
start_pilight                  ip =    0x20f44, sp = 0xbec694a0
main                           ip =    0x21d0c, sp = 0xbec69d20
__libc_start_main              ip = 0xb6d1a81c, sp = 0xbec69d38
_start                         ip =    0x1a5fc, sp = 0xbec69e78
segmentation fault
failed!

EDIT: last part of
Code:
/usr/local/sbin/pilight-daemon --stacktracer
is:
Code:
[Nov 21 19:40:52:748113] pilight-daemon: STACK: isNumeric(...)
[Nov 21 19:40:52:748439] pilight-daemon: STACK: isNumeric(...)
[Nov 21 19:40:52:748733] pilight-daemon: STACK: isNumeric(...)
[Nov 21 19:40:52:749028] pilight-daemon: STACK: isNumeric(...)
[Nov 21 19:40:52:749615] pilight-daemon: STACK: isNumeric(...)
[Nov 21 19:40:52:749930] pilight-daemon: STACK: isNumeric(...)
[Nov 21 19:40:52:750217] pilight-daemon: STACK: isNumeric(...)
[Nov 21 19:40:52:750515] pilight-daemon: STACK: isNumeric(...)
[Nov 21 19:40:52:750844] pilight-daemon: STACK: isNumeric(...)
[Nov 21 19:40:52:751255] pilight-daemon: STACK: gc_handler(...)
-- STACKTRACE (1 FRAMES) --
segmentation fault


Is there more info I can provide?
 
Reply
#2
Yes, please follow the instructions over on the manual -> Development -> Debugging to get a full backtrace from gdb and post it here please.
 
Reply
#3
(11-21-2015, 08:56 PM)pilino1234 Wrote: Yes, please follow the instructions over on the manual -> Development -> Debugging to get a full backtrace from gdb and post it here please.
Thank you for the hint.

Here is more info from GDB.
Crash:
Code:
Program received signal SIGSEGV, Segmentation fault.
0x0007a3d4 in checkArguments (obj=0x8b0390) at /home/pi/pilight_compile/pilight/libs/pilight/events/actions/switch.c:179
179                                logprintf(LOG_ERR, "switch action \"%s\" is not a valid unit", array[1]);

Backtrace:
Code:
#0  0x0007a3d4 in checkArguments (obj=0x8b0390) at /home/pi/pilight_compile/pilight/libs/pilight/events/actions/switch.c:179
#1  0x0006c308 in event_parse_action (action=0x8b0348 "switch DEVICE z TO off AFTER 3 MINUTES", obj=0x8b02f8, validate=1)
    at /home/pi/pilight_compile/pilight/libs/pilight/events/events.c:1446
#2  0x0006d004 in event_parse_rule (rule=0x8b01b8 "IF 0==1 THEN switch DEVICE z TO off AFTER 3 MINUTES", obj=0x8b02f8, depth=0, validate=1)
    at /home/pi/pilight_compile/pilight/libs/pilight/events/events.c:1688
#3  0x00065108 in rules_parse (root=0x8b0128) at /home/pi/pilight_compile/pilight/libs/pilight/config/rules.c:104
#4  0x00031654 in config_parse (root=0x8b00e0) at /home/pi/pilight_compile/pilight/libs/pilight/core/config.c:119
#5  0x00031a20 in config_read () at /home/pi/pilight_compile/pilight/libs/pilight/core/config.c:206
#6  0x00020eec in start_pilight (argc=2, argv=0xbefff764) at /home/pi/pilight_compile/pilight/daemon.c:2307
#7  0x00021cb4 in main (argc=2, argv=0xbefff764) at /home/pi/pilight_compile/pilight/daemon.c:2799

That was useful Smile
I found the bug, fixed it, tested it and created a pull request.
Now /var/log/pilight.err contains a nice error message:
Code:
[Nov 21 21:51:53:115245] pilight-daemon: ERROR: switch action "MINUTES" is not a valid unit
 
Reply
#4
@pilino1234 found that similar problems are in dim and label.
I tested
Code:
"rule": "IF 0==1 THEN dim DEVICE z TO 0 AFTER 3 MINUTES",
"rule": "IF 0==1 THEN label DEVICE z TO 0 AFTER 3 MINUTES",
and these also give segmentation faults.

We are working on the solution.
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  [Fixed] Segmentation fault when using Socket API wrong tomk 2 188 08-19-2019, 07:09 PM
Last Post: curlymo
  Infinite loop on sunrise rule caused by currentdatetime Trashware 18 1,928 10-14-2018, 03:41 PM
Last Post: kylex
Bug Bug report: WIFI dongle stops when gpio_switch.gpio = 20 woutput 16 5,327 01-03-2018, 10:11 PM
Last Post: zackdvd
Bug Bug report: double free or corruption (!prev) diman87 16 5,240 03-09-2016, 11:10 AM
Last Post: diman87
Bug Bug report: gpio_switch does not accept high pin numbers woutput 2 2,444 10-12-2015, 03:54 PM
Last Post: woutput
  Kernel Fault - Raspberry Pi 2 simonsmart99 7 5,148 05-04-2015, 05:52 PM
Last Post: wo_rasp
  Bug Report: pilight will not compile if the ARP protocol is not specified UndeadKernel 1 1,984 05-01-2015, 09:41 PM
Last Post: curlymo

Forum Jump:


Browsing: 1 Guest(s)