re: crash in the carbon event loop

"Mr. George Warner" <[email protected]>
Newsgroups gmane.comp.macosx.devel
Message-ID <[email protected]>
On Wed, 11 Nov 2009 14:28:20 +1300, Emmanuel Quetelard <[email protected]> wrote:
> I have a weird crash in the carbon RunApplicationEventLoop() function.
> According to the backtrace it crash somewhere in this method without touching one of my event handler.
> To be more precise mouse events work just fine but keyboard events seem to crash the application.
> Whatever I do with the handlers doesn't seem to change anything...(like disabling keyboard or mouse events handler or whatever..)

More often than not this is caused by you CFReleasing something that you shouldn't be releasing. The clang analyzer is good at picking up a lot of these unnecessary CFReleases. Use the "Build and Analyze" item in Xcode's "Build" menu.

Also, make sure you haven't turn off compiler and linker warnings. At the very least I'd max them out in my debug builds. You can cut-n-paste the following into your project (or target) build settings:

[BEGIN]

•	All Configurations

ARCHS = $(ARCHS_STANDARD_32_BIT) x86_64
GCC_DYNAMIC_NO_PIC = NO
GCC_ENABLE_FIX_AND_CONTINUE = NO
GCC_PRECOMPILE_PREFIX_HEADER = YES
GCC_WARN_FOUR_CHARACTER_CONSTANTS = NO
PREBINDING = NO
ZERO_LINK = NO

•	Debug

COPY_PHASE_STRIP = NO
DEBUG_INFORMATION_FORMAT = dwarf
GCC_FAST_OBJC_DISPATCH = NO
GCC_GENERATE_DEBUGGING_SYMBOLS = YES
GCC_OPTIMIZATION_LEVEL = 0
GCC_PREPROCESSOR_DEFINITIONS = $(value) DEBUG=1
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES
GCC_WARN_ABOUT_RETURN_TYPE = YES
GCC_WARN_CHECK_SWITCH_STATEMENTS = YES
GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = NO
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES
GCC_WARN_MISSING_PARENTHESES = YES
GCC_WARN_PEDANTIC = NO
GCC_WARN_SHADOW = YES
GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES
GCC_WARN_UNINITIALIZED_AUTOS = NO
GCC_WARN_UNKNOWN_PRAGMAS = YES
GCC_WARN_UNUSED_FUNCTION = YES
GCC_WARN_UNUSED_LABEL = YES
GCC_WARN_UNUSED_PARAMETER = YES
GCC_WARN_UNUSED_VALUE = YES
GCC_WARN_UNUSED_VARIABLE = YES
ONLY_ACTIVE_ARCH = YES
OTHER_CFLAGS = $(value) -Wimplicit-function-declaration
OTHER_CPLUSPLUSFLAGS = 
WARNING_CFLAGS = -Wall -Wcast-align -Wchar-subscripts -Wextra -Wextra-tokens -Wformat=2 -Wpointer-arith -Wswitch-default -Wundef -Wwrite-strings

•	Release

COPY_PHASE_STRIP = YES
DEBUG_INFORMATION_FORMAT = dwarf-with-dsym
GCC_FAST_OBJC_DISPATCH = YES
GCC_GENERATE_DEBUGGING_SYMBOLS = NO
GCC_OPTIMIZATION_LEVEL = s
ONLY_ACTIVE_ARCH = NO

• Current SDK & target OS

SDKROOT = 
MACOSX_DEPLOYMENT_TARGET = 

• Snow Leopard

MACOSX_DEPLOYMENT_TARGET = 10.6
SDKROOT = $(DEVELOPER_SDK_DIR)/MacOSX10.6.sdk

• PowerPC Leopard, Intel Snow Leopard and deploy to Tiger

SDKROOT = macosx10.6
SDKROOT[arch=ppc] = macosx10.5
MACOSX_DEPLOYMENT_TARGET = 10.4

[END]

With all the above warnings on build your debug configuration and pay attention to the warnings.

In the "Mac OS X Debugging Magic" technote (<http://developer.apple.com/mac/library/technotes/tn2004/tn2124.html>) read the section on tracing Carbon events:
<HIToolbox Event Debugging>. It may be of interest which event handler is being called when the crash occurs.

-- 
Enjoy,
George Warner,
Schizophrenic Optimization Scientist
Apple Developer Technical Support (DTS)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.