Skip to content
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

crash in QRingBuffer::reserve #133

Closed
stefansaraev opened this issue Jul 20, 2016 · 10 comments
Closed

crash in QRingBuffer::reserve #133

stefansaraev opened this issue Jul 20, 2016 · 10 comments
Labels

Comments

@stefansaraev
Copy link

hi there,

today I tried runing a self compiled hyperion.ng on my wetek core and it fails to run

TB:~/.kodi/addons/service.hyperion/bin # gdb --args ./hyperiond /storage/.kodi/userdata/addon_data/service.hyperion/hyperion.config.jso
n 
...
Program received signal SIGSEGV, Segmentation fault.
QRingBuffer::reserve (this=0x0, bytes=512) at tools/qringbuffer.cpp:111
111 tools/qringbuffer.cpp: No such file or directory.
(gdb) thread apply all bt

Thread 1 (process 520):
#0  QRingBuffer::reserve (this=0x0, bytes=512) at tools/qringbuffer.cpp:111
#1  0x001cf2e6 in QSerialPortPrivate::readNotification() ()
#2  0x001cf8e8 in QSerialPortPrivate::waitForBytesWritten(int) ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

I dont know if it's qt or hyperiond bug, but I decided to post this here.

[HYPERIOND LedDevice] <ERROR> Unable to open RS232 device ()

^^ I've got this once in a gdb session, just once. no matter how hard I try, I cant get it anymore

compiling against qtbase-5.7.0 + qtserialport-5.7.0, there is an extra (it should not interfere in no way) patch to make avahi optional. I can PR / share it if you want me to.

my compile opts: http://sprunge.us/LMXD
my config: http://sprunge.us/GRMa

device is a wetek core + dyi arduino nano clone + ws2812b leds (adalight). it works fine with https://github.com/hyperion-project/hyperion self compiled from master branch.

@redPanther
Copy link
Contributor

redPanther commented Jul 20, 2016

here the same thing:
#87

big thanx for that good bug report!
I recommend
"delayAfterConnect" : 1000
because arduino resets when port is opened and this could lead to strange behaviour.

BTW to be sure that this is no issue with firmware. Can you try our adalight firmware
https://github.com/hyperion-project/hyperion.ng/tree/master/assets/firmware/arduino/adalight

@stefansaraev
Copy link
Author

stefansaraev commented Jul 20, 2016

ouch. sorry for the dupe. I searched and somehow missed #87. fyi delayAfterConnect was my first guess, I played a bit with different values but it did not help..

EDIT: here is what I use: https://github.com/stefansaraev/IoT/blob/master/nanoatmega328-ambilight/src/main.ino

I am pretty sure it is fine. it never fails with old hyperion git. but if you insist, I can try yours .. :)

@redPanther
Copy link
Contributor

it looks like calling waitforbyteswritten when it is not neccessary can lead to problems. Waiting is only necessary when write returns with "not all written yet".

here some idea:
http://stackoverflow.com/questions/35273827/serial-write-crashes-program-in-qt-c

I will modify code to something like:

    qint64 bytesWritten = serialPort.write(writeData);

    if (bytesWritten == -1) {
        standardOutput << QObject::tr("Failed to write the data to port %1, error: %2").arg(serialPortName).arg(serialPort.errorString()) << endl;
        return 1;
    } else if (bytesWritten != writeData.size()) {
        standardOutput << QObject::tr("Failed to write all the data to port %1, error: %2").arg(serialPortName).arg(serialPort.errorString()) << endl;
        return 1;
    } else if (!serialPort.waitForBytesWritten(5000)) {
        standardOutput << QObject::tr("Operation timed out or an error occurred for port %1, error: %2").arg(serialPortName).arg(serialPort.errorString()) << endl;
        return 1;
    }

@stefansaraev
Copy link
Author

k http://sprunge.us/DZXR with this no crash and amlgrabber seems to work now. framegrabber (used for software decoded content in kodi) does not work, startup effect does not work. but thats another story :)

@brindosch
Copy link
Contributor

It would be great if someone could extend the amlgrabber to work also with kodi. Or is Kodi a workaround? It would be hard with 2 grabbers at the same. As our target is one grabber for one system and not two :)

startup effect does not work

checkout the current valid config at the config dir

@stefansaraev
Copy link
Author

amlgrabber works "behind" kodi's back (takes frames fron /dev/amvideocap). because amcodec renders behind kodi's back. it is more like a v4l grabber, and it always worked for me. still works :)

previously, I used different priorities. 900 for bootsequence / framegrabber, and 800 for amlgrabber and it worked nicely. however, this is unrelated and can be looked at later

@brindosch
Copy link
Contributor

brindosch commented Jul 20, 2016

No, i wanted to point to this:
https://github.com/hyperion-project/hyperion.ng/blob/master/config/hyperion.config.json.default
This should be your basic file for hyperion.ng and will be updated whenever we change something.
(btw prio is gone)

@stefansaraev
Copy link
Author

@brindosch yep, I failed to update my old config (sorry for the extra noise). ./hyperion-remote -e worked. adding the new initialEffect section does the trick.

@redPanther
Copy link
Contributor

I did some deeper investigation. waitForBytesWritten causes after sending some bytes (7k) a resource error:
"An I/O error occurred when a resource becomes unavailable, e.g. when the device is unexpectedly removed from the system."

I guess in your code waitForBytesWritten would never be executed and thatswyh it worked.

In above example result != size is an error, in your code would waitForBytesWritten be executed in that case.

I removed waitForBytesWritten, because it is not neccesary - the flush blocks until all data is written to port and do nearly the same.

@stefansaraev
Copy link
Author

#134 fixed the issue. thanks @redPanther

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants