Fix crash on startup when no configuration exists yet - #102
Open
stefan-siebert wants to merge 1 commit into
Open
Fix crash on startup when no configuration exists yet#102stefan-siebert wants to merge 1 commit into
stefan-siebert wants to merge 1 commit into
Conversation
InitShellIconOverlays() copies SALAMANDER_ROOT_REG into the overlay diagnostics header, but that pointer is NULL whenever FindLatestConfiguration() didn't load a configuration - a first run on a clean machine, or an import offer the user declined. It only gets set to SalamanderConfigurationRoots[0] later in the startup sequence, after this call. lstrcpyn is remapped to _sal_lstrcpynA in common/lstrfix.h so that NULL faults instead of being swallowed, so this is an access violation reading 0x0 about 140 ms into startup. It happens before any configuration is written, so it repeats on every launch: 1.0.24 can't start at all on a machine that has no Salamander configuration yet. Guard the copy the way every other reader of SALAMANDER_ROOT_REG already does. An empty config root in the report is the right answer for "no configuration loaded".
Owner
|
Thank you, Stefan. I did fix that a while back and just noticed your PR. Version 1.0.25 should already fix that. If not, let me know. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sally 1.0.24 (x64) crashes on startup on a machine that has no Salamander configuration in the registry yet. No window ever appears, the access violation hits about 140 ms in. Since the crash happens before any configuration is written, the key it would need never gets created and it repeats on every launch, so the build is effectively unusable on a clean machine.
Cause
InitShellIconOverlays()snapshots the overlay diagnostics header and copies the resolved registry root into it (src/shiconov.cpp):SALAMANDER_ROOT_REGisNULLat that point whenever no configuration was loaded.FindLatestConfiguration()starts withloadConfiguration = NULLand only assigns a root when a key with aConfigurationsubkey actually exists, so it stays NULL on a first run — and also when an older configuration is found but the user declines the import offer. The fallbackSALAMANDER_ROOT_REG = SalamanderConfigurationRoots[0]insally_entry_lifecycle.cppruns later in the startup sequence than theInitShellIconOverlays()call.src/common/lstrfix.hdeliberately remapslstrcpynto_sal_lstrcpynAso that NULL faults instead of being swallowed the way the kernel32 version would, which is why this is a hard crash rather than an empty string.Every other reader of
SALAMANDER_ROOT_REGin the tree already guards for NULL (main_window_commands_help.cpp,main_window_config_persistence.cpp,plugins_fs_encapsulation.cpp,sally_strings_waitwindow.cpp). This call site is new in c580010 and doesn't.From the bug report
The code at the faulting RIP is the copy loop of
_sal_lstrcpynA:RCXpoints at 256 zero bytes in.data, i.e. the freshlyReset()ShellOverlayDiag.Header.ConfigRoot, and the emptyConfig root in use:line in the report says the same thing.Repro
reg delete "HKCU\Software\Sally\1.0" /f(or just use a machine that never had Salamander or Sally on it)sally.exeWith the guard in place the same machine starts normally and the report shows an empty config root, which is the correct answer for "no configuration loaded".