typemytype / drawbot

http://www.drawbot.com
Other
406 stars 63 forks source link

Cancelling with command-period crahses hard #501

Open justvanrossum opened 1 year ago

justvanrossum commented 1 year ago
import time

for i in range(100):
    print(i)
    time.sleep(0.2)

Type command-period while the above is running. It exists with a hard crash Illegal instruction: 4

typemytype commented 1 year ago

when CheckEventQueueForUserCancel is True it fails and crashes

https://github.com/typemytype/drawbot/blob/master/drawBot/scriptTools.py#L110

the rest of the code in side that if statement seems to work fine (did this silly test):

image
justvanrossum commented 1 year ago

I currently cannot get it to not crash, even with Python 3.7, even though the 3.128 release works perfectly.

typemytype commented 1 year ago

what OS?

it crashes every time when esc or cmd . on M1 Ventura

justvanrossum commented 1 year ago

Ok, this is unfortunately related to py2app: it works with py2app==0.25 but crashes with py2app==0.26 and later.

justvanrossum commented 1 year ago

Browsing through https://github.com/ronaldoussoren/py2app/compare/v0.25...v0.26 so far doesn't give me any clues.

justvanrossum commented 1 year ago

it crashes every time when esc or cmd . on M1 Ventura

Same here, unless I downgrade py2app to 0.25 (which also requires downgrading setuptools to something older).

typemytype commented 1 year ago

strange, DB is building the function from the Carbon library with ctypes

https://github.com/typemytype/drawbot/blob/master/drawBot/scriptTools.py#L24-L26

the minimal setup to make it crash, in the main loop, however this works in terminal

import ctypes
from ctypes.util import find_library

_carbonPath = find_library("Carbon")
CheckEventQueueForUserCancel = ctypes.CFUNCTYPE(ctypes.c_bool)(('CheckEventQueueForUserCancel', ctypes.CDLL(_carbonPath)))

while not CheckEventQueueForUserCancel():
    pass
justvanrossum commented 1 year ago

In terminal there is no event loop, so that is to be expected.

I've been trying to make a minimal Cocoa app to reproduce, but I'm failing so far.