podonoghue / usbdm-eclipse-makefiles-build

Current USBDM builds
GNU General Public License v2.0
15 stars 15 forks source link

FlashProgrammer segfaults when passed the -h/--help option #25

Closed DanielO closed 10 months ago

DanielO commented 1 year ago

Hi, I have a USBDM connected to a HCS12, if I run the FlashProgrammer with -h to get help it prints the usage but then segfaults. Running lldb on it shows it trying to access bdmInterface but it is null:

* thread #1, name = 'UsbdmFlashProgra', stop reason = signal SIGSEGV: invalid address (fault address: 0x0)
    frame #0: 0x000000000025f80b UsbdmFlashProgrammer`UsbdmDialogue::loadSettings(this=0x0000000809a76600) at UsbdmDialogue.cpp:753:18
   750     // load saved settings
   751     appSettings.printToLog();
   752
-> 753     bdmInterface->loadSettings(appSettings);
   754     deviceInterface->loadSettings(appSettings);
   755
   756     // Save these settings for later
(lldb) print bdmInterface
(BdmInterfacePtr) $0 = nullptr {
  __ptr_ = nullptr
  __cntrl_ = nullptr
}
(lldb) print deviceInterface
(DeviceInterfacePtr) $1 = nullptr {
  __ptr_ = nullptr
  __cntrl_ = nullptr
}

I think this happens because wx parses the command line but does not call parseCommandLine because it considers -h an invalid option, so those are never set as the code expects.

DanielO commented 1 year ago

I see reason - FlashProgrammerApp::OnInit deliberately ignores the OnInit() failure. The comment says 'Return true here as we want OnRun() to execute' but that doesn't explain why it wants to do that..

podonoghue commented 1 year ago

I have no idea why I did that in OnInit(). Fixed so it quits on error and added "help" as valid parameter so it doesn't log error for "-help"

podonoghue commented 10 months ago

No further comments so closing