Nethack '_NSAutoreleaseNoPool' - Falling into despair

dave123
Unregistered
 
Post: #1
I'm trying to get myself a gamepad controllable version of Nethack that will use a menu system to gain access to all the commands with just using about 8 buttons + d-pad.

Something like this ( A port to a open linux handheld called gp2x ) :
[Image: Nethackmenu.png]

Now I was trying to re-port this port of 'dzz' and after some changes I was able to compile it correctly but when I'm running it, I get the '_NSAutoreleaseNoPool' messages. I first thought that's a problem with this port, so I downloaded the official nethack sources, multiple frontends, slash'em.. Basically every source available and worked on them but after a lot of hassle I always came to the same end.

After searching the I-Net for over an hour I found some hints that this error comes from a problem with threads where the pool hasn't been allocated in the thread. So I changed it to a non-threaded version, but the errors stayed the same.

The source is in c++ & sdl. I haven't got any experiance with cocoa or obj-c programming ( what could be the problem, according to some guy in a newsgroup ), so could please anyone help me with this? I've been trying for hours..
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
These are caused when -autorelease is sent to an Objective-C object when there is no NSAutoreleasePool present. You need to find the places where they are occurring, and add NSAutoreleasePools around the problem code.

The code will look like

Code:
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// ... code here that [eventually] autoreleases ObjC objects
[pool release];

But I can't tell you exactly where to put that code, obviously Smile
Quote this message in a reply
dave123
Unregistered
 
Post: #3
First, thanks a lot for helping out, I've nearly gone crazy with this problem and a segfault in my graphics engine..

So this is objc code? What's the easiest way to use this in a c++ project?
I haven't got zero experience with objc and any other way of programming/compiling/porting than c, sdl and a simple text editor. Wink

I've searched and found that the Foundation framework defines the autorelease pools? But obviously I can't import this in the .c file, the compiler is going crazy with the obj-c. How can I use the old source file and just implent this solution via obj-c?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
I think you need to find the answer to the question of *where* the leaks are coming from, before you can fix them.

Unless you're getting heaps of them as you run, you can ignore them (one or two at startup is nothing more than an annoyance).
Quote this message in a reply
Moderator
Posts: 1,562
Joined: 2003.10
Post: #5
If you need to keep Objective-C separate from the rest of your code, you could create a .m file with one or more C functions in it that would contain all of the Objective-C code you need to use. Then, just call those functions from your C code, and the file calling them can still use the .c extension.
Quote this message in a reply
dave123
Unregistered
 
Post: #6
Well, I traced the errors to SDL_SetVideoMode. If I add the flag SDL_FULLSCREEN it does work, else it will generate the following warnings & errors;
Code:
_NSAutoreleaseNoPool ( Around 50 times )
Uncaught exception: <NSInternalInconsistencyException> Error (1002) creating CGSWindow
Trace/BPT trap

I'm not quite sure what to do with this since leaks are coming from the sdl library...

And thanks for all the advice, a really nice community here!
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #7
I'm going to take a wild stab in the dark and guess that you aren't using SDLMain.m...
Quote this message in a reply
dave123
Unregistered
 
Post: #8
Well, now I'm at a point where everything runs more or less fine ( in windowed mode it gets all drawn in the upper left corner, not being in a window, but that's the rendering code ) but the app doesn't receive any keyboard events!

If it's run in windowed mode, the mouse changes to the spinning circle and it tells me that I should fore quit the app ( but I still get the terminal output of the in-game stuff ) and in fullscreen mode it also doesn't receive any input..


Edit: Bundled into a .app folder it also doesn't recognize any keyboard input.

The only event I get is after pressing ctrl+alt+esc what quits the fullscreen app..

Edit2: Using Spin Control I got the following output ( windowed ), but it doesn't help me alot, maybe someone could give me a hint. But I don't think just these values could give some info..
If it is run fullscreen, Spin Control tells me that 'loginwindow' is aswell unresponsive.


Code:
Call graph:
    900 Thread_4947
      900 0x297c
        900 0x2ad4
          900 0x3b14
            900 0x936d708c
              900 0x936dab48
                900 0x936db05c
                  900 0x931db0e0
                    900 0x914f2654
                      900 0x914f27fc
                        900 0x914f2960
                          900 0x92932944
                            900 0x92932ae4
                              900 0x936dc914
                                900 0x936dcd6c
                                  900 0x936dd224
                                    900 0x936dd338
                                      900 0x9291bee0
                                        900 0x907fb0ec
                                          900 0x90803010
                                            900 0x92931ad8
                                              900 0x34dc
                                                900 0x16a978
                                                  878 0x16f2d4
                                                    878 0x900443f8
                                                      877 0x90040eb8
                                                        877 0x90040eb8
                                                      1 0x90040b64
                                                        1 0x90040b64
                                                  21 0x900443b8
                                                    21 0x900443b8
                                                  1 0x900443bc
                                                    1 0x900443bc
    900 Thread_565b
      900 0x9002ba68
        760 0x175d54
          760 0x175d54
        71 0x175d30
          41 0x174a18
            15 0xffff8a60
              15 0xffff8a60
            8 0xffff89b4
              8 0xffff89b4
            6 0xffff8a70
              6 0xffff8a70
            5 0xffff8a50
              5 0xffff8a50
            2 0xffff89e0
              2 0xffff89e0
            2 0xffff8a54
              2 0xffff8a54
            1 0xffff89e4
              1 0xffff89e4
            1 0xffff8a64
              1 0xffff8a64
            1 0xffff8a8c
              1 0xffff8a8c
          18 0x174b20
            8 0x16d230
              8 0x16d230
            3 0x16d6e4
              3 0x16d6e4
            2 0x16b570
              2 0x16b570
            2 0x16ebe0
              1 0x16d704
                1 0x16d704
              1 0x16d740
                1 0x16d740
            1 0x16b590
              1 0x16b590
            1 0x16b5a0
              1 0x16b5a0
            1 0x16ecf0
              1 0x16ecf0
          4 0x16d230
            4 0x16d230
          3 0x16b594
            3 0x16b594
          2 0x16b5a8
            2 0x16b5a8
          1 0x16b57c
            1 0x16b57c
          1 0x16b590
            1 0x16b590
          1 0x16fcf8
            1 0x16fcf8
        15 0x175cc4
          15 0x30025e58
            15 0x30025cf8
              15 0x300274d0
                14 0x30028de0
                  8 0x30029b88
                    5 0x90aeb020
                      5 0x90aea3a0
                        4 0x90ae90e0
                          4 0x90ae90e0
                        1 0x90ae939c
                          1 0x90ae939c
                    3 0x90aeb004
                      3 0x90aef44c
                        3 0x9000b0a8
                          3 0x9000b0a8
                  6 0x30029c94
                    6 0x90aed184
                      4 0x1f9bd88
                        3 0x90aeb004
                          3 0x90aef44c
                            3 0x9000b0a8
                              3 0x9000b0a8
                        1 0x90aeb020
                          1 0x90aea3a0
                            1 0x90ae8bc0
                              1 0x90ae8bc0
                      2 0x1f9bde0
                        2 0x1f9daf0
                          2 0x1f9de40
                            2 0x907eb3c4
                              2 0x1f9dd44
                                2 0x1f9e0bc
                                  2 0x1f9de40
                                    2 0x907eb3c4
                                      2 0x1f9dd44
                                        1 0x1f9e4a0
                                          1 0x907fa534
                                            1 0x907f09d0
                                              1 0x907c7854
                                                1 0x907c7ce8
                                                  1 0x907c7ce8
                                        1 0x1f9e4b8
                                          1 0x907bbf34
                                            1 0x907bbe3c
                                              1 0x907bbe3c
                1 0x30028efc
                  1 0x1f9ead4
                    1 0x1f9b524
                      1 0x90aeb878
                        1 0x90aed660
                          1 0x9000b0a8
                            1 0x9000b0a8
        10 0x175d84
          10 0x175d84
        8 0x175ce8
          8 0x30020524
            8 0x3002b430
              8 0x3002fd5c
                8 0x3002aee0
                  8 0x93704ad0
                    8 0x93704ce8
                      6 0x93705980
                        6 0x93738320
                          6 0x93738394
                            5 0x937385b8
                              5 0x937389c4
                                5 0x93738b1c
                                  5 0x93738e0c
                                    5 0x93738ee4
                                      5 0x937390c0
                                        5 0x936f7a7c
                                          5 0x93739160
                                            5 0x936ff9d8
                                              5 0x936ffb18
                                                5 0x936f8240
                                                  5 0x936e6cb4
                                                    3 0x936e720c
                                                      3 0x9021b3d4
                                                        3 0x9021b488
                                                          3 0x9021b82c
                                                            3 0x9021bae8
                                                              3 0x9021bc88
                                                                1 0x9021bdf0
                                                                  1 0x902403c8
                                                                    1 0x9023fca8
                                                                      1 0x902a22a4
                                                                        1 0x902a22f8
                                                                          1 0x902a2520
                                                                            1 0x902a34f0
                                                                              1 0x902a34f0
                                                                1 0x9021be60
                                                                  1 0x9021c50c
                                                                    1 0x9021c6c8
                                                                      1 0x907cf8ac
                                                                        1 0x907d003c
                                                                          1 0x907c7ca0
                                                                            1 0x907c3ef0
                                                                              1 0x907c3ef0
                                                                1 0x9021be68
                                                                  1 0x9021c9b0
                                                                    1 0x9021ca2c
                                                                      1 0x907bbffc
                                                                        1 0x907bbffc
                                                    2 0x936e72fc
                                                      2 0x93a24a88
                                                        2 0x93a24a88
                            1 0x937386c0
                              1 0x9370ecc0
                                1 0x90a3e1d4
                                  1 0x90a3e430
                                    1 0x90a3e430
                      2 0x937059c4
                        1 0x937160d0
                          1 0x9373cce4
                            1 0x93716eb4
                              1 0x937170d4
                                1 0x90a3e1d4
                                  1 0x90a3e430
                                    1 0x90a3e430
                        1 0x937164c0
                          1 0x907d9b0c
                            1 0x93709bec
                              1 0x93789c54
                                1 0x9377a04c
                                  1 0x90a3e1d4
                                    1 0x90a3e404
                                      1 0x90a3ec28
                                        1 0x90a3b760
                                          1 0x90a3b760
        8 0x175d50
          8 0x175d50
        7 0x175d14
          7 0x17585c
            6 0x300048f8
              3 0x3002d660
                3 0x90ec4d9c
                  3 0x90ec4ec4
                    3 0x90aebd64
                      3 0x90aeed10
                        3 0x9000b0a8
                          3 0x9000b0a8
              1 0x3002d774
                1 0x936dab48
                  1 0x936dad5c
                    1 0x936daab4
                      1 0x9086b734
                        1 0x9086b734
              1 0x3002ed3c
                1 0x92aa66e4
                  1 0x92aa66e4
              1 0xfffeff00
                1 0xfffeff00
            1 0x8fe15498
              1 0x8fe04174
                1 0x8fe106b4
                  1 0x8fe101bc
                    1 0x8fe130a0
                      1 0x8fe130a0
        6 0x175d60
          6 0x175d60
        5 0x175d78
          5 0x175d78
        4 0x175da0
          4 0x300213a4
            2 0x3002b79c
              2 0x9174742c
                1 0x90b9120c
                  1 0x90b91268
                    1 0x90b912c8
                      1 0x90b913e8
                        1 0x90b917b8
                          1 0x90b91834
                            1 0x90b91834
                1 0x90b91220
                  1 0x90b8cd0c
                    1 0x900063a0
                      1 0x900063a0
            1 0x3002b808
              1 0x9039ca60
                1 0x9039ca60
            1 0x90a3e0e8
              1 0x90a3e0e8
        3 0x30021224
          3 0x30021224
        1 0x175d28
          1 0x172974
            1 0x172974
        1 0x175d6c
          1 0x175d6c
        1 0x30021220
          1 0x30021220
    900 Thread_574b
      900 0x9002ba68
        900 0x30028320
          900 0x30026184
            895 0x30007ebc
              895 0x9001f5ec
                895 0x9001f5ec
            4 0x30007c30
              4 0x30007c30
            1 0x30007ec0
              1 0x30007ec0

Total number in stack (recursive counted multiple, when >=5):

Sort by top of stack, same collapsed (when >= 5):
        0x9001f5ec        895
        0x90040eb8        877
        0x175d54        760
        0x900443b8        21
        0xffff8a60        15
        0x16d230        12
        0x175d84        10
        0x9000b0a8        10
        0x175d50        8
        0xffff89b4        8
        0x175d60        6
        0xffff8a70        6
        0x175d78        5
        0xffff8a50        5
Quote this message in a reply
Post Reply