×
INDI Library v1.8.1 Released (09 Sep 2019)

Monthly maintenance release INDI v1.8.1

help on indi wiringPi gpio crash

2 years 2 months ago 1 year 7 months ago by pauledd.
pauledd
Platinum Boarder
Platinum Boarder
Posts: 346
Karma: 3
More
Topic Author
help on indi wiringPi gpio crash #18464
Hi

This is a very odd story! After I bricked my Raspberry sdcard I had a complete reinstall of gentoo including gcc upgrade from 4.9.3 to 5.4.0. So far so good, everything worked fine, until I installed indi_wiringpi_gpio.

System:
Raspberry Pi
gentoo
gcc-5.4.0
indilib: yesterday from git
wiringPi libs: newest from git (working, gpio readall success)
indi_wiringpi_gpio: from git (no changes to the code since 1 year)

Compiling of indi_wiringpi_gpio without any errors.
Now to the problem: when I start indiserver with driver indi_wiringpi_gpio no errors. But when I connect from kstars I get this in the
indiserver log:
...
2017-08-13T12:53:59: Driver indi_wiringpi_gpio: WiringPiGPIO::ISNewSwitch CONNECTION
2017-08-13T12:53:59: Driver indi_wiringpi_gpio: WiringPiGPIO::ISNewSwitch CONNECTION
Child process 3614 died
2017-08-13T12:53:59: Driver indi_wiringpi_gpio: Impossible IPState -1877497395
2017-08-13T12:53:59: Driver indi_wiringpi_gpio: stdin EOF
2017-08-13T12:53:59: Driver indi_wiringpi_gpio: restart #1
2017-08-13T12:53:59: Driver indi_wiringpi_gpio: pid=3653 rfd=5 wfd=13 efd=14
...

Then it shows connected in ekos but seems not usable at all. If I try to set this pin to output I get this error in the server log:
2017-08-13T12:59:07: Driver indi_wiringpi_gpio: indi_wiringpi_gpio dispatch error: Property PIN_0_CONFIG is not defined in WiringPi GPIO.

I also tried to attach the process id of the driver (before I press connect in ekos) to gdb and I got an backtrace:
(gdb) attach 25324
Attaching to process 25324
Reading symbols from /usr/bin/indi_wiringpi_gpio...(no debugging symbols found)...done.
Reading symbols from /usr/lib/libindidriver.so.1...done.
Reading symbols from /usr/lib/libindiAlignmentDriver.so.1...done.
Reading symbols from /usr/lib/libwiringPi.so...(no debugging symbols found)...done.
Reading symbols from /usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/5.4.0/libstdc++.so.6...(no debugging symbols found)...done.
Reading symbols from /lib/libm.so.6...(no debugging symbols found)...done.
Reading symbols from /usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/5.4.0/libgcc_s.so.1...(no debugging symbols found)...done.
Reading symbols from /lib/libc.so.6...(no debugging symbols found)...done.
Reading symbols from /lib/ld-linux-armhf.so.3...(no debugging symbols found)...done.
Reading symbols from /lib/libusb-1.0.so.0...(no debugging symbols found)...done.
Reading symbols from /usr/lib/libnova-0.15.so.0...(no debugging symbols found)...done.
Reading symbols from /lib/libpthread.so.0...(no debugging symbols found)...done.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
Reading symbols from /usr/lib/libcfitsio.so.5...(no debugging symbols found)...done.
Reading symbols from /lib/libz.so.1...(no debugging symbols found)...done.
Reading symbols from /usr/lib/libjpeg.so.62...(no debugging symbols found)...done.
Reading symbols from /lib/libdl.so.2...(no debugging symbols found)...done.
Reading symbols from /usr/lib/libgsl.so.0...(no debugging symbols found)...done.
Reading symbols from /usr/lib/libgslcblas.so.0...(no debugging symbols found)...done.
Reading symbols from /lib/librt.so.1...(no debugging symbols found)...done.
Reading symbols from /lib/libcrypt.so.1...(no debugging symbols found)...done.
Reading symbols from /lib/libudev.so.1...(no debugging symbols found)...done.
Reading symbols from /lib/libbz2.so.1...(no debugging symbols found)...done.
Reading symbols from /lib/libcap.so.2...(no debugging symbols found)...done.
Reading symbols from /lib/libattr.so.1...(no debugging symbols found)...done.
0x76b70ae0 in select () from /lib/libc.so.6
(gdb) continue
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x76b1d22e in strlen () from /lib/libc.so.6
(gdb) bt
#0  0x76b1d22e in strlen () from /lib/libc.so.6
#1  0x76ae9f24 in vfprintf () from /lib/libc.so.6
#2  0x76b85c80 in __printf_chk () from /lib/libc.so.6
#3  0x76e2d4dc in printf (__fmt=0x76ea1cd8 "    name='%s'\n")
    at /usr/include/bits/stdio2.h:104
#4  IDDefLight (lvp=lvp@entry=0x15f67d0, fmt=0x0)
    at /home/pi/build/indi/libindi/indidriver.c:1721
#5  0x76e3b7b4 in INDI::DefaultDevice::defineLight (this=<optimized out>, 
    lvp=0x15f67d0)
    at /home/pi/build/indi/libindi/libs/indibase/defaultdevice.cpp:937
#6  0x00018fa4 in WiringPiGPIO::updateProperties() ()
#7  0x76e3cbe0 in INDI::DefaultDevice::ISNewSwitch (this=0x15ed038, 
    dev=<optimized out>, name=<optimized out>, states=<optimized out>, 
    names=0x1609938, n=1)
    at /home/pi/build/indi/libindi/libs/indibase/defaultdevice.cpp:344
#8  0x0001a3c4 in WiringPiGPIO::ISNewSwitch(char const*, char const*, ISState*, char**, int) ()
#9  0x00017504 in ISNewSwitch ()
#10 0x76e2f5f4 in dispatch (root=root@entry=0x15f6480, 
    msg=msg@entry=0x7e8a09c4 "")
    at /home/pi/build/indi/libindi/indidriver.c:1104
#11 0x76e2fc30 in clientMsgCB (fd=<optimized out>, arg=<optimized out>)
    at /home/pi/build/indi/libindi/indidriver.c:878
---Type <return> to continue, or q <return> to quit---
#12 0x76e30848 in callCallback (rfdp=0x7e8a1204) at /home/pi/build/indi/libindi/eventloop.c:347
#13 oneLoop () at /home/pi/build/indi/libindi/eventloop.c:439
#14 0x76e308f0 in eventLoop () at /home/pi/build/indi/libindi/eventloop.c:106
#15 0x76e30418 in main (ac=0, av=<optimized out>) at /home/pi/build/indi/libindi/indidrivermain.c:98
#16 0x76abf4f8 in __libc_start_main () from /lib/libc.so.6
#17 0x0001736c in _start ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

What else I tried? I installed indi_wiringpi_gpio on another Raspberry Pi with old gcc, stable indilib (1.4.1): same problem, checking /dev/gpiomem permission: works, deleting any xml config... nothing helped.

I talked to magnue on his git repo issues but he also ran out of ideas whats the cause of this errors.
Maybe someone else has an idea whats wrong here?

(the original discussion is here )

--= human, without Windows™ =--
pls excuse my bad english! :)

Please Log in or Create an account to join the conversation.

2 years 2 months ago
pauledd
Platinum Boarder
Platinum Boarder
Posts: 346
Karma: 3
More
Topic Author
help on indi wiringPi gpio crash #18470
I made "some" progress. I just installed a fresh raspbian jessie with stable indilib and wiringpigpio on the raspberry.
Now it works without any errors. So the problem must be inside the raspberry gentoo system and not
in my kstars desktop system. I will do a complete recompile of the system. Maybe it might still be a gcc issue.
If that doesnt help I will throw away gentoo and switch to raspbian on the raspberry. :angry:

--= human, without Windows™ =--
pls excuse my bad english! :)

Please Log in or Create an account to join the conversation.

2 years 2 months ago 2 years 2 months ago by Magnus_e. Reason: typo
Magnus_e
Gold Boarder
Gold Boarder
Posts: 254
Karma: 4
More
help on indi wiringPi gpio crash #18476
Hi Paule.

This might be good info. All the INDI specific code should work just as well on Gentoo and raspbian.
However there is some code in the wiringpi_gpio/systeminfo.cpp file, that I'm not certain will work on Gentoo (I have newer used Gentoo, so not tested).

Could you try to comment out line 501 in wiringpi_gpio.cpp, so it looks like
void WiringPiGPIO::TimerHit()
{
    //  No need to reset timer if we are not connected anymore 
    if (!isConnected()) return;    

    wiPiUpdater.UpdateAllRead(InputDigitalLP);
    if (timer > 2500)
    {
        //sysinfoUpdater.UpdateDynamicProperties();
        timer = 0;
    }
    timer += 250;
    SetTimer(250);
}
and then recompile on your Gentoo Pi.
If it's code in the SystemInfo class that fails, then this is the only point it will be called from.

Proud owner of Observatory 17b - A remote Linux observatory.
Website: Observatory 17b
Build thread @ SGL: Starting summers observatory project

Please Log in or Create an account to join the conversation.

2 years 2 months ago
pauledd
Platinum Boarder
Platinum Boarder
Posts: 346
Karma: 3
More
Topic Author
help on indi wiringPi gpio crash #18477
That did neither work, still errors.

Well, if I would be able to interpret that backtrace... Iam not so deep in coding. There seems to be some kind of buffer overflow (strlen () from /lib/libc.so.6) of a string. I hope that the error lies within the libc.so.6 (glibc) that has not been rebuild by the new gcc but my understanding of this is very small and maybe wrong.
I started the complete rebuild in my gentoo pi. That will take some hours, maybe a day, even with crosscompile :silly: Yippee!

--= human, without Windows™ =--
pls excuse my bad english! :)

Please Log in or Create an account to join the conversation.

2 years 2 months ago
pauledd
Platinum Boarder
Platinum Boarder
Posts: 346
Karma: 3
More
Topic Author
help on indi wiringPi gpio crash #18478
I tried to enable debug flags in indi_wiringpi_gpio's CMakeLists.txt.

now I have a bit more detailed backtrace:
Program received signal SIGSEGV, Segmentation fault.
0x769a722e in strlen () from /lib/libc.so.6
(gdb) bt
#0  0x769a722e in strlen () from /lib/libc.so.6
#1  0x76973f24 in vfprintf () from /lib/libc.so.6
#2  0x76978d74 in printf () from /lib/libc.so.6
#3  0x76d481e4 in IDDefLight (lvp=0x2917d0, fmt=0x0)
    at /home/pi/build/indi/libindi/indidriver.c:1721
#4  0x76d61230 in INDI::DefaultDevice::defineLight (this=0x288038, lvp=0x2917d0)
    at /home/pi/build/indi/libindi/libs/indibase/defaultdevice.cpp:937
#5  0x00018fa4 in WiringPiGPIO::updateProperties (this=0x288038)
    at /home/pi/build/indi_wiringpi_gpio/wiringpi_gpio/wiringpi_gpio.cpp:287
#6  0x76d5e58c in INDI::DefaultDevice::ISNewSwitch (this=0x288038, 
    dev=0x299290 "WiringPi GPIO", name=0x299340 "CONNECTION", states=0x2a4ac8, 
    names=0x2a4938, n=1)
    at /home/pi/build/indi/libindi/libs/indibase/defaultdevice.cpp:344
#7  0x0001a3c4 in WiringPiGPIO::ISNewSwitch (this=0x288038, dev=0x299290 "WiringPi GPIO", 
    name=0x299340 "CONNECTION", states=0x2a4ac8, names=0x2a4938, n=1)
    at /home/pi/build/indi_wiringpi_gpio/wiringpi_gpio/wiringpi_gpio.cpp:481
#8  0x00017504 in ISNewSwitch (dev=0x299290 "WiringPi GPIO", name=0x299340 "CONNECTION", 
    states=0x2a4ac8, names=0x2a4938, num=1)
    at /home/pi/build/indi_wiringpi_gpio/wiringpi_gpio/wiringpi_gpio.cpp:44
#9  0x76d45878 in dispatch (root=0x291480, msg=0x7e94a95c "")
    at /home/pi/build/indi/libindi/indidriver.c:1104
#10 0x76d449cc in clientMsgCB (fd=0, arg=0x0)
    at /home/pi/build/indi/libindi/indidriver.c:878
#11 0x76d4ac00 in callCallback (rfdp=0x7e94b1cc)
    at /home/pi/build/indi/libindi/eventloop.c:347
#12 0x76d4b0a8 in oneLoop () at /home/pi/build/indi/libindi/eventloop.c:439
#13 0x76d49ce0 in eventLoop () at /home/pi/build/indi/libindi/eventloop.c:106
#14 0x76d49b68 in main (ac=0, av=0x7e94b3e4)
    at /home/pi/build/indi/libindi/indidrivermain.c:98
#15 0x769494f8 in __libc_start_main () from /lib/libc.so.6
#16 0x0001736c in _start ()

--= human, without Windows™ =--
pls excuse my bad english! :)

Please Log in or Create an account to join the conversation.

2 years 2 months ago
Magnus_e
Gold Boarder
Gold Boarder
Posts: 254
Karma: 4
More
help on indi wiringPi gpio crash #18479
Hmmm. Have not debugged c++ in a while, but there is one thing.

All the traces that are within WiringPiGPIO is related to the connection switch being pressed, except
#5  0x00018fa4 in WiringPiGPIO::updateProperties (this=0x288038)
      at /home/pi/build/indi_wiringpi_gpio/wiringpi_gpio/wiringpi_gpio.cpp:287
This is from defining a light property.
if (InputDigitalLP[i]->lp != NULL)
    defineLight(InputDigitalLP[i]);
The only thing I can think of with this, is that I delete that property before defining it, as the main tab will change depending on what switches are defined in the config.

Just to be sure, could you try to comment out these lines
            // Dynamic properties must be "redifined" to be kept in order and avoid duplicate
            deleteProperty(InputDigitalLP[i]->name);
            deleteProperty(OutputDigitalSP[i]->name);
They are line 276, 277 and 278 in wiringpi_gpio.cpp
I would not bet on that i will help, but if deleteProperty is working in a different way than when I have been testing, than this could have something to do with the bug.

Proud owner of Observatory 17b - A remote Linux observatory.
Website: Observatory 17b
Build thread @ SGL: Starting summers observatory project

Please Log in or Create an account to join the conversation.

2 years 2 months ago
pauledd
Platinum Boarder
Platinum Boarder
Posts: 346
Karma: 3
More
Topic Author
help on indi wiringPi gpio crash #18494
no, that didn't work. Still those errors.

I finished recompiling the system files on my gentoo pi, still same errors.
One last try is to recompile all packages and not just system files but my guess is that wont change anything.
:S Despair is gaining ground.

--= human, without Windows™ =--
pls excuse my bad english! :)

Please Log in or Create an account to join the conversation.

2 years 2 months ago
pauledd
Platinum Boarder
Platinum Boarder
Posts: 346
Karma: 3
More
Topic Author
help on indi wiringPi gpio crash #18522
and this did not work too. My system is now recompiled to the very last piece of code.

Well I could try to compare piece by piece whats different from the working raspbian image and my gentoo.
I also tried to exchange the indi_wiringpi_gpio binary from raspbian to gentoo pi but I still get the error.
Maybe its not the driver binary itself but some call to another library on the system (those seen by ldd )

Maybe knro has an idea ?
My last idea would be try to post it on stackoverflow, maybe there is someone who has an instant enlightenment whats wrong here.

--= human, without Windows™ =--
pls excuse my bad english! :)

Please Log in or Create an account to join the conversation.

2 years 2 months ago
Kaczorek
Moderator
Moderator
Posts: 649
Karma: 6
More
help on indi wiringPi gpio crash #18538
Have you tried using official WiringPi from wiringpi.com/ instead the one located on github? According to wiringpi.com:

There is a version of wiringPi hosted on Github. Do not use this version of wiringPi. It only exists to facilitate building the Ruby and Python wrappers which have been written by Gadgetoid.


--
Radek Kaczorek
Astroberry Server | NEQ6 | Atik 460EX | Atik EFW2 | ASI 120MM

Please Log in or Create an account to join the conversation.

2 years 2 months ago
pauledd
Platinum Boarder
Platinum Boarder
Posts: 346
Karma: 3
More
Topic Author
help on indi wiringPi gpio crash #18539
Thanks for the hint but I already use his git repo:
git clone git://git.drogon.net/wiringPi
I also downloaded it as described as tar.gz and installed
and recompiled the driver, no change.

What I else did in the meantime:
Changed locales from de_DE to en_GB (because it is in the raspbian image (*) )
Installed dbus.
Update of bcm2835 header, recompiling dependencies...

I also did a +30 minutes gdb debug step by step into video
but there is so much going on that I dont know what to look for.

To my understanding "Impossible IPState" happens if an undefined indi property state is returned.
I will try to add a breakpoint somewhere before that happens and see if I can find something.

(* there is another problem with the systeminfo.cpp. Its does not correctly parse some values if the locale is set e.g. to de_DE,
I will open another issue for that on github.)

--= human, without Windows™ =--
pls excuse my bad english! :)

Please Log in or Create an account to join the conversation.

2 years 2 months ago
Magnus_e
Gold Boarder
Gold Boarder
Posts: 254
Karma: 4
More
help on indi wiringPi gpio crash #18541
So on line 287 you have
if (InputDigitalLP[i]->lp != NULL)
    defineLight(InputDigitalLP[i]);

For some reason InputDigitalLP->lp is NOT NULL.
However this is the input light property for the main tab.
With no inputs defined (new config file) this should be NULL.
For some reason it's not NULL, but in some way undefined, and chrashes defaultdevice in the ISNewLight function.

Try to set a breakpoint in the if statement and see what InputDigitalLP really is, an why ->lp is NOT NULL.

Proud owner of Observatory 17b - A remote Linux observatory.
Website: Observatory 17b
Build thread @ SGL: Starting summers observatory project

Please Log in or Create an account to join the conversation.

2 years 2 months ago
pauledd
Platinum Boarder
Platinum Boarder
Posts: 346
Karma: 3
More
Topic Author
help on indi wiringPi gpio crash #18544
Ok, so I got:
Breakpoint 1, WiringPiGPIO::updateProperties (this=0xb72f10)
    at /home/pi/build/indi_wiringpi_gpio/wiringpi_gpio/wiringpi_gpio.cpp:286
286                 if (InputDigitalLP[i]->lp != NULL)
(gdb) p InputDigitalLP[0]->lp
$1 = (ILight *) 0x1043a2ce
I dont know what that means but it is not NULL.

Then I look maybe earlier in the code where InputDigitalLP gets assigned in the for loop at line 109:

for (int i = 0; i < NUMBER_OF_PINS; i++)
110     {
111         InputDigitalLP[i] = new ILightVectorProperty;
112         OutputDigitalSP[i] = new ISwitchVectorProperty;
113     }
So I run new and set a new breakpoint at 109 and continue execution but it seems not to reach the breakpoint at 109 but instead
crashes at the old known point. Is it intended that line 109 gets not executed before line 287?

--= human, without Windows™ =--
pls excuse my bad english! :)

Please Log in or Create an account to join the conversation.

Time to create page: 0.296 seconds