Skip to content

fix(cpn): crash converting settings before firmwares are registered - #30

Closed
pfeerick wants to merge 1 commit into
mainfrom
fix/cpn-settings-convert-null-firmware
Closed

pfeerick wants to merge 1 commit into
mainfrom
fix/cpn-settings-convert-null-firmware

Conversation

@pfeerick

@pfeerick pfeerick commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes a startup segfault in Companion and the standalone simulator. It hits anyone upgrading from settings revision 3 or lower who has at least one radio profile. That includes every 2.12 user who has profiles, on their first 3.0 launch, because the automatic settings import runs the same conversion.

[I] AppData::convertSettings():773 - Converting settings Companion 3.0_import from v2.12.4.3 to v3.0.0.4. Removing unused: true
[I] AppData::convertSettings():944 - Converting profiles firmware type
Segmentation fault

#0  AppData::convertSettings(QSettings&)
#1  AppData::importSettings(QSettings*)
#2  AppData::importSettings(QString const&)
#3  checkSettingsImport(bool)
#4  main

Cause

EdgeTX#7623 added a revision 4 conversion that splits each profile's fwType into type, options and language. It checked the language with getCurrentFirmware()->getFirmwareBase()->languageList().

Settings are converted in g.init() and in importSettings(). Both run in main() before registerOpenTxFirmwares() and Firmware::setCurrentVariant(), so Firmware::currentVariant is still nullptr at that point.

The check also had two other problems, even when a firmware was available:

  • It tested against the current firmware, not each profile's own.
  • QLocale::languageToString() returns a name like "English", not a code, so the locale fallback could never match.

Fix

  • Drop the firmware lookup from the conversion. Nothing is lost:
    • prefs_profile.cpp already falls back to a supported language when the stored one is not in the profile's firmware list.
    • GeneralSettings falls back to en when the language is empty.
  • Fill in en only when a profile has no language at all.
  • Never overwrite a language already split out by an earlier conversion. The block runs whenever the saved revision is below CPN_SETTINGS_REVISION, so it will run again on already-converted settings the next time the revision is bumped.

Testing

Linux native build in the container, run offscreen against hand-written settings files:

  • Before the fix, revision 3 settings with one profile reproduced the segfault, with the same log lines as the report.
  • Existing v3.0.0.3 settings: no crash. edgetx-tx16s-heli-ppmus-fr becomes type edgetx-tx16s, options heli-ppmus, language fr. edgetx-x9d becomes edgetx-x9d, language en. The version is stamped v3.0.0.4.
  • First launch importing v2.12.4.3 settings (the backtrace above): no crash, the profile converts as above, and the temporary _import settings are cleaned up.
  • Conversion run again on already-converted settings: the stored fr / en languages are kept.
  • Linux AppImage from this PR's CI, on a desktop, with real user settings. Each route was run with the old 3.0 AppImage first and then this one:
    • First launch importing real 2.12 settings: the old AppImage segfaults, and this one starts and imports the profiles.
    • Existing real v3.0.0.3 settings: the old AppImage segfaults, and this one starts and opens the converted settings without error.

🤖 Generated with Claude Code

The revision 4 profile conversion added in EdgeTX#7623 validated each profile's
language with getCurrentFirmware(), but settings are converted in g.init() and
when importing previous-version settings on first launch, both before any
firmware is registered. The current firmware is still null there, so Companion
and the standalone simulator segfault on startup for anyone with profiles in
revision 3 (or 2.12) settings.

Drop the firmware lookup: the profile settings already fall back to a
supported language. Only fill in a missing language, and never overwrite one
already split out by an earlier conversion.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pfeerick pfeerick closed this Oct 7, 2026
@pfeerick
pfeerick deleted the fix/cpn-settings-convert-null-firmware branch October 24, 2026 06:12
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.

1 participant