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

Bugfix for racy crash on opening bad serial port #12122

Merged
merged 1 commit into from
Nov 23, 2024

Conversation

unjambonakap
Copy link
Contributor

@unjambonakap unjambonakap commented Nov 21, 2024

To reproduce: on linux, try to connect to an existing /dev/ttySX that is not a valid serial port (preexisting ttys?)

Crash happens like this:

  • Open an existing port that triggers on open a QSerialPort::ResourceError (stock /dev/ttySX on my end)
  • Signal QSerialPort::errorOccurred
  • Slot SerialLink::linkError
  • LinkInterface::_connectionRemoved
  • SerialLink::disconnect => set _port = null
  • On retry, at [https://github.com/unjambonakap/qgroundcontrol/blob/aacb664bffc2baa47c6f6a8ec9a224149fd06977/src/Comms/SerialLink.cc#L182], crashes because _port == null

Simply moves the connection of signals (readyRead and errorOccurred) until the serial port's configuration is finished.

Note: I'm guessing that should data arrive in between port opening and connection of the readyRead() signal, it does not matter since it's the event loop stuff that triggers the readyRead()

@HTRamsey HTRamsey merged commit 2b1149d into mavlink:master Nov 23, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants