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

examples crash without a helpful error message when setup.bat isn't loaded #161

Open
codebot opened this issue Dec 19, 2016 · 16 comments
Open
Labels
backlog enhancement New feature or request

Comments

@codebot
Copy link
Member

codebot commented Dec 19, 2016

this might be a Windows-specific issue, but if you try to run talker.exe or examples_rclcpp_minimal_publisher_lambda.exe or basically anything (it seems?) without first calling local_setup.bat, Windows 10 pops up the generic "this program has stopped working" box. I'm not sure what the answer is, but it would be nicer to have a friendly error message instead.

@wjwwood
Copy link
Member

wjwwood commented Dec 19, 2016

That's Windows failing to find the .dll files it needs. So this is happening at dynamic linking time. I do not think we can do anything before this. The only thing you could do is wrap all of these in a .bat which makes sure the env is reasonable before running. I don't think this is a very nice thing to do though, because it is awkward to call a .bat file in order to run an exe and because it's not clear to me what the script would check to consider the environment to be reasonably set up.

@codebot
Copy link
Member Author

codebot commented Dec 19, 2016

I see, thanks for explaining. I suppose we could load the DLLs ourselves (rather than asking Windows to do it) because we could then catch the "I couldn't find the .dll" error ourselves and try to have a helpful error message. But that sounds like an awful lot of work.

@wjwwood
Copy link
Member

wjwwood commented Dec 19, 2016

Yeah, that doesn't sound very feasible to me, since we would also have to do that for Linux or have two completely different mechanisms for dealing with shared libraries on Windows and Linux.

Also, it's not just our libraries, it's libraries like boost (via fast rtps) which would need to be loaded manually.

@wjwwood
Copy link
Member

wjwwood commented Dec 19, 2016

You might be able to do Static linking by default on the Windows packaging job (which would required getting static linking working first, but that would be nice anyways). And then you'd still want to have something in our executables which checked the env, because that just works around the missing dll's, but not other things that might break because of the missing source of setup.bat.

@codebot
Copy link
Member Author

codebot commented Dec 19, 2016

Naive question: how do "typical" Windows applications handle this? If you're using MS Word or Firefox or whatever else is popular, and a DLL is moved or not on the loader's path, do they try to catch it, or does Windows just pop up that generic "OH NOES" box for them as well?

@wjwwood
Copy link
Member

wjwwood commented Dec 19, 2016

They put all of the dll's (for their code as well as dependencies not provided on the PATH) in the same folder as the executable. If they use someone else's libraries which are in a different folder which is not on the PATH by default, then they update the default PATH to include that folder with the installer program (.msi or w/e).

@wjwwood
Copy link
Member

wjwwood commented Dec 19, 2016

Or they do static linking.

@codebot
Copy link
Member Author

codebot commented Dec 19, 2016 via email

@wjwwood
Copy link
Member

wjwwood commented Dec 19, 2016

The OS provides the error box. There might be a way to customize it, but I'm not aware of one. You could also wrap your executable in a shell script or another program which checks before trying to run it.

@gavanderhoorn
Copy link

gavanderhoorn commented Dec 19, 2016

I think this is actually program-specific. Just tested this - as I was curious as well - with 7z, and when I remove the 7z.dll from the program's installation directory (C:\Program Files\7-Zip) and then try to use 7z, I get:

sshot_7z

That seems like what @codebot is looking for.

@codebot
Copy link
Member Author

codebot commented Dec 19, 2016

Ah, thanks @gavanderhoorn I guess my curiosity would be if it was possible to (easily) modify the error box the OS generates, so that we could give a friendly reminder to users about a likely next-step to take as they are troubleshooting. Maybe 7-Zip is loading their DLL "manually" rather than letting the OS load it for them, so they can capture any problems and generate their own error box.

@wjwwood
Copy link
Member

wjwwood commented Dec 19, 2016

I think that's auto generated by the OS. 7-Zip is the executable name (either the file name 7-Zip.exe or maybe there is a way to indicate to Windows what the executable's name is just like you can do so with the icon).

@gavanderhoorn
Copy link

It looks like they have a custom DLL/plugin loader mechanism that allows them to catch these kind of things: 7z/CPP/7zip/UI/GUI/GUI.cpp, lines 147-152 (that is not an official repo, but close enough).

@wjwwood
Copy link
Member

wjwwood commented Dec 19, 2016

You're right @gavanderhoorn, that's crazy. It might be worth doing for high visibility programs, but I wonder what the impact would be on our examples. Maybe it could be baked into them somehow so that it wouldn't be added complexity for simple programs.

@codebot
Copy link
Member Author

codebot commented Dec 19, 2016 via email

@gavanderhoorn
Copy link

From a quick google, perhaps delayed loading with DLLs could be (ab)used to get something like a generic / customisable error dialogue. A Windows dev would probably quickly point out why that is not a sane approach though (for one thing it could mean 'unpredictable' performance hits as loading of code is done JIT).

@jacobperron jacobperron added backlog enhancement New feature or request labels Mar 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants