Mac app crashes from finder but runs inside Terminal - macos

I tried searching, but did not find a specific post that could answer my question.
For my MacOS app, I have an external framework residing in /Library/Frameworks that I am linking to.
The app runs fine from Xcode. The app runs fine by itself on my dev system.
If I copy the app bundle over to another machine, and also copy over the external framework to /Library/Frameworks area (so it has a similar setup to my dev machine), the app crashes when it tries to perform the task that uses the external framework.
What's weird is that the app does not crash on the other machine if run from the terminal, or through gdb. It only crashes on the feature using the external framework when launched from the Finder. I made sure permissions etc are all open.
The crash is of BAD_ACCESS (SIGSEGV) type and the feature involves using the framework to write out a file.
Any thoughts about what could be causing the crash/how to go about debugging this?
Thanks

The most likely difference you're running into is working directories -- launching an application manually from the terminal will run it in whatever directory you happen to be in at the time, while launching it normally (e.g, by double-clicking it in the Finder) will start it up with a working directory of /. Make sure you aren't using any relative paths by mistake.

Related

how to run a self-contained asp.net core api in Mac Os

At first I have to apologize that I know it's a stupid question but since I don't have Mac computer so I can't test it as well, and I also failed to find document in Microsoft about the actions after publish, then I reach here to gather a confirmation from wise SO contributers.
I have an asp.net core project and I published it as self-contained application. When I choose the target OS as windows, then I will get an EXE file in the publish folder, then in a windows OS without .net runtime, I can still run the app by just double clicking the exe file.
Okay, then here's the question, when I choose the target OS as osx-x64, I can get a file like screenshot below. Then if I have a Mac computer, how can I run this File? The Mac wouldn't have .net runtime, and at first I think this app may also can be run by just double clicking the file. Am I right? Or it should be run within a command line like cd xxx first then ./filename?
Thank you very much in advance for your confirmation.

Why do Native Messaging Host processes spawned by Firefox have an odd DLL search order?

I'm trying to create a browser extension using native messaging, where the messaging host is basically a simple launcher for another (3rd party) native executable.
The 3rd party application relies on various DLLs, some of which need to be loaded from the same directory the executable is in. This works perfectly on Chrome (and chromium based Edge as well), however I ran into issues when using Firefox where the wrong DLL would be loaded.
After monitoring, it appears that instead of looking in the executable directory first, messaging host processes (including all their child processes) started by Firefox have the following DLL search order:
System directory
16-bit System directory
Windows directory
Directory of the executable
Working Directory
Directories in path
I was able to reproduce this exact behavior easily in my own launcher application as well by using LoadLibrary without an explicit path, so it is not just the 3rd party app.
Looking through MS documents related to DLL search order, I could not find anything that could cause this, so I am quite lost as to what the issue is, and whether I could go around it somehow.
Already tried the following with no success:
Using cmd.exe as an intermediary to start my process. Tried this both when Firefox starts the native host and when my launcher starts the 3rd party app, neither seem to make a difference.
Calling SetDllDirectory in the launcher. This just replaces Working Directory, but stays after the System folders in the order. Calling it with null does not change anything.
Redirection by adding a .local file/directory. This does force the app to load the DLLs from its own directory, but breaks the application for other reasons I have no control over. (I believe there are full-path dll loads in it which also get overridden this way)
These would only be workarounds either way for what seems to be caused by Firefox, as like I said, when launching the app manually, or using Chrome/Edge everything works as expected.
Any clue why this is happening, or a way I could force the application to use the default DLL search order when it's launched by a Firefox messaging host?

Windows 10 EV code signing no longer works on electron app

I have an electron app. Pretty basic app. It doesn't use ffmpeg for anything it does play an mp3 chime from time to time. I build my app with electron-forge using squirrel format. I then sign it using the SafeNet Authentication app. It's always worked flawlessly.
It's been a couple months since I last released a version. Only thing that has changed is some html ui updates within my electron app and of course lots of Windows 10 updates.
My app builds fine using electron-forge, it installs and runs without issue. I then sign it like usual from the command line and SafeNet confirms it was signed. Right clicking on the file shows it has been signed by my organization. However, once I execute the signed app I get this error: "The code execution cannot proceed because ffmpeg.dll was not found. Reinstalling the program may fix this problem."
Here is what I have tried so far:
Building/Signing on a different windows 10 machine.
Uninstall/Reinstall SafeNet.
Running signed .exe on a different Windows 10 instance
Building/Signing with a cmd session ran as administrator
I am at a loss, why is it screaming about ffmpeg.dll which my app doesn't depend on? Why only after the .exe has been signed do I get this error?
OS: Windows 10
Electron v7.3.2
Electron-Forge/cli v6.0.0-beta.47
SafeNet x64 v10.3
I feel really stupid. I was trying sign the wrong .exe file. Electron-forge creates two output directories when building an app, a directory called "make" and a directory with the name of your app. I should have been signing the .exe in the make folder. The .exe in the app name folder is a stand alone .exe that doesn't have any of the supported .dll files built into it.
After run the
npx #electron-forge/cli import and `npm run make`
Inside the project folder path it creates out folder. Inside out, there are two folders make and electron..........
Go to make then 64x and then you can find .exe
Use that one. It will work without any issue.

No windows appears on deployed application on Windows

I have developed an QML application (Mingw). I want to deploy this app to other Windows system. My instructions are:
Building app in Release mode
Run windeployqt.exe for necessery dlls and folders.
Adding missing dll.
Problem is, when I start my app, it seems to work in background and no window appears. I have wasted a lot of time on this.
I know it's an old question. For anyone to get here looking for an anwser, try using:
windeployqt.exe . --qmldir <\project\folder\>

qt program deployed on mac. config file not writing when standalone app launched, works when run from within qt creator

I have a program that I have developed for mac osx. When the program is run from within Qt creator, a log file and a config.cfg file are created in the myapp.app/Contents/MacOS folder, alongside the executable. This is the correct behaviour, the program needs these files.
When I deploy the app to run standalone (by linking the required libraries using macdeploymentqt tool) the app launches and runs correctly however the log and config.cfg file do not get written to the myapp.app/Contents/MacOS folder and so settings can't be read in.
Is there anyway to get around this? Has anyone encountered this before?
Mitch
osx will likely not allow you writing to your bundle location on installed apps, for security reasons and because it may conflict when multiple users are using your app.
To be cross platform, you could write instead to:
QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)
which resolves to
~/Library/Application Support/<APPNAME>
and
C:/Users/<USER>/AppData/Local/<APPNAME>
or equivalent on windows.
You're never supposed to write to the application bundle, whether on Mac or on Windows. Even on Windows, it will not work if your user isn't an administrator. This idea last made sense on Windows 95 - not even on Windows NT. Don't do it.

Resources