views:

97

answers:

3

I'm debugging an issue on OS X that only occurs when the application is started from the dock. It does not happen when the app is started from the command line. What is the difference between the two scenarios? The code I'm working with is a c++ based bundled plug-in being loaded in a third party app. I've attached to the process with GDB in both scenarios and the only difference I can see is that a couple of extra dylibs are loaded in the process when running from the command line and that the base address of my library is slightly different in the two scenarios. I've tried changing my linkage to -prebind and/or -bind_at_load to no avail.

+1  A: 

One important difference is that the initial working directory will be different in each case. Applications should never make any assumptions about the working directory and will break in interesting ways if they do.

Paul R
Based on more investigation I'm starting to think that the problem is a memory corruption issue and the "only from the dock" symptom is a red herring. Though it doesn't appear to be the problem in my, different working directory is definitely something I looked over when I was trying to come up with possibilities. Thanks for the tip!
Josh Knauer
+1  A: 

An application launched from the Dock icon won't pick up the same environment variables that may be set in the shell you're using. If you're relying on picking up something from the environment, you'll want to look for a different approach. You'll get some of the env vars, like PATH, HOME, LOGNAME, etc. But if you're looking for HOSTTYPE, LANG, OSTYPE, et al, they're not going to be present.

Matthew Etter
A: 

In this case, my problem was caused by a difference in the order that shared libraries are loaded. One of the third party libraries that our application uses loads extension libraries into a global namespace. There were symbol conflicts with a different version of that same library. The order that the extension libraries are loaded into the global pool changes based on whether the app is started from the doc or from the command line.

Josh Knauer