Re: App crashes when launched from finder, but not when launched from debugger or command line
Re: App crashes when launched from finder, but not when launched from debugger or command line
- Subject: Re: App crashes when launched from finder, but not when launched from debugger or command line
- From: Rick Mann <email@hidden>
- Date: Mon, 17 Nov 2008 09:48:28 -0800
On Nov 17, 2008, at 05:35:54, Ken Thomases wrote:
On Nov 17, 2008, at 4:10 AM, Rick Mann wrote:
I have a Carbon app that exhibits a crash when launched either by
double-clicking it in the Finder, or clicking on its dock icon. But
if I launch it from within Xcode (with debugger), or by executing
the Contents/MacOS/<executable>, or by using the "open" command-
line tool, it works fine.
The crash occurs when bringing up a utility window. It always
happens in the same place, a Nano framework method called
NHIWindow::Select(). This method is straightforward:
void NHIWindow::Select(bool makeVisible)
{
// Select the window
SelectWindow(mWindow);
if (makeVisible)
SetVisible(true);
}
I call this method successfully on other windows in my app without
trouble. The window that causes the crash is a floating utility
window. When I look at the values of things like this and mWindow,
they look sane. I tried printf-ing their values in this method, but
nothing prints in the crash. I've included a crash report.
The crash report looks like "this" is NULL. That is, you're calling
this method on a NULL object pointer. When the method attempts to
access the mWindow member variable, that's when the access violation
occurs.
That was my very first thought. Examining this (and the only accessed
member within, mWindow) show that they are both valid. Mind you, this
examination takes place in the debugger, where everything works.
I tried printing the values of this & mWindow, but nothing ever
appears in the crashing case.
So, the problem is not at the point of the crash. The problem
occurred earlier and was only exposed by the crash.
Any ideas? What's different about the four different ways of
launching the file?
The main difference is that, when launched by Xcode or executing
Contents/MacOS/<executable>, your program inherits its environment
from the parent process, including environment variables and the
current working directory.
When launched from the Finder or Dock, your program receives a very
basic environment from launchd.
Using "open" used to cause the program to inherit the caller's
environment in Tiger, but since Leopard it should gets the basic
environment from launchd. It _should_ be identical to launching it
from the Finder. I'm not sure why your experience suggests
differently. Were you testing on Tiger?
Nope, all Leopard.
--
Rick
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden