banthar / Go-SDL

Go bindings for SDL
218 stars 68 forks source link

NSInternalInconsistencyException creating window in test. OS X 10.6.6 #19

Open jakerr opened 13 years ago

jakerr commented 13 years ago

Problem

When I run the GO-SDL test on OSX 10.6.6 I get a lot of errors about leaking objects due to no autorelease pool being in place, and then a crash trying to create the window.

Hardware / Software Overview

Model Name: MacBook Pro
Model Identifier: MacBookPro6,2
Processor Name: Intel Core i7
Processor Speed: 2.8 GHz
Number Of Processors: 1
Total Number Of Cores: 2
L2 Cache (per core): 256 KB
L3 Cache: 4 MB
Memory: 8 GB
Processor Interconnect Speed: 4.8 GT/s
Boot ROM Version: MBP61.0057.B0C
SMC Version (system): 1.58f16
Sudden Motion Sensor:
State: Enabled

System Version: Mac OS X 10.6.6 (10J567)
Kernel Version: Darwin 10.6.0
Boot Volume: Mac HD
Boot Mode: Normal
Secure Virtual Memory: Enabled
64-bit Kernel and Extensions: No
Time since boot: 15:54

Developer Information

Version: 4.0 (4A251a)
Location: /Xcode4
Applications:
Xcode: 4.0 (92)
Instruments: 3.0 (3524)
Dashcode: 3.0.2 (333)
SDKs:
Mac OS X:
10.5: (9L31a)
10.6: (4A251a)
iPhone OS:
4.2: (8C134)
iPhone Simulator:
3.2: (7W367a)
4.0: (8A400)
4.1: (8B117)
4.2: (8C134)

Go-SDL test output

bluehex@macbook:~/contrib/Go-SDL/test$ ./test 
2011-04-03 13:08:02.529 test[85928:903] *** __NSAutoreleaseNoPool(): Object 0x401c4f0 of class NSCFNumber autoreleased with no pool in place - just leaking
2011-04-03 13:08:02.531 test[85928:903] *** __NSAutoreleaseNoPool(): Object 0x4300000 of class NSCFNumber autoreleased with no pool in place - just leaking

# <<about 75 more lines of 'autoreleased with no pool in place - just leaking' warnings>>

2011-04-03 13:08:02.685 test[85928:903] *** __NSAutoreleaseNoPool(): Object 0x260b9c0 of class NSTrackingArea autoreleased with no pool in place - just leaking
Sun Apr  3 13:08:02 macbook test[85928] <Error>: kCGErrorInvalidConnection: CGSGetCurrentCursorLocation: Invalid connection
Sun Apr  3 13:08:02 macbook test[85928] <Error>: kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch errors as they are logged.
2011-04-03 13:08:02.685 test[85928:903] *** __NSAutoreleaseNoPool(): Object 0x430d9f0 of class NSTrackingArea autoreleased with no pool in place - just leaking
Sun Apr  3 13:08:02 macbook test[85928] <Error>: kCGErrorInvalidConnection: CGSGetCurrentCursorLocation: Invalid connection
Sun Apr  3 13:08:02 macbook test[85928] <Error>: kCGErrorInvalidConnection: CGSNewWindowWithOpaqueShape: Invalid connection
2011-04-03 13:08:02.686 test[85928:903] *** __NSAutoreleaseNoPool(): Object 0x430e620 of class NSCFString autoreleased with no pool in place - just leaking
2011-04-03 13:08:02.686 test[85928:903] *** __NSAutoreleaseNoPool(): Object 0x430dd90 of class NSException autoreleased with no pool in place - just leaking
2011-04-03 13:08:02.686 test[85928:903] *** __NSAutoreleaseNoPool(): Object 0x430e820 of class _NSCallStackArray autoreleased with no pool in place - just leaking
2011-04-03 13:08:02.686 test[85928:903] *** __NSAutoreleaseNoPool(): Object 0x430e8d0 of class _NSCallStackArray autoreleased with no pool in place - just leaking
2011-04-03 13:08:02.687 test[85928:903] *** __NSAutoreleaseNoPool(): Object 0x430ea00 of class NSCFString autoreleased with no pool in place - just leaking
2011-04-03 13:08:02.687 test[85928:903] *** __NSAutoreleaseNoPool(): Object 0x4806a00 of class NSCFString autoreleased with no pool in place - just leaking
2011-04-03 13:08:02.687 test[85928:903] *** __NSAutoreleaseNoPool(): Object 0x430ea70 of class NSConcreteMutableData autoreleased with no pool in place - just leaking
2011-04-03 13:08:02.688 test[85928:903] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Error (1002) creating CGSWindow'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x00007fff875167b4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x00007fff83de90f3 objc_exception_throw + 45
    2   CoreFoundation                      0x00007fff875165d7 +[NSException raise:format:arguments:] + 103
    3   CoreFoundation                      0x00007fff87516564 +[NSException raise:format:] + 148
    4   AppKit                              0x00007fff84416ee2 _NSCreateWindowWithOpaqueShape2 + 473
    5   AppKit                              0x00007fff843ab489 -[NSWindow _commonAwake] + 1214
    6   AppKit                              0x00007fff843a816e -[NSWindow _commonInitFrame:styleMask:backing:defer:] + 1501
    7   AppKit                              0x00007fff843a6dfa -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1396
    8   AppKit                              0x00007fff843a6883 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 42
    9   libSDL-1.2.0.dylib                  0x000000000218bc0d -[SDL_QuartzWindow initWithContentRect:styleMask:backing:defer:] + 285
    10  libSDL-1.2.0.dylib                  0x00000000021890e4 QZ_SetVideoMode + 1076
    11  libSDL-1.2.0.dylib                  0x000000000218025f SDL_SetVideoMode + 527
    12  test                                0x00000000000175aa 0x0 + 95658
    13  test                                0x0000000000003c2d 0x0 + 15405
)
terminate called after throwing an instance of 'NSException'
SIGABRT: abort
pc: 0x7fff82e3f616

goroutine 1 [3]:
runtime.entersyscall+0x28 /Users/bluehex/go/src/pkg/runtime/proc.c:617
    runtime.entersyscall()
runtime.cgocall+0xb1 /Users/bluehex/go/src/pkg/runtime/cgocall.c:42
    runtime.cgocall(0x1758e, 0x2386e10, 0x2386e18, 0x162a0)
sdl._Cfunc_SDL_SetVideoMode+0x2f /Users/bluehex/contrib/Go-SDL/sdl/_obj/_cgo_defun.c:387
    sdl._Cfunc_SDL_SetVideoMode(0x1e000000280, 0x1000000020)
sdl.SetVideoMode+0x3b /Users/bluehex/contrib/Go-SDL/sdl/_obj/sdl.cgo1.go:-803
    sdl.SetVideoMode(0x1e000000280, 0x1000000020, 0xf800000000, 0xf840001280, 0x8863, ...)
main.main+0x157 /Users/bluehex/contrib/Go-SDL/test/test.go:58
    main.main()
runtime.mainstart+0xf /Users/bluehex/go/src/pkg/runtime/amd64/asm.s:77
    runtime.mainstart()
runtime.goexit /Users/bluehex/go/src/pkg/runtime/proc.c:150
    runtime.goexit()
----- goroutine created by -----
_rt0_amd64+0x8e /Users/bluehex/go/src/pkg/runtime/amd64/asm.s:64
rax     0x0
rbx     0x7fff704da2d8
rcx     0x7fff5fbfede8
rdx     0x0
rdi     0x14fa8
rsi     0x6
rbp     0x7fff5fbfee00
rsp     0x7fff5fbfede8
r8      0x7fff704dda40
r9      0x63
r10     0x7fff82e3b656
r11     0x206
r12     0x7fff8759bb09
r13     0x0
r14     0x2
r15     0x0
rip     0x7fff82e3f616
rflags  0x206
cs      0x2f
fs      0x10
gs      0x48
banthar commented 13 years ago

http://www.libsdl.org/cgi/docwiki.cgi/SDL_envvars

Try using x11 driver (SDL_VIDEODRIVER=x11).

If you want to use the default driver (Quartz), you need to run your program through SDLmain. In Go it's not easy.

nickoneill commented 13 years ago

banthar, your comment helped me get sdl working in x11 on roughly the same hardware as bluehex. I'm interested in getting things running through Quartz as well, do you have any tips on where I should start looking? Or an explanation why it's not easy? Any information helps.

banthar commented 13 years ago

To use GUI on Mac (and Windows), you need to initialize some stuff before your program starts. In SDL It's done through SDLmain module. It contains entry point for GUI programs. On windows it's WinMain, on Mac it's some Objective-C stuff. The problem is you cannot write SDLmain in Go. It has to be written in C/Objective-C. And it has to be the entry point of your executable, while Go already specifies it's own to make it's own initializations. Finally, the executable has to be marked as GUI.

Basically, Go needs to add support for GUI programs. This requires some changes in go compiler and runtime. On windows some work is already done (http://code.google.com/p/go/source/detail?r=ef61c195ed), but I haven't heard anything about Mac. Maybe it's mentioned somewhere in Go docs, issues, or mailing list/irc archives.

I don't know if any of this is accurate. You should probably talk to someone familiar with Macs.

cookieo9 commented 13 years ago

SDL 1.3 doesn't need a SDLmain function on OSX as far as I can tell, but the Go-SDL wrapper doesn't compile due to some API differences.

ghost commented 12 years ago

A fix for this issue: https://github.com/0xe2-0x9a-0x9b/Go-SDL/commit/e4605f9fc41eb624d69a9d7e6e72e95b64e51e2a

netpoetica commented 11 years ago

SDL 1.3 doesn't exist as far as I can tell O_O

I initially had this issue, but then I downlloaded SDL2 and did configure, make, make install (I couldn't find any SDL 1.3) and now I get a different error:

# command-line-arguments
ld: library not found for -lSDLmain
collect2: ld returned 1 exit status
/Users/netpoetica/go/pkg/tool/darwin_amd64/6l: running gcc failed: unsuccessful exit status 0x100

Anyone know what's going on here?

Had to revert back to 1.2 as apparently SDL + Mac OSX is a major problem :0

So back to this same issue. Is there an updated solution to this (this thread is years old)? Additionally this URL http://www.libsdl.org/cgi/docwiki.cgi/SDL_envvars is broken so I cannot follow to learn more about using x11

netpoetica commented 11 years ago

Also if it helps any, I am using it to try to compile some of the go-gl examples. I am able to compile some of them, like some of the NeHe ones, but this particular one is actually from github.com/go-gl/examples/sdl/gears - that's where I get this issue.

As I play around more with the framework I will try to post back if I ever get the gears example working

Thanks a bunch!