Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8493765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:06:43+00:00 2026-06-10T23:06:43+00:00

I have this code: from AppKit import * def setupWindow(): w = NSWindow.alloc() w.initWithContentRect_styleMask_backing_defer_(

  • 0

I have this code:

from AppKit import *

def setupWindow():
    w = NSWindow.alloc()
    w.initWithContentRect_styleMask_backing_defer_(
        ((200.0, 200.0), (250.0, 100.0)),
        NSTitledWindowMask |
        NSClosableWindowMask |
        NSResizableWindowMask,
        NSBackingStoreBuffered, False)
    w.setTitle_("Hello world")

    w.display()
    w.orderFrontRegardless()
    w.makeMainWindow()

    app.delegate().mainWindow = w

    return w

class PyAppDelegate(NSObject):

    def applicationOpenUntitledFile_(self, app):
        print "applicationOpenUntitledFile_", app
        print "delegate:", app.delegate()
        print self.__class__
        setupWindow()

app = NSApplication.sharedApplication()
appDelegate = PyAppDelegate.alloc().init()
app.setDelegate_(appDelegate)
app.finishLaunching()
app.run()

When I click on the dock and no window is open, I get this output:

applicationOpenUntitledFile_ <NSApplication: 0x7fbb57e10bb0>
delegate: <PyAppDelegate: 0x7fbb5770c0f0>
<objective-c class PyAppDelegate at 0x7fbb57e05c30>
fish: Job 1, '../main.py ' terminated by signal SIGSEGV (Address boundary error)

Along with this crash:

Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: EXC_I386_GPFLT

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libobjc.A.dylib                 0x00007fff9474acbc _class_getName + 13
1   _objc.so                        0x0000000109fda3a2 0x109fb7000 + 144290
2   org.python.python               0x0000000109d074e7 0x109c67000 + 656615
3   org.python.python               0x0000000109cd10b7 0x109c67000 + 434359
4   org.python.python               0x0000000109cd0f10 PyDict_SetItem + 145
5   _objc.so                        0x0000000109fdaba1 0x109fb7000 + 146337
6   org.python.python               0x0000000109cdae38 PyObject_SetAttr + 157
7   org.python.python               0x0000000109c7f78d PyEval_EvalFrameEx + 5632
8   org.python.python               0x0000000109c84869 0x109c67000 + 120937
9   org.python.python               0x0000000109c8063a PyEval_EvalFrameEx + 9389
10  org.python.python               0x0000000109c7e147 PyEval_EvalCodeEx + 1934
11  org.python.python               0x0000000109cb7d7a 0x109c67000 + 331130
12  org.python.python               0x0000000109c766c6 PyObject_Call + 97
13  _objc.so                        0x0000000109fcc758 0x109fb7000 + 87896
14  libffi.dylib                    0x00007fff9023b8a6 ffi_closure_unix64_inner + 508
15  libffi.dylib                    0x00007fff9023af66 ffi_closure_unix64 + 70
16  com.apple.AppKit                0x00007fff923ce664 -[NSApplication _doOpenUntitled] + 482
17  com.apple.AppKit                0x00007fff92619e93 -[NSApplication(NSAppleEventHandling) _handleAEReopen:] + 240
18  com.apple.AppKit                0x00007fff923cbabc -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] + 351
19  com.apple.Foundation            0x00007fff9505f35b -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 308
20  com.apple.Foundation            0x00007fff9505f1bd _NSAppleEventManagerGenericHandler + 106
21  com.apple.AE                    0x00007fff94864f68 aeDispatchAppleEvent(AEDesc const*, AEDesc*, unsigned int, unsigned char*) + 307
22  com.apple.AE                    0x00007fff94864dc9 dispatchEventAndSendReply(AEDesc const*, AEDesc*) + 37
23  com.apple.AE                    0x00007fff94864c89 aeProcessAppleEvent + 318
24  com.apple.HIToolbox             0x00007fff94369e29 AEProcessAppleEvent + 100
25  com.apple.AppKit                0x00007fff923c82a6 _DPSNextEvent + 1456
26  com.apple.AppKit                0x00007fff923c7862 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 128
27  com.apple.AppKit                0x00007fff923bec03 -[NSApplication run] + 517
28  libffi.dylib                    0x00007fff9023ade4 ffi_call_unix64 + 76
29  libffi.dylib                    0x00007fff9023b619 ffi_call + 853
30  _objc.so                        0x0000000109fd1557 PyObjCFFI_Caller + 1980
31  _objc.so                        0x0000000109fe6372 0x109fb7000 + 193394
32  org.python.python               0x0000000109c766c6 PyObject_Call + 97
33  org.python.python               0x0000000109c8078d PyEval_EvalFrameEx + 9728
34  org.python.python               0x0000000109c84869 0x109c67000 + 120937
35  org.python.python               0x0000000109c8063a PyEval_EvalFrameEx + 9389
36  org.python.python               0x0000000109c7e147 PyEval_EvalCodeEx + 1934
37  org.python.python               0x0000000109c7d9b3 PyEval_EvalCode + 54
38  org.python.python               0x0000000109cb9c70 0x109c67000 + 339056
39  org.python.python               0x0000000109cb9d3c PyRun_FileExFlags + 165
40  org.python.python               0x0000000109cb9726 PyRun_SimpleFileExFlags + 410
41  org.python.python               0x0000000109cdde27 Py_Main + 2715
42  libdyld.dylib                   0x00007fff946a07e1 start + 1

The crash is in the line app.delegate().mainWindow = w.

Why? Am I doing something wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T23:06:45+00:00Added an answer on June 10, 2026 at 11:06 pm

    I found the problem. The normal close behavior on a window does an additional release. See here.

    It becomes more clear with this code which results in the same crash (in the line where you set it to None):

    if app.delegate().mainWindow:
        app.delegate().mainWindow.close()
        app.delegate().mainWindow = None
    app.delegate().mainWindow = w
    

    It crashes because the close() already deallocates the object. And then PyObjC tries to deallocate it again.

    Thus, the fix is:

    w.setReleasedWhenClosed_(False)
    

    Another possible solution would be to not keep any Python reference to the NSWindow object. Then, in setupWindow(), instead of setting mainWindow and returning the window, just do:

    w.retain()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code in my forms.py : from django import forms from formfieldset.forms
i have this code from t he django sample tutorial from django.db import models
I have this code from win32com.client import Dispatch connection_string = Provider=SQLNCLI;server=%s;initial catalog=%s;user id=%s;password=%s%(server,db_name,user,pwd) dbConn
I have this code from a tutorial: #File called test 1 def sanitize(time_string): 2
I have this code: from BeautifulSoup import BeautifulSoup TABLE_CONTENT = [['958','<a id=958F href=javascript:c_row(\'958\') title=go
I have this code (snippet) from a .h file: #import <UIKit/UIKit.h> #import ILView.h /**
i have this code from a tutorial: // Do the search and show the
I have this source code from 2001 that I would like to compile. It
I have this code that reads from XML file. It gets five strings (groupId,
Ok i have this piece of code from which i took from W3schools :-

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.