podonoghue / usbdm-eclipse-makefiles-build

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

FirmwareChanger segfault on linux #21

Closed HondaRulez closed 2 years ago

HondaRulez commented 3 years ago

Hi,

The FirmwareChager got segfault at startup (probably localization/text related, something wx character conversion issue)

log and coredump are attached.

core.zip FirmwareChanger.zip

podonoghue commented 3 years ago

Hi, I have done a build from GITHUB on a new machine running the current version of Mint. This consisted of cloning the archive and running LinuxPackages (with some problems) and then running doit.

Testing FirmwareChanger ran and updated the target firmware without any problems. I'm sorry but I can't see any way to determine the error. There are some some differences in the log files that are puzzling. /* 0.00 */ static std::shared_ptr<_Tp> PluginFactory<T>::createPlugin(std::string, std::string) [with T = FlashImage; std::string = std::__cxx11::basic_string<char>]: Entry =============== /* 0.01 */ static std::shared_ptr<_Tp> PluginFactory<T>::createPlugin(std::__cxx11::string, std::__cxx11::string) [with T = FlashImage; std::__cxx11::string = std::__cxx11::basic_string<char>]: Entry =============== This may indicate different C compiler version or library versions? Perhaps a clean and rebuild may help to ensure consistent versions for plugins? FirmwareChanger.log

HondaRulez commented 3 years ago

Really the FirmwareChanger does not work since version 250 or so.. and tryed many dsistros... therefore not a distro problem probably.

now, I made a clean clone and compille, still segfault..

it's possible due the localization settings, I'm using Hungarian.

here is a gdb log:

Reading symbols from ./FirmwareChanger-debug...done. (gdb) r Starting program: /opt/src/usbdm/FirmwareChanger/FirmwareChanger-debug.x86_64-linux-gnu/FirmwareChanger-debug [Thread debugging using libthread_db enabled]

Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". [New Thread 0x7ffff2e54700 (LWP 4482)]

Thread 1 "FirmwareChanger" received signal SIGSEGV, Segmentation fault. 0x000055555557fe07 in wxStringOperationsWchar::DecodeChar ( i=<error reading variable: Cannot access memory at address 0x5559557f3d8c>) at /usr/include/wx-3.0/wx/stringops.h:52 52 { return *i; } (gdb)

another little thing, the make clean does not work in the USBDM_API_Example and USBD_Programmer_API_Example directoryes

podonoghue commented 3 years ago

Hi, I'll have a look at the examples but they a pretty low priority. Could you provide a stack trace in GDB of the crash. I can't tell much from an error inside wxWidgets. bye

HondaRulez commented 3 years ago

my BDM device's serial # is "0003" if it's matter... the stack strace on the image is without BDM connected

(gdb) bt

0 0x000055555557fe07 in wxStringOperationsWchar::DecodeChar(__gnu_cxx::normal_iterator<wchar_t const*, std::cxx11::basic_string<wchar_t, std::char_traits, std::allocator > > const&)

(i=<error reading variable: Cannot access memory at address 0x5559557ee25c>) at /usr/include/wx-3.0/wx/stringops.h:52

1 0x00005555555801d1 in wxString::at(unsigned long) const (this=0x7fffffffd960, n=4294967295)

at /usr/include/wx-3.0/wx/string.h:1514

2 0x000055555557b031 in FirmwareChangerDialogue::parseSerialNumber(wxString const&, wxString&) (this=

0x5555556ec740, serialNumber=..., serialNumberPrefix=...) at src/FirmwareChanger.cpp:889

3 0x000055555557b187 in FirmwareChangerDialogue::textControlToSerialNumber() (this=0x5555556ec740)

at src/FirmwareChanger.cpp:904

4 0x000055555557acc0 in FirmwareChangerDialogue::readSerialNumber() (this=0x5555556ec740) at src/FirmwareChanger.cpp:860

5 0x000055555557bf72 in FirmwareChangerDialogue::doAutoUpdate() (this=0x5555556ec740) at src/FirmwareChanger.cpp:1048

6 0x000055555557c65e in FirmwareChangerDialogue::setAutoLoad(bool) (this=0x5555556ec740, value=false)

at src/FirmwareChanger.cpp:1090

7 0x000055555557e2ec in FirmwareChangerApp::OnInit() (this=0x5555556101f0) at src/FirmwareChanger.cpp:1427

8 0x0000555555580f89 in wxAppConsoleBase::CallOnInit() (this=0x5555556101f0) at /usr/include/wx-3.0/wx/app.h:93

9 0x00007ffff734dd52 in wxEntry(int&, wchar_t**) () at /lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0

10 0x000055555557de8c in main(int, char**) (argc=1, argv=0x7fffffffe108) at src/FirmwareChanger.cpp:1354

debug

podonoghue commented 3 years ago

OK I believe I have found the error. It is caused by a combination of zero length serial number and autoload being enabled. Still a silly error where I didn't check for an empty string. Please use the updated file on GITHUB. bye

HondaRulez commented 3 years ago

The app starts now, but clicking on the Auto Sselect BDM Firmware or Read From Device still segfault

podonoghue commented 3 years ago

Hi, As before can you run in GDB and provide a stack trace as I can't get it to misbehave for me. bye

HondaRulez commented 3 years ago

Hi,

here is the logs,

autosel.txt readfromdev.txt

podonoghue commented 3 years ago

Thanks for that. Basically the same error - checking for underflow in a unsigned number in the same bit of code. Please try the update on GITHUB. It is triggered by having a serial number which is actually a number! I usually use a mixture such as USBDM-JS16-SWD-0004 Strangely enough USB Serial numbers don't have to be a number!

HondaRulez commented 3 years ago

Everything works fine,

thanks alot for fast response/solution :)

BTW, I use simple serials to make symlynk like /dev/serial/Usbdm-0003 by udev rules to easy find the serialport for debug.

Another question, any plan to platformio porting and more STM32 support ? :)

podonoghue commented 2 years ago

Assumed Closed