michaellukashov / Far-NetBox

SFTP/SCP/FTP/FTPS/WebDAV/S3 client for Far Manager 3 (http://farmanager.com/)
https://forum.farmanager.com/viewtopic.php?t=6317
GNU General Public License v2.0
155 stars 52 forks source link

Fix ssh crash on reconnect #459

Closed ssvine closed 2 months ago

ssvine commented 2 months ago

This pull request fixes this external bug.

Finally, I found the root cause of the crash.

This crash happens because extern "C" function select_result throws exception but we use /EHsc flag, which leads to UB. Because of UB the compiler can create a code that calls a destructor of already destroyed or never created object while doing stack unwinding.

Also this pull request fixes freeing of FCallbackSet in FreeBackend function.

UPDATE:

@michaellukashov, I updated this pull request with another one that was previously created separately, because otherwise merging them would result in a error.

So, I describe that appended PR: "Include map file in releases and fix optimizations"

There are several issues with release builds:

  1. If NetBox crashes and Far is able to create a crash report, that report won't contain meaningful names of NetBox functions and a random user may create an issue attaching such a problematic report. So, it's a good idea to include rather small .map file in the binary distribution, because Far can use them to convert addresses to meaningful names. (Far releases include .map files for all executables.)
  2. Release build is not fully optimized.

This PR adds NetBox.map file to the release build.

It also fixes and simplifies compiler and linker flags among different build types:

sonarcloud[bot] commented 2 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud