Hello, I am getting a very strange crash, in a place of my code which never hat problems before. The exact same code works in another PasCocoa example, and even the same code worked before! Sometimes the application won't crash, but most times it will. Here is my code (also available in the lazarus-ccr subversion in lazarus-ccr/bindings/pascocoa/examples/texteditor
Any ideas? I am really lost at what could cause such behavior. I am using fpc 2.2.2 in Mac OS X 10.4 var pool: NSAutoreleasePool; begin { Avoids arithmetic exceptions in Objective-C code } SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide, exOverflow, exUnderflow, exPrecision]); // doesn't matter if I comment this { Creates the AutoreleasePool } pool := NSAutoreleasePool.Create; { Creates the application NSApp object } NSApp := NSApplication.sharedApplication; { Initializes the controller, view and model objects } myController := TMyController.Create(); // Enters here ... constructor TMyController.Create; begin { The class is registered on the Objective-C runtime before the NSObject constructor is called } if not CreateClassDefinition(ClassName(), Str_NSObject) then WriteLn('Failed to create objc class ' + ClassName()); inherited Create; // Enters here { Create objects } OpenPanel := NSOpenPanel.openPanel; SavePanel := NSSavePanel.savePanel; end; constructor NSObject.Create; begin ClassId := getClass(); allocbuf := objc_msgSend(ClassId, sel_registerName(PChar(Str_alloc)), []); // Crashes here Handle := objc_msgSend(allocbuf, sel_registerName(PChar(Str_init)), []); { Adds custom methods, if any } AddMethods(); end; Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_PROTECTION_FAILURE at address: 0x00000007 0x90a594c7 in objc_msgSend () (gdb) bt #0 0x90a594c7 in objc_msgSend () #1 0x000f7294 in U_SYSTEM_RETURNNILIFGROWHEAPFAILS () #2 0x0004629e in TMYCONTROLLER__CREATE (vmt=0xdf8f4, this=0x41d190) at controller.pas:77 #3 0x00002788 in PASCALMAIN () at texteditor.pas:38 #4 0x0001c555 in SYSTEM_FPC_SYSTEMMAIN$LONGINT$PPCHAR$PPCHAR () #5 0x00002702 in _start () #6 0x00002629 in start () thanks, -- Felipe Monteiro de Carvalho _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal