Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StubExecutable crashes on update / uninstall #1500

Open
Glebka opened this issue Jun 12, 2019 · 5 comments
Open

StubExecutable crashes on update / uninstall #1500

Glebka opened this issue Jun 12, 2019 · 5 comments
Assignees

Comments

@Glebka
Copy link

Glebka commented Jun 12, 2019

Squirrel version(s)
1.9.1

Description
AppName_ExecutionStub.exe crashes during autoupdate / uninstall of our Electron app.
More details in Additional information section.

Steps to recreate
Trigger update of Electron App from older to newer version.

Expected behavior
AppName_ExecutionStub.exe should not crash. It should exit with some error code, for example -1.

Actual behavior
AppName_ExecutionStub.exe crashes with core dump generation.

Additional information

This happens because installer treats AppName_ExecutionStub.exe as a Squirrel Aware app and starts executing hooks on it (calling it with additional command line arguments such as "--squirrel-updated 19.6.1-beta").
Well, actually, AppName_ExecutionStub.exe is Squirrel Aware
because during the release build process Squirrel copies resources from the main app to the StubExecutable.

String.Format("--copy-stub-resources \"{0}\" \"{1}\"", fullName, target),

When StubExecutable starts, it tries to find the main executable and run it with passed arguments. In this particular case installer calls StubExecutable that is already located in AppData/Local/AppName/app-VERSION, thus it fails to find main executable.
I collected a core dump of the StubExecutable. So here some variable values ad call stack that reflects the state of executable when it crashed:

Variables

  Name Value Type
&fileInfo 0x004efa68 L"" 0x00000000 _WIN32_FIND_DATAW *
fileInfo L"" 0x00000000 _WIN32_FIND_DATAW
  hFile 0xffffffff void *
ourDir L"C:\Users\vagrant\AppData\Local\AppName\app-19.6.1-beta\app-*" std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >
cmdLine 0x008b19bc L""C:\Users\vagrant\AppData\Local\AppName\app-19.6.1-beta\AppName_ExecutionStub.exe" --squirrel-updated 19.6.1-beta" wchar_t *

Call stack

 	AppName_ExecutionStub.exe!std::char_traits<wchar_t>::length(const wchar_t * _First) Line 303	C++
 	[Inline Frame] AppName_ExecutionStub.exe!std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >::assign(const wchar_t *) Line 1182	C++
 	AppName_ExecutionStub.exe!std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >(const wchar_t * _Ptr) Line 838	C++
>	AppName_ExecutionStub.exe!FindLatestAppDir() Line 53	C++
 	AppName_ExecutionStub.exe!wWinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, wchar_t * lpCmdLine, int nCmdShow) Line 97	C++
 	[External Code]	
 	[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]	Unknown

I found here

std::wstring FindLatestAppDir()

that FindLatestAppDir() may return NULL in some cases, but defined return type is std::wstring. That is the root cause of the crash. I think we need to replace NULL with empty std::wstring. I can create a PR later for this.

@Thieum
Copy link
Contributor

Thieum commented Jun 12, 2019

@Glebka Nice research! I'm sure a PR would be much appreciated.

Glebka pushed a commit to Glebka/Squirrel.Windows that referenced this issue Jun 13, 2019
@Glebka
Copy link
Author

Glebka commented Jun 13, 2019

@Thieum I've posted a PR, please review

@Thieum
Copy link
Contributor

Thieum commented Jun 13, 2019

@Glebka I think only @shiftkey and @robmen have that power atm.

@bddckr
Copy link
Contributor

bddckr commented Jun 15, 2019

This reminds me of #1355 - perhaps it's related?

@robmen robmen self-assigned this Jun 15, 2019
@anaisbetts
Copy link
Contributor

anaisbetts commented Jun 19, 2019

I think, that given that we understand the underlying issue, this fix could be improved, we're kind of paving over the actual issue instead of just fixing the cause. The correct fix is either:

  • Squirrel should not mark stub executables as Squirrel-Aware during the resource copy step (hard, because we don't want to get into the game of stripping attributes from RC files and assemblies)

  • Squirrel should detect an executable (probably by name) as a stub, and ignore it for the purposes of running down Squirrel hooks (i.e. "Stubs can never be Squirrel-aware"). This is an easy fix and is More Correct

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

No branches or pull requests

5 participants