Telldus 2.1.2 do not start on Synology DS1813+

Moderator: Telldus

LeprA
Posts: 21
Joined: Fri Mar 17, 2023 9:45 am

Telldus 2.1.2 do not start on Synology DS1813+

Post by LeprA »

Hi,

I have now tried a couple of hours to get things running without any success.

Now when i try to start with this commandline:
telldusd --nodaemon
il get the feed back:
telldusd daemon starting up
Segmentation fault (core dumped)

My config file (/etc/tellstick.conf):

Code: Select all

user = "telldus"
group = "users"
ignoreControllerConfirmation = "false"
device {
  id = 1
  name = "Workarea"
  protocol = "arctech"
  model = "selflearning-dimmer:nexa"
  parameters {
    house = "13451262"
    unit = "3"
  }
}
I have a user created inside the nas called "telldus" and it has the group users assigned to it.

dmesg report this:
[16358.525968] telldusd[29724] general protection ip:80a8e32 sp:ffcb33d0 error:0

lsusb report this:
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 002: ID 1781:0c31 Multiple Vendors Telldus TellStick Duo
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID f400:f400
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

/var/log/messages
Do not contain any information about telldus.

I have tried to start it through gdb but im a beginner in debugging on linux, windows is less complicated =)

Any suggestion how to proceed would be much appreciated!
micke.prag
Site Admin
Posts: 2243
Joined: Fri Mar 17, 2023 9:45 am
Location: Lund
Contact:

Re: Telldus 2.1.2 do not start on Synology DS1813+

Post by micke.prag »

If you can get a stack trace out of your core dump it may help a lot to figure out where and why it crashes.
Micke Prag
Software
Telldus Technologies
LeprA
Posts: 21
Joined: Fri Mar 17, 2023 9:45 am

Re: Telldus 2.1.2 do not start on Synology DS1813+

Post by LeprA »

@telldusd.zip
@telldus.core
(65.66 KiB) Downloaded 487 times
Hi,

Don't know if i got it right but here goes the core dump i think you need.
micke.prag
Site Admin
Posts: 2243
Joined: Fri Mar 17, 2023 9:45 am
Location: Lund
Contact:

Re: Telldus 2.1.2 do not start on Synology DS1813+

Post by micke.prag »

Sorry, I cannot open the core dump. You need to extract the stack trace on the NAS.
Micke Prag
Software
Telldus Technologies
LeprA
Posts: 21
Joined: Fri Mar 17, 2023 9:45 am

Re: Telldus 2.1.2 do not start on Synology DS1813+

Post by LeprA »

I ran the command
gdb telldusd /volume1/@telldusd.core
Got this output below, It looks like I can't get the symbols loaded from my binary file.

I have added a few logging rows in the source file and come to the conclusion that "getgrnam" fails and crashes the program.
I have checked that the group "users" exist in "/etc/group" and that the variable is "users" that are sent to "getgrnam".

Any idea what to do next?

Code: Select all

dlopen failed on 'libthread_db.so.1' - libthread_db.so.1: cannot open shared object file: No such file or directory
GDB will not be able to debug pthreads.


GNU gdb 6.8
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 "i686-linux-gnu"...

warning: Can't read pathname for load map: Input/output error.
Reading symbols from /lib/libpthread.so.0...done.
Loaded symbols for /lib/libpthread.so.0
Reading symbols from /opt/lib/libconfuse.so.0...done.
Loaded symbols for /opt/lib/libconfuse.so.0
Reading symbols from /opt/lib/libftdi.so.1...done.
Loaded symbols for /opt/lib/libftdi.so.1
Reading symbols from /opt/lib/libstdc++.so.6...done.
Loaded symbols for /opt/lib/libstdc++.so.6
Reading symbols from /lib/libm.so.6...done.
Loaded symbols for /lib/libm.so.6
Reading symbols from /opt/lib/libgcc_s.so.1...done.
Loaded symbols for /opt/lib/libgcc_s.so.1
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /opt/lib/libusb-0.1.so.4...done.
Loaded symbols for /opt/lib/libusb-0.1.so.4
Reading symbols from /lib/libnss_files.so.2...done.
Loaded symbols for /lib/libnss_files.so.2
Core was generated by `telldusd --nodaemon'.
Program terminated with signal 11, Segmentation fault.
[New process 20086]
#0  0x080a8e32 in ?? ()
(gdb) Quit
(gdb) where
#0  0x080a8e32 in ?? ()
#1  0x00000001 in ?? ()
#2  0x00000000 in ?? ()
(gdb) list
1       /synosrc/source_backup/crosstool-0.43/build/i686-linux-gnu/build-glibc/csu/crti.S: No such file or directory.
        in /synosrc/source_backup/crosstool-0.43/build/i686-linux-gnu/build-glibc/csu/crti.S
(gdb) info locals
No symbol table info available.
micke.prag
Site Admin
Posts: 2243
Joined: Fri Mar 17, 2023 9:45 am
Location: Lund
Contact:

Re: Telldus 2.1.2 do not start on Synology DS1813+

Post by micke.prag »

Maybe you can rebuild telldusd with debug symbols built in?
You can do this, I think, by setting the cmake variable CMAKE_BUILD_TYPE to Debug in the cache. You cannot set it in CMakeLists.txt. It must be in the cache.
Micke Prag
Software
Telldus Technologies
LeprA
Posts: 21
Joined: Fri Mar 17, 2023 9:45 am

Re: Telldus 2.1.2 do not start on Synology DS1813+

Post by LeprA »

Tried and successfully compiled with debug information.
Set breakpoints at:
getgrnam
setgid
getpwnam
setuid
chdir

and it looks like i said something goes wrong in "getgrnam" i never hit setgid or getpwnam.

i have broken out the getgrnam into a simple little program and that works ok.
the result from that program is:
After getgrnam
After setgid
After getpwnam
After setuid

Debug code listing:

Code: Select all

Synology> gdb telldusd -c /var/core/core.9307


dlopen failed on 'libthread_db.so.1' - libthread_db.so.1: cannot open shared object file: No such file or directory
GDB will not be able to debug pthreads.

GNU gdb 6.8
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 "i686-linux-gnu"...

warning: Can't read pathname for load map: Input/output error.
Reading symbols from /lib/libpthread.so.0...done.
Loaded symbols for /usr/lib/libpthread.so.0
Reading symbols from /opt/lib/libconfuse.so.0...done.
Loaded symbols for /opt/lib/libconfuse.so.0
Reading symbols from /opt/lib/libftdi.so.1...done.
Loaded symbols for /opt/lib/libftdi.so.1
Reading symbols from /lib/libstdc++.so.6...done.
Loaded symbols for /usr/lib/libstdc++.so.6
Reading symbols from /lib/libm.so.6...done.
Loaded symbols for /usr/lib/libm.so.6
Reading symbols from /lib/libgcc_s.so.1...done.
Loaded symbols for /usr/lib/libgcc_s.so.1
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /usr/lib/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /lib/libusb-0.1.so.4...done.
Loaded symbols for /usr/lib/libusb-0.1.so.4
Reading symbols from /lib/libnss_files.so.2...done.
Loaded symbols for /usr/lib/libnss_files.so.2
Core was generated by `telldusd --nodaemon'.
Program terminated with signal 11, Segmentation fault.
[New process 9307]
#0  0x080a8e32 in ?? ()
(gdb) list
38                              break;
39                      case SIGPIPE:
40                              break;
41                      default:
42                              Log::warning("Unhandled signal (%d) %s", sig, strsignal(sig));
43                              break;
44              }
45      }
46
47      int main(int argc, char **argv) {
(gdb) b getgrnam
Breakpoint 1 at 0xf759e2d0
(gdb) b setgid
Breakpoint 2 at 0xf75a1be0
(gdb) b getpwnam
Breakpoint 3 at 0xf759f770
(gdb) b setuid
Breakpoint 4 at 0xf75a1b60
(gdb) b chdir
Breakpoint 5 at 0xf75c6910
(gdb) t
[Current thread is 1 (process 9307)]
(gdb) r --nodaemon
Starting program: telldusd --nodaemon
telldusd daemon starting up
Before parse of wideToString
After parse of wideToString
user is telldus (My added logging)
group is "users" (My added logging)

Breakpoint 1, 0xf75482d0 in getgrnam () from /usr/lib/libc.so.6
(gdb) n
Single stepping until exit from function getgrnam,
which has no line number information.
0xf74c7b7c in malloc@plt () from /usr/lib/libc.so.6
(gdb) n
Single stepping until exit from function malloc@plt,
which has no line number information.
0xf7522440 in malloc () from /usr/lib/libc.so.6
(gdb) n
Single stepping until exit from function malloc,
which has no line number information.
0xf75483e6 in getgrnam () from /usr/lib/libc.so.6
(gdb) n
Single stepping until exit from function getgrnam,
which has no line number information.
0xf7548b40 in getgrnam_r () from /usr/lib/libc.so.6
(gdb) n
Single stepping until exit from function getgrnam_r,
which has no line number information.
0xf75b18d0 in ?? () from /usr/lib/libc.so.6
(gdb) n
Cannot find bounds of current function
(gdb) n
Cannot find bounds of current function
(gdb) n
Cannot find bounds of current function
(gdb) c
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x080a8e32 in ?? ()
(gdb) Quit
Simple program:

Code: Select all

#include <signal.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <errno.h>
#include <pwd.h>
#include <grp.h>
#include <string>
#include <iostream>
#include <cstdio>
using namespace std;
int main(int argc, char **argv) {
	struct group *grp = getgrnam("users");  // NOLINT(runtime/threadsafe_fn)
	cout << "After getgrnam"<< endl;
	setgid(grp->gr_gid);
	cout << "After setgid"<< endl;
	struct passwd *pw = getpwnam("telldus");  // NOLINT(runtime/threadsafe_fn)
	cout << "After getpwnam"<< endl;
	setuid( pw->pw_uid );
	cout << "After setuid"<< endl;

	return 0;
}
I still do not understand what happens diffrently in the telldusd bin.

Any idea?
micke.prag
Site Admin
Posts: 2243
Joined: Fri Mar 17, 2023 9:45 am
Location: Lund
Contact:

Re: Telldus 2.1.2 do not start on Synology DS1813+

Post by micke.prag »

I am sorry but I have no idea why it fails. It is strange.
Maybe you could try to hardcode the group the same way you do in your example program and see if it makes any difference?

Code: Select all

struct group *grp = getgrnam("users");
Else, I can come up with two possible workarounds:

1) To not start telldusd as root. This makes it to not run this code.
2) Remove this piece of code and let the daemon run as root instead.
Micke Prag
Software
Telldus Technologies
LeprA
Posts: 21
Joined: Fri Mar 17, 2023 9:45 am

Re: Telldus 2.1.2 do not start on Synology DS1813+

Post by LeprA »

micke.prag wrote: 1) To not start telldusd as root. This makes it to not run this code.
2) Remove this piece of code and let the daemon run as root instead.
Tried both of the solutions but both fails after this piece of code, it feels more like some other thread is starting and corrupting things, I will investigate and see if i can get a more accurate error on what goes wrong.

Thanks for the help!
LeprA
Posts: 21
Joined: Fri Mar 17, 2023 9:45 am

Re: Telldus 2.1.2 do not start on Synology DS1813+

Post by LeprA »

micke.prag wrote: 1) To not start telldusd as root. This makes it to not run this code.
2) Remove this piece of code and let the daemon run as root instead.
I was too hasty to say that option 1 was not working, with some fiddling now i have come a bit longer but it now the problem are in the configuration.

ill get to this point in code (added some more logging):
telldusd daemon starting up
before change dir
before signal traps
SIGTERM installed
SIGINT installed
SIGPIPE installed
All signal traps installed
before start
TelldusMain::start()
Supervisor Started
EventUpdateManager Started
ControllerManager::ControllerManager()
ControllerManager::loadStoredControllers()
Settings::getNumberOfNodes()
Settings::getNumberOfNodes == Controller (134907848)
ControllerManager get control
Settings::getNumberOfNodes()
Settings::getNumberOfNodes == Controller (134907848)
ControllerManager::loadStoredControllers() Finished
ControllerManager::loadControllers()
TellStick::findAll()
TellStick::findAllByVIDPID() vid = 1781 pid= c30
TellStick::findAllByVIDPID() - before ftdi_usb_find_all
TellStick::findAllByVIDPID() - after ftdi_usb_find_all
TellStick::findAllByVIDPID() - finished
TellStick::findAllByVIDPID() vid = 1781 pid= c31
TellStick::findAllByVIDPID() - before ftdi_usb_find_all
Illegal instruction

it looks like the function "ftdi_usb_find_all" is failing.
I have installed libftdi-0.20 by building it and make install.

Any suggestion?
micke.prag
Site Admin
Posts: 2243
Joined: Fri Mar 17, 2023 9:45 am
Location: Lund
Contact:

Re: Telldus 2.1.2 do not start on Synology DS1813+

Post by micke.prag »

So first TellStick::findAllByVIDPID() runs once and succeds for TellStick (vid = 1781 pid= c30). But the next time is runs for TellStick Duo (vid = 1781 pid= c31) it crashes.
Du you have anything connected? TellStick or TellStick Duo?
Micke Prag
Software
Telldus Technologies
LeprA
Posts: 21
Joined: Fri Mar 17, 2023 9:45 am

Re: Telldus 2.1.2 do not start on Synology DS1813+

Post by LeprA »

I have a tellstick duo connected.

But now i tried to remove it and run the program again and it still gave me the same result "CRASH"...
GAH, there is something really weird with my setup I think.

i try to run the example program find_all for libFtdi and it always returned 0 devices and never crashed,
i altered the code, line 24;

Code: Select all

if ((ret = ftdi_usb_find_all(&ftdic, &devlist, 0x0403, 0x6001)) < 0)
To

Code: Select all

if ((ret = ftdi_usb_find_all(&ftdic, &devlist, 0x1781, 0x0c31)) < 0)
Are there some access permission i need to set so the libFtdi could access the USB device.
micke.prag
Site Admin
Posts: 2243
Joined: Fri Mar 17, 2023 9:45 am
Location: Lund
Contact:

Re: Telldus 2.1.2 do not start on Synology DS1813+

Post by micke.prag »

On a desktop computer you can use udev to set the permissions for usb-devices. How it is done on your NAS I don't know.
Running as root should be enough though.
Micke Prag
Software
Telldus Technologies
LeprA
Posts: 21
Joined: Fri Mar 17, 2023 9:45 am

Re: Telldus 2.1.2 do not start on Synology DS1813+

Post by LeprA »

Ok,

Got a bit further now i think but just with the included test program find_all.

with root:

Code: Select all

Synology> /volume1/telldus/libftdi-0.20/examples/find_all
Number of FTDI devices found: 1
Checking device: 0
Manufacturer: Telldus, Description: TellStick Duo
With a standard user in the group "users":

Code: Select all

Synology>  /volume1/telldus/libftdi-0.20/examples/find_all
Number of FTDI devices found: 1
Checking device: 0
ftdi_usb_get_strings failed: -7 (error sending control message: Operation not permitted)
And telldusd with standard user in the group "users":
Same result as before.

Now i wonder if the rules and udev are correct after install:
"/etc/udev/rules.d/05-tellstick.rules"

Code: Select all

ATTRS{idVendor}=="1781", SUBSYSTEM=="usb", ACTION=="add", MODE="664", GROUP="users", ENV{ID_VENDOR_ID}="$attr{idVendor}",ENV{ID_MODEL_ID}="$attr{idProduct}", ENV{ID_SERIAL_SHORT}="$attr{serial}",RUN+="/opt/share/telldus-core/helpers/udev.sh"

ENV{ID_VENDOR_ID}=="1781", SUBSYSTEM=="usb", ACTION=="remove", ENV{ID_VENDOR_ID}="$attr{idVendor}", ENV{ID_MODEL_ID}="$attr{idProduct}", ENV{ID_SERIAL_SHORT}="$attr{serial}", RUN+="/opt/share/telldus-core/helpers/udev.sh"
"/opt/share/telldus-core/helpers/udev.sh"

Code: Select all

if [ "${ID_VENDOR_ID}" = "1781" ]; then
        if [ "${ACTION}" = "add" ]; then
                /opt/sbin/tdadmin controller connect --pid=${ID_MODEL_ID} --vid=${ID_VENDOR_ID} --serial=${ID_SERIAL_SHORT}
        elif [ "${ACTION}" = "remove" ]; then
                /opt/sbin/tdadmin controller disconnect --pid=${ID_MODEL_ID} --vid=${ID_VENDOR_ID} --serial=${ID_SERIAL_SHORT}
        fi
fi
LeprA
Posts: 21
Joined: Fri Mar 17, 2023 9:45 am

Re: Telldus 2.1.2 do not start on Synology DS1813+

Post by LeprA »

I successfully set the access privilege on the USB

Code: Select all

Synology> lsusb
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 004: ID 1781:0c31 Multiple Vendors Telldus TellStick Duo
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID f400:f400
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Set so Everyone can read write and execute. (but it looks like i do not have access to udev so do it manually)

Code: Select all

chmod 777 /proc/bus/usb/007/004
Investigation:
I think Synology mount scripts are defined in
"/usr/syno/hotplug.d/default/default.hotplug"
and this may be the place to create an script equal to udev script.
Now find_all return the same on both root user and standard user.

But i still get the error "Illegal instruction" when running "telldusd --nodaemon".

dmesg return this:
[94760.712737] telldusd[15830] trap invalid opcode ip:80a8e49 sp:ffd367ac error:0

is it something wrong with my compile that i have compiled for some other processor architecture.

using this paramas when compiling:

Code: Select all

export CFLAGS="-O3 -march=i686 -mtune=i686"
export CXXFLAGS="${CFLAGS}"
And the processor is:
Intel Atom D2700 @ 2.13 GHz

I run the following commands:
Synology> file /usr/bin/file

Code: Select all

/sbin/init: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, stripped
Synology> uname -m

Code: Select all

x86_64
Synology> cat /proc/cpuinfo

Code: Select all

processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 54
model name      : Intel(R) Atom(TM) CPU D2701   @ 2.13GHz
stepping        : 1
microcode       : 0x10d
cpu MHz         : 2127.834
cache size      : 512 KB
physical id     : 0
siblings        : 4
core id         : 0
cpu cores       : 2
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 10
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts nopl nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl tm2 ssse3 cx16 xtpr pdcm movbe lahf_lm arat dtherm
bogomips        : 4255.79
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:

processor       : 3
vendor_id       : GenuineIntel
cpu family      : 6
model           : 54
model name      : Intel(R) Atom(TM) CPU D2701   @ 2.13GHz
stepping        : 1
microcode       : 0x10d
cpu MHz         : 2127.834
cache size      : 512 KB
physical id     : 0
siblings        : 4
core id         : 1
cpu cores       : 2
apicid          : 3
initial apicid  : 3
fpu             : yes
fpu_exception   : yes
cpuid level     : 10
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts nopl nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl tm2 ssse3 cx16 xtpr pdcm movbe lahf_lm arat dtherm
bogomips        : 4255.77
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
Post Reply