Created attachment 173616 [details] log of last session and sysinfo *** krita exits with code 13 on unlinking shared_memory in python scripter and plugins this bug only occurs on macos If you're reporting a crash, attach a backtrace with debug symbols; see https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports Please remove this comment after reading and before submitting - thanks! *** SUMMARY I am developing plugin using shared memory feature and encountered issues on macos. while on windows and linux this issue is not present. I also tested code that is resulting in crash in python repl and other application allowing for scripting (blender) and did not encounter any issues. STEPS TO REPRODUCE 1. open tools>scripts>scripter 2. paste from multiprocessing import shared_memory test = shared_memory.SharedMemory(create=True, size=10000) test.unlink() 3. click run button 3 times OBSERVED RESULT krita crashes with no reasonable log errors exit status 13 EXPECTED RESULT krita reports a bug or works properly like on other platforms SOFTWARE/OS VERSIONS macOS: 14.6.1 (23G93) ADDITIONAL INFORMATION also tested on 5.3.0-prealpha git 9f8f65f and produced same results I am testing it on Intel vm SYSTEM INFO
Sorry, but I cannot reproduce this problem. Do you have any third-party python plugins installed?
(In reply to Halla Rempt from comment #1) > Sorry, but I cannot reproduce this problem. Do you have any third-party > python plugins installed? I do not, I disabled and uninstalled them, and I have same issue. It might be that I am on macOS vm but that should probably break every python runtime. Shared memory behaves weirdly on macOS, I executed the script like 2-6 times for it to always result in a crash. also weird thing is that when I open shared memory on mac another krita icon appears in the dock for like 1s and disappears.
I can reproduce this. Just running the script twice to create the shared memory even without unlinking is enough to crash Krita with SIGPIPE. Having the script create a shared memory twice or more in one run doesn't crash. I can also confirm the second Krita icon briefly appearing. Maybe that's another process, which could be related to the SIGPIPE?
Setting to confirmed then. I'm not sure we can do much about this, though -- one reason for the g'mic rewrite we did years ago was that macos has a really small shared memory allocation per process.
(In reply to Halla Rempt from comment #4) > Setting to confirmed then. I'm not sure we can do much about this, though -- > one reason for the g'mic rewrite we did years ago was that macos has a > really small shared memory allocation per process. I can easily allocate 64MB of SharedMemory and work with it in my scripts. No matter if I am opening or creating SharedMemory it crashes on subsequent use. And of course it works in python interpreter in standard way. The memory allocation also does not matter as I can allocate objects of size 4KB(minimal amount as far as I have seen) and still get a crash. I donβt know how krita works but It looks like it is not entirely os issue. the amount of memory created is irrelevant, the issue occurs on opening shared memory object(unlinking too) and allows allocation of rather big chunks of memory. Also I think the max amount of shared memory per process on macos can be changed by some commands.
I don't get a crash as such, but I do get a weird message from deep within Python: ==== Warning: Script not saved! ==== ==== Warning: Script not saved! ==== /Users/halla/Desktop/krita.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.10/multiprocessing/resource_tracker.py:104: UserWarning: resource_tracker: process died unexpectedly, relaunching. Some resources might leak. warnings.warn('resource_tracker: process died unexpectedly, ' ==== Warning: Script not saved! ==== ==== Warning: Script not saved! ==== ==== Warning: Script not saved! ==== ==== Warning: Script not saved! ====
I tested with 5.2.6, btw -- the report is for 5.2.3 Krita embeds its own version of Python, and I cannot get the weird warning with the system python, but I'm also pretty sure we're not going to be able to fix this. since it doesn't happen in our own code. The issue might appear or disappear whenever we update the version of Python we embed. Could you check whether 5.2.6 doesn't crash for you, and whether you also see the weird message?
I checked it with the 5.2.6 version and it went the same way, krita crashed. Also its worth to note that after the first shm init and unlink weird line goes to output. krita: Unknown option 'c'. full log: macos@macoss-Mac-Pro ~ % /Applications/krita.app/Contents/MacOS/krita 2024-10-31 16:45:08.591 krita[1271:30582] WARNING: Secure coding is automatically enabled for restorable state! However, not on all supported macOS versions of this application. Opt-in to secure coding explicitly by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState:. qt.qpa.fonts: Populating font family aliases took 100 ms. Replace uses of missing font family ".AppleSystemUIFont" with one that exists to avoid this cost. Invalid profile : "/Library/ColorSync/Profiles//WebSafeColors.icc" QObject::startTimer: Timers cannot have negative intervals /Applications/krita.app/Contents/lib/krita-python-libs/krita added to PYTHONPATH qt.svg: Cannot open file ':/icons/debug_arrow.svg', because: No such file or directory qt.svg: Cannot open file ':/icons/debug_arrow.svg', because: No such file or directory krita: Unknown option 'c'.
ππ§Ή Thanks for your comment! Automatically switching the status to REPORTED so the team can perform further triage. In the future you may also do this yourself when providing needed information.
I really wonder what the difference between our systems is then. I'm testing with an M1 pro macbook with sequoia 15.01.
(In reply to Halla Rempt from comment #10) > I really wonder what the difference between our systems is then. I'm testing > with an M1 pro macbook with sequoia 15.01. I am using Intel Mac sonoma 14.6.1 in vm with gpu passthrough so the setup is much different. But anyway, I installed krita next nightly build(ebe387e) and the script behaves same as your output, also I checked 5.2.6 version and it somehow works same there too, checked 5.2.3 and same thing. I ticked some security setting while installing the next nightly so maybe that did it. Will need to test it on clear system probably.
Yes, please test in a clean system, if at all possible. Freya, I wonder what your setup is that you got this crash?