How can I contribute to Haiku?

3 Likes

I think Python bindings for the Haiku API would be great. The hard (and fun) part of the bindings is usually converting between the native language types and Python - I used Pyrex back in the day to create Python bindings for PortAudio, and I used PerlXS to wrap some Objective-C MacOS functions in Perl. It’s always rewarding when you get it to work! If I had free time I might be interested in working on this, but right now I really don’t have much.

4 Likes

pybind11 will convert between cpp and python types

The problem is that I do not have any experience in C++ or the Haiku API

current progress:
screenshot

14 Likes

So far have made bindings for:
AppDefs.h, Application.h, Clipboard.h, Cursor.h, Handler.h, Invoker.h, Key.h, KeyStore.h, Looper.h, Message.h, MessageFilter.h, MessageQueue.h

8 Likes

I have done ‘complete’ bindings for AppKit, and InterfaceKit.h, Window.h, Rect.h, View.h, StringView.h, Button.h, Control.h and TextControl.h in the InterfaceKit.
I compile all the cpp files in each kit together into one .so and symlink it to Window.so, View.so, etc.
My problem is, when i run this test program,

from bin import BApplication, BWindow, BRect, BMessage, BView, BButton, window_type,  B_NOT_RESIZABLE

class Window(BWindow):
    def __init__(self):
        BWindow.__init__(self, BRect(100,100,200,150), "Hello Haiku!", window_type.B_TITLED_WINDOW,  B_NOT_RESIZABLE)
        self.say_hi = BMessage(1)
        self.panel = BView(self.Bounds(), "panel", 8, 20000000)
        self.button = BButton(self.panel.Bounds(), "hi", "Say Hello!", self.say_hi) #BRect(10,10,100,50)
        self.panel.AddChild(self.button, None)
        self.AddChild(self.panel, None)
 
    def MessageReceived(self, msg):
        if msg.what == self.say_hi.what:
            print("Hello World!")
        else:
            BWindow.MessageReceived(self, msg)
 
    def QuitRequested(self):
        print("PyQUIT")
        return True
 
class App(BApplication):
    def __init__(self):
        BApplication.__init__(self, "application/x-python")
    def ReadyToRun(self):
        self.window = Window()
        self.window.Show()
 
def main():
    global be_app
    be_app = App()
    be_app.Run()
    print('Ran')
 
if __name__ == "__main__":
    main()

it runs, but when i close it, it stays in the deskbar, and it does not quit in the terminal.
I have to use the vulcan death grip or ^Z on it.
Do you know why?
EDIT:
^Z quits in terminal, but it stays on Deskbar.

2 Likes

Why do you create the be_app as global?

1 Like

I was calling be_app.Lock() and be_app.Quit() in QuitRequested. It didn’t help.

You probably need B_QUIT_ON_WINDOW_CLOSE in your window flags if you’re trying to quit the entire app by closing the window.

I tried that, it ‘works’, but pops up an error dialog.

Well, I can’t help if you don’t say what the error message is. This is how it’s normally done for simple apps.

It just says something like, this application has ran into an error which prevents it from continuing etc
output is:

panel BView::_InitData(): resizing mode or flags swapped
PyQUIT
Ran
Kill Thread

This dialog has an option to save a debug report, which will have more information.

Debug information for team /boot/system/bin/python3.9 (2232):
CPU(s): 1x AMD QEMU Virtual CPU version 2.5+
Memory: 3.00 GiB total, 767.11 MiB used
Haiku revision: hrev56578+87 Jul 30 2023 06:34: (x86_64)

Active Threads:
	thread 2238: team 2232 debug task 
	thread 2232: python3 (main)
		state: Debugged

		Frame		IP			Function Name
		-----------------------------------------------
		00000000	0x5f414354	? 
			Unable to retrieve disassembly for IP 0x5f414354: address not contained in any valid image.
		0x7f5b40ed5ce0	0x18574d99a76	std::default_delete<BMessage>::operator()(BMessage*) const + 0x26 
		0x7f5b40ed5d20	0x18574d79f1f	std::unique_ptr<BMessage, std::default_delete<BMessage> >::~unique_ptr() + 0x4d 
		0x7f5b40ed5d70	0x18574d6b489	_ZN8pybind116class_I8BMessageJEE7deallocERNS_6detail16value_and_holderE + 0x3a 
		0x7f5b40ed5e40	0x18574ca080c	pybind11::detail::clear_instance(_object*) + 0x12f 
		0x7f5b40ed5e70	0x18574ca08e1	pybind11_object_dealloc + 0x13 
		0x7f5b40ed5ec0	0x220ee5637f8	dict_dealloc + 0x318 
		0x7f5b40ed5f20	0x220ee5788c2	subtype_dealloc + 0x1c2 
		0x7f5b40ed5f70	0x220ee5637f8	dict_dealloc + 0x318 
		0x7f5b40ed5fd0	0x220ee5788c2	subtype_dealloc + 0x1c2 
		0x7f5b40ed6000	0x220ee5638af	free_keys_object + 0x5f 
		0x7f5b40ed6010	0x220ee5e87e4	dict_tp_clear + 0x4 
		0x7f5b40ed6190	0x220ee62bf12	collect + 0x732 
		0x7f5b40ed61b0	0x220ee62c62e	_PyGC_CollectNoFail + 0x3e 
		0x7f5b40ed6240	0x220ee61a186	_PyImport_Cleanup + 0x296 
		0x7f5b40ed6270	0x220ee621bb8	Py_FinalizeEx + 0x78 
		0x7f5b40ed6340	0x220ee62b013	Py_RunMain + 0x163 
		0x7f5b40ed6370	0x220ee62ad76	Py_BytesMain + 0x26 
		0x7f5b40ed63a0	0x11c89c0465a	_start + 0x3a 
		0x7f5b40ed63d0	0x1c55eb43ae3	runtime_loader + 0x103 
		00000000	0x7ffffdab2258	commpage_thread_exit + 0 

		Registers:
			  rip:	0x000000005f414354
			  rsp:	0x00007f5b40ed5cb8
			  rbp:	0x00007f5b40ed5cd0
			  rax:	0x0000124a3081c950
			  rbx:	0x00000119330af7c8
			  rcx:	0x00007f5b40ed5d40
			  rdx:	0x000000005f414354
			  rsi:	0x0000124a3081c950
			  rdi:	0x0000124a3081c950
			   r8:	0x00007f5b40ed5d30
			   r9:	0x0000000000000002
			  r10:	0x0000000000000002
			  r11:	0x0000000000000002
			  r12:	0x0000011582b0ef80
			  r13:	0x000001193309ef60
			  r14:	0x000001190cb7f920
			  r15:	0x0000124a307dd3a0
			   cs:	0x002b
			   ds:	0x0000
			   es:	0x0000
			   fs:	0x0000
			   gs:	0x0000
			   ss:	0x0023
			  st0:	0
			  st1:	0
			  st2:	0
			  st3:	0
			  st4:	0
			  st5:	0.99
			  st6:	9.83e+04
			  st7:	nan
			  mm0:	{0x3c, 0, 0, 0}
			  mm1:	{0x4, 0, 0, 0}
			  mm2:	{0, 0, 0, 0}
			  mm3:	{0, 0, 0, 0xc000}
			  mm4:	{0, 0, 0, 0}
			  mm5:	{0x7000, 0xa3d, 0xa3d7, 0xfd70}
			  mm6:	{0, 0, 0, 0xc000}
			  mm7:	{0, 0, 0, 0}
			 xmm0:	{0, 0, 0, 0, 0, 0, 0, 0}
			 xmm1:	{0xa670, 0xee94, 0x220, 0, 0, 0, 0, 0}
			 xmm2:	{0x60e1, 0x40ed, 0x7f5b, 0, 0x7eb2, 0x3309, 0x119, 0}
			 xmm3:	{0, 0x82b1, 0x115, 0, 0xa670, 0xee94, 0x220, 0}
			 xmm4:	{0x2031, 0x3032, 0x3332, 0x202c, 0x3231, 0x333a, 0x3a39, 0x3731}
			 xmm5:	{0x60b0, 0x40ed, 0x7f5b, 0, 0x60b0, 0x40ed, 0x7f5b, 0}
			 xmm6:	{0x60b0, 0x40ed, 0x7f5b, 0, 0x60b0, 0x40ed, 0x7f5b, 0}
			 xmm7:	{0x1, 0, 0, 0, 0x3f9, 0, 0, 0}
			 xmm8:	{0xaa, 0, 0, 0, 0, 0, 0, 0}
			 xmm9:	{0x1, 0, 0, 0, 0, 0, 0, 0}
			xmm10:	{0x4648, 0x3081, 0x124a, 0, 0x4648, 0x3081, 0x124a, 0}
			xmm11:	{0, 0, 0, 0, 0, 0, 0, 0}
			xmm12:	{0, 0, 0, 0, 0, 0, 0, 0}
			xmm13:	{0, 0, 0, 0, 0, 0, 0, 0}
			xmm14:	{0, 0, 0, 0, 0, 0, 0, 0}
			xmm15:	{0, 0, 0, 0, 0, 0, 0, 0}

Loaded Images:
	ID		Text Base	Text End	Data Base	Data End	Type	Name
	--------------------------------------------------------------------------------
	31028	0x13a0f08000	0x13a0f14000	0x13a1113000	0x13a1115000	lib    	/boot/system/lib/libicuio.so.66.1
	31034	0x14f3b6b000	0x14f3b79000	0x14f3d79000	0x14f3d7a000	lib    	/boot/system/lib/python3.9/lib-dynload/math.cpython-39.so
	31023	0x23c50c5000	0x23c52a5000	0x23c54a5000	0x23c54bb000	lib    	/boot/system/lib/libstdc++.so.6.0.29
	31021	0x2b9aea7000	0x2b9aeb0000	0x2b9b0b0000	0x2b9b0b1000	lib    	/boot/system/lib/libbsd.so
	31059	0x62d2609000	0x62d2614000	0x62d2813000	0x62d2815000	lib    	/boot/system/lib/python3.9/lib-dynload/_struct.cpython-39.so
	31031	0x73edbd9000	0x73edbdc000	0x73edddb000	0x73edddc000	lib    	/boot/system/lib/python3.9/lib-dynload/grp.cpython-39.so
	31066	0x8603a21000	0x8603c37000	0x8603e37000	0x8603e40000	lib    	/BeRepos/Haiku-PyAPI/bin/interface/InterfaceKit.so
	31063	0xdd1b3fe000	0xdd1b4bc000	0xdd1b6bc000	0xdd1b6bd000	lib    	/boot/system/lib/libzstd.so.1.5.2
	31030	0x11449f89000	0x11449f8d000	0x1144a18c000	0x1144a18d000	lib    	/boot/system/lib/python3.9/lib-dynload/_heapq.cpython-39.so
	31029	0x11933abf000	0x11933c93000	0x11933e93000	0x11933ea9000	lib    	/boot/system/lib/libicuuc.so.66.1
	31018	0x11c89c04000	0x11c89c05000	0x11c89e04000	0x11c89e05000	app    	/boot/system/bin/python3.9
	31062	0x180e5c3f000	0x180e5c55000	0x180e5e54000	0x180e5e55000	lib    	/boot/system/lib/libz.so.1.2.13
	31060	0x18574c06000	0x18574f11000	0x18575111000	0x1857511d000	lib    	/BeRepos/Haiku-PyAPI/bin/app/AppKit.so
	31065	0x1aaea122000	0x1aaea12a000	0x1aaea329000	0x1aaea32a000	add-on 	/boot/system/add-ons/locale/catalogs/plaintext
	31033	0x1b6d045c000	0x1b6d0460000	0x1b6d0660000	0x1b6d0661000	lib    	/boot/system/lib/python3.9/lib-dynload/select.cpython-39.so
	31022	0x1b761fee000	0x1b762101000	0x1b762300000	0x1b762353000	lib    	/boot/system/lib/libroot.so
	31061	0x1b8ce1dc000	0x1b8ce50b000	0x1b8ce70a000	0x1b8ce738000	lib    	/boot/system/lib/libbe.so
	31024	0x1c36620b000	0x1c366221000	0x1c366421000	0x1c366422000	lib    	/boot/system/lib/libgcc_s.so.1
	31017	0x1c55eb34000	0x1c55eb51000	0x1c55ed51000	0x1c55ed52000	lib    	/boot/system/runtime_loader
	31032	0x1d3da4f4000	0x1d3da4f8000	0x1d3da6f7000	0x1d3da6f8000	lib    	/boot/system/lib/python3.9/lib-dynload/_posixsubprocess.cpython-39.so
	31027	0x1d7041d0000	0x1d7044c7000	0x1d7046c6000	0x1d7046df000	lib    	/boot/system/lib/libicui18n.so.66.1
	31026	0x1e30369b000	0x1e30369c000	0x1e30389b000	0x1e30389c000	lib    	/boot/system/lib/libicudata.so.66.1
	31025	0x1edef049000	0x1edef05b000	0x1edef25b000	0x1edef25c000	lib    	/boot/system/lib/libroot-addon-icu.so
	31020	0x2063deec000	0x2063df2d000	0x2063e12c000	0x2063e135000	lib    	/boot/system/lib/libnetwork.so
	31019	0x220ee40c000	0x220ee72e000	0x220ee92e000	0x220ee98e000	lib    	/boot/system/lib/libpython3.9.so.1.0
	31016	0x7ffffdab2000	0x7ffffdaba000	0x00000000	0x00000000	system 	commpage

Areas:
	ID		Base		End			Size (KiB)	Protection	Locking			Name
	--------------------------------------------------------------------------------
	120394	0x60000000	0x60001000	         4	rw-cS      	none          	server_memory
	120396	0x68000000	0x68020000	       128	rw-cS      	none          	server_memory
	120266	0x13a0f08000	0x13a0f14000	        48	r-x        	none          	libicuio.so.66.1_seg0ro
	120267	0x13a1113000	0x13a1115000	         8	rw-        	none          	libicuio.so.66.1_seg1rw
	120291	0x14f3b6b000	0x14f3b79000	        56	r-x        	none          	math.cpython-39.so_seg0ro
	120292	0x14f3d79000	0x14f3d7a000	         4	rw-        	none          	math.cpython-39.so_seg1rw
	120252	0x23c50c5000	0x23c52a5000	      1920	r-x        	none          	libstdc++.so.6.0.29_seg0ro
	120253	0x23c54a5000	0x23c54b3000	        56	rw-        	none          	libstdc++.so.6.0.29_seg1rw
	120254	0x23c54b3000	0x23c54bb000	        32	rw-        	none          	libstdc++.so.6.0.29_seg2rw
	120247	0x2b9aea7000	0x2b9aeb0000	        36	r-x        	none          	libbsd.so_seg0ro
	120248	0x2b9b0b0000	0x2b9b0b1000	         4	rw-        	none          	libbsd.so_seg1rw
	120237	0x3749d67000	0x3749d77000	        64	rw-        	none          	rld heap
	120370	0x62d2609000	0x62d2614000	        44	r-x        	none          	_struct.cpython-39.so_seg0ro
	120371	0x62d2813000	0x62d2815000	         8	rw-        	none          	_struct.cpython-39.so_seg1rw
	120285	0x73edbd9000	0x73edbdc000	        12	r-x        	none          	grp.cpython-39.so_seg0ro
	120286	0x73edddb000	0x73edddc000	         4	rw-        	none          	grp.cpython-39.so_seg1rw
	120238	0x7af74ac000	0x7af74ad000	         4	rw-cS      	none          	_rld_debug_
	120386	0x8603a21000	0x8603c37000	      2136	r-x        	none          	InterfaceKit.so_seg0ro
	120387	0x8603e37000	0x8603e3f000	        32	rw-        	none          	InterfaceKit.so_seg1rw
	120388	0x8603e3f000	0x8603e40000	         4	rw-        	none          	InterfaceKit.so_seg2rw
	120257	0x866fee7000	0x866fef7000	        64	rw-        	none          	rld heap
	120271	0xd1273ee000	0xd127406000	        96	rw-        	none          	rld heap
	120379	0xdd1b3fe000	0xdd1b4bc000	       760	r-x        	none          	libzstd.so.1.5.2_seg0ro
	120380	0xdd1b6bc000	0xdd1b6bd000	         4	rw-        	none          	libzstd.so.1.5.2_seg1rw
	120272	0xecb99bf000	0xecb99d7000	        96	rw-        	none          	rld heap
	120273	0x108d9b48000	0x108db603000	     27372	r--S       	none          	libicuuc.so.66 mmap area
	120274	0x1107d9f3000	0x1107da33000	       256	rw-        	none          	libpython3.9.so.1.0 mmap area
	120275	0x1138018c000	0x113801cc000	       256	rw-        	none          	libpython3.9.so.1.0 mmap area
	120276	0x113ee21c000	0x113ee25c000	       256	rw-        	none          	libpython3.9.so.1.0 mmap area
	120282	0x11449f89000	0x11449f8d000	        16	r-x        	none          	_heapq.cpython-39.so_seg0ro
	120283	0x1144a18c000	0x1144a18d000	         4	rw-        	none          	_heapq.cpython-39.so_seg1rw
	120277	0x11582ae4000	0x11582b24000	       256	rw-        	none          	libpython3.9.so.1.0 mmap area
	120278	0x1184e77d000	0x1184e7bd000	       256	rw-        	none          	libpython3.9.so.1.0 mmap area
	120279	0x1190cb7c000	0x1190cbbc000	       256	rw-        	none          	libpython3.9.so.1.0 mmap area
	120280	0x11919803000	0x11919843000	       256	rw-        	none          	libpython3.9.so.1.0 mmap area
	120281	0x1192ddf4000	0x1192de34000	       256	rw-        	none          	libpython3.9.so.1.0 mmap area
	120284	0x11933076000	0x119330b6000	       256	rw-        	none          	libpython3.9.so.1.0 mmap area
	120385	0x11933a76000	0x11933ab6000	       256	rw-        	none          	libpython3.9.so.1.0 mmap area
	120268	0x11933abf000	0x11933c93000	      1872	r-x        	none          	libicuuc.so.66.1_seg0ro
	120269	0x11933e93000	0x11933ea8000	        84	rw-        	none          	libicuuc.so.66.1_seg1rw
	120270	0x11933ea8000	0x11933ea9000	         4	rw-        	none          	libicuuc.so.66.1_seg2rw
	120389	0x11a53a73000	0x11a53ab3000	       256	rw-        	none          	libpython3.9.so.1.0 mmap area
	120239	0x11c89c04000	0x11c89c05000	         4	r-x        	none          	python3.9_seg0ro
	120240	0x11c89e04000	0x11c89e05000	         4	rw-        	none          	python3.9_seg1rw
	120377	0x180e5c3f000	0x180e5c55000	        88	r-x        	none          	libz.so.1.2.13_seg0ro
	120378	0x180e5e54000	0x180e5e55000	         4	rw-        	none          	libz.so.1.2.13_seg1rw
	120372	0x18574c06000	0x18574f11000	      3116	r-x        	none          	AppKit.so_seg0ro
	120373	0x18575111000	0x1857511c000	        44	rw-        	none          	AppKit.so_seg1rw
	120374	0x1857511c000	0x1857511d000	         4	rw-        	none          	AppKit.so_seg2rw
	120383	0x1aaea122000	0x1aaea12a000	        32	r-x        	none          	plaintext_seg0ro
	120384	0x1aaea329000	0x1aaea32a000	         4	rw-        	none          	plaintext_seg1rw
	120289	0x1b6d045c000	0x1b6d0460000	        16	r-x        	none          	select.cpython-39.so_seg0ro
	120290	0x1b6d0660000	0x1b6d0661000	         4	rw-        	none          	select.cpython-39.so_seg1rw
	120249	0x1b761fee000	0x1b762101000	      1100	r-x        	none          	libroot.so_seg0ro
	120250	0x1b762300000	0x1b76230e000	        56	rw-        	none          	libroot.so_seg1rw
	120251	0x1b76230e000	0x1b762353000	       276	rw-        	none          	libroot.so_seg2rw
	120375	0x1b8ce1dc000	0x1b8ce50b000	      3260	r-x        	none          	libbe.so_seg0ro
	120376	0x1b8ce70a000	0x1b8ce738000	       184	rw-        	none          	libbe.so_seg1rw
	120255	0x1c36620b000	0x1c366221000	        88	r-x        	none          	libgcc_s.so.1_seg0ro
	120256	0x1c366421000	0x1c366422000	         4	rw-        	none          	libgcc_s.so.1_seg1rw
	120235	0x1c55eb34000	0x1c55eb51000	       116	r-x        	none          	runtime_loader_seg0ro
	120236	0x1c55ed51000	0x1c55ed52000	         4	rw-        	none          	runtime_loader_seg1rw
	120287	0x1d3da4f4000	0x1d3da4f8000	        16	r-x        	none          	_posixsubprocess.cpython-39.so_
	120288	0x1d3da6f7000	0x1d3da6f8000	         4	rw-        	none          	_posixsubprocess.cpython-39.so_
	120263	0x1d7041d0000	0x1d7044c7000	      3036	r-x        	none          	libicui18n.so.66.1_seg0ro
	120264	0x1d7046c6000	0x1d7046de000	        96	rw-        	none          	libicui18n.so.66.1_seg1rw
	120265	0x1d7046de000	0x1d7046df000	         4	rw-        	none          	libicui18n.so.66.1_seg2rw
	120261	0x1e30369b000	0x1e30369c000	         4	r-x        	none          	libicudata.so.66.1_seg0ro
	120262	0x1e30389b000	0x1e30389c000	         4	rw-        	none          	libicudata.so.66.1_seg1rw
	120259	0x1edef049000	0x1edef05b000	        72	r-x        	none          	libroot-addon-icu.so_seg0ro
	120260	0x1edef25b000	0x1edef25c000	         4	rw-        	none          	libroot-addon-icu.so_seg1rw
	120244	0x2063deec000	0x2063df2d000	       260	r-x        	none          	libnetwork.so_seg0ro
	120245	0x2063e12c000	0x2063e130000	        16	rw-        	none          	libnetwork.so_seg1rw
	120246	0x2063e130000	0x2063e135000	        20	rw-        	none          	libnetwork.so_seg2rw
	120241	0x220ee40c000	0x220ee72e000	      3208	r-x        	none          	libpython3.9.so.1.0_seg0ro
	120242	0x220ee92e000	0x220ee96c000	       248	rw-        	none          	libpython3.9.so.1.0_seg1rw
	120243	0x220ee96c000	0x220ee98e000	       136	rw-        	none          	libpython3.9.so.1.0_seg2rw
	120258	0x124a307c1000	0x124a30aa1000	      2944	rw-        	none          	heap
	120233	0x7f5b3fed3000	0x7f5b40ed9000	     16408	rw-s       	none          	python3_2232_stack
	120232	0x7fd7b3dcb000	0x7fd7b3dcf000	        16	rw-k       	full          	user area
	120234	0x7ffffdab2000	0x7ffffdaba000	        32	r-xSk      	full          	commpage

Protection Flags: r - read, w - write, x - execute, s - stack, o - overcommit, c - cloneable, S - shared, k - kernel

Semaphores:
	ID		Count	Last Holder	Name
	------------------------------------------------------------
	1468341	    0	       2232	BLooperList lock
	1468349	    0	       1574	Catalog
	1468355	    0	       1574	LocaleRosterData
	1468357	    0	       1572	some BLocker
	1468358	    0	       1574	some BBlockCache lock
	1468359	    0	       1572	some BLocker
	1468361	    0	       1574	BMessageQueue Lock
	1468362	    0	       1572	AppServerLink_sLock
	1468364	    0	       1572	token space
	1468366	    0	       1574	AppLooperPort
	1468369	    0	       1572	width buffer
	1468371	    0	       1572	some BLocker
	1468382	    0	       1572	clipboard
	1468389	    0	       1572	screen list
	1468411	    0	       1572	tool tip manager

It seems your code is holding a BMessage inside an unique_ptr. What was this message used for? Quite often, the messages will be deleted for you, for example:

  • Messages received in MessageReceived: the application kit takes care of deleting them
  • Messages you add to a BControl or BInvoker: the object takes ownership of the message

So, you may easily end up with a double delete here.

I don’t know if pybind allows enough control on allocations to manage this somewhat automatically.

Message.cpp

Oh. Ownership mapping is the hardest part of language binding sometime GC helps, sometime not.

Often threre is some type of convention (e.g. child windows automatically freed by parent), but marking large API surface correctly is labor.

1 Like

I changed it to:

py::class_<BMessage,std::unique_ptr<BMessage, py::nodelete>>(m, "BMessage")

and it has a different error.

Debug information for team /boot/system/bin/python3.9 (1072):
CPU(s): 1x AMD QEMU Virtual CPU version 2.5+
Memory: 3.00 GiB total, 569.41 MiB used
Haiku revision: hrev56578+87 Jul 30 2023 06:34: (x86_64)

Active Threads:
	thread 1079: team 1072 debug task 
	thread 1072: python3 (main)
		state: Call (getNumAvailable() < getNumBlocks())

		Frame		IP			Function Name
		-----------------------------------------------
		00000000	0x4a01f8f097	_kern_debugger + 0x7 
			Disassembly:
				_kern_debugger:
				0x0000004a01f8f090:   48c7c0e5000000  mov $0xe5, %rax
				0x0000004a01f8f097:             0f05  syscall  <--

		0x7f8434d04a20	0x4a01f974e1	__assert_fail + 0x61 
		0x7f8434d04a70	0x4a0201953d	BPrivate::hoardHeap::freeBlock(BPrivate::block*&, BPrivate::superblock*&, int, BPrivate::processHeap*) + 0x52d 
		0x7f8434d04ab0	0x4a0201992c	BPrivate::processHeap::free(void*) + 0xfc 
		0x7f8434d04ae0	0x4a0201ab54	free + 0x44 
		0x7f8434d04b60	0x16d9c30eb0b	pybind11::cpp_function::destruct(pybind11::detail::function_record*, bool) + 0x1e8 
		0x7f8434d04b80	0x16d9c30ce14	_ZZN8pybind1112cpp_function18initialize_genericEOSt10unique_ptrINS_6detail15function_recordENS0_33InitializingFunctionRecordDeleterEEPKcPKPKSt9type_infomENKUlPvE_clESE_ + 0x1c 
		0x7f8434d04ba0	0x16d9c30ce34	_ZZN8pybind1112cpp_function18initialize_genericEOSt10unique_ptrINS_6detail15function_recordENS0_33InitializingFunctionRecordDeleterEEPKcPKPKSt9type_infomENUlPvE_4_FUNESE_ + 0x18 
		0x7f8434d04bd0	0x16d9c30809a	_ZZN8pybind117capsuleC4EPKvPFvPvEENKUlP7_objectE_clES7_ + 0x40 
		0x7f8434d04bf0	0x16d9c3080b7	_ZZN8pybind117capsuleC4EPKvPFvPvEENUlP7_objectE_4_FUNES7_ + 0x18 
		0x7f8434d04c10	0x1b90de68e21	capsule_dealloc.cold + 0xc 
		0x7f8434d04c30	0x1b90df46c08	meth_dealloc + 0x98 
		0x7f8434d04c50	0x1b90de69849	instancemethod_dealloc + 0x3d 
		0x7f8434d04c80	0x1b90df428af	free_keys_object + 0x5f 
		0x7f8434d04ca0	0x1b90df59109	type_clear + 0x39 
		0x7f8434d04e20	0x1b90e00af12	collect + 0x732 
		0x7f8434d04e40	0x1b90e00b62e	_PyGC_CollectNoFail + 0x3e 
		0x7f8434d04e70	0x1b90e000bb8	Py_FinalizeEx + 0x78 
		0x7f8434d04f40	0x1b90e00a013	Py_RunMain + 0x163 
		0x7f8434d04f70	0x1b90e009d76	Py_BytesMain + 0x26 
		0x7f8434d04fa0	0xffc004e65a	_start + 0x3a 
		0x7f8434d04fd0	0x24cc50c9ae3	runtime_loader + 0x103 
		00000000	0x7ffff655a258	commpage_thread_exit + 0 

		Registers:
			  rip:	0x0000004a01f8f099
			  rsp:	0x00007f8434d049d8
			  rbp:	0x00007f8434d04a10
			  rax:	0x00000000000000e5
			  rbx:	0x00007f8434d04a78
			  rcx:	0x0000004a01f8f099
			  rdx:	0x00007f8434d044f3
			  rsi:	0x00007f8434d044f3
			  rdi:	0x0000004a020461d8
			   r8:	0x0000000000000430
			   r9:	0x00007f8434d04440
			  r10:	0x0000000000000000
			  r11:	0x0000000000000206
			  r12:	0x0000004a020461d8
			  r13:	0x000000000000000f
			  r14:	0x000010e36f7839a8
			  r15:	0x000000000000000f
			   cs:	0x002b
			   ds:	0x0000
			   es:	0x0000
			   fs:	0x0000
			   gs:	0x0000
			   ss:	0x0023
			  st0:	0
			  st1:	0
			  st2:	0
			  st3:	0
			  st4:	0
			  st5:	0
			  st6:	0
			  st7:	0
			  mm0:	{0, 0, 0, 0}
			  mm1:	{0, 0, 0, 0}
			  mm2:	{0, 0, 0, 0}
			  mm3:	{0, 0, 0, 0}
			  mm4:	{0, 0, 0, 0}
			  mm5:	{0, 0, 0, 0}
			  mm6:	{0, 0, 0, 0}
			  mm7:	{0, 0, 0, 0}
			 xmm0:	{0, 0, 0, 0, 0, 0, 0, 0}
			 xmm1:	{0, 0, 0, 0, 0, 0, 0, 0}
			 xmm2:	{0, 0, 0, 0, 0, 0, 0, 0}
			 xmm3:	{0, 0, 0, 0, 0, 0, 0, 0}
			 xmm4:	{0, 0, 0, 0, 0, 0, 0, 0}
			 xmm5:	{0, 0, 0, 0, 0, 0, 0, 0}
			 xmm6:	{0, 0, 0, 0, 0, 0, 0, 0}
			 xmm7:	{0, 0, 0, 0, 0, 0, 0, 0}
			 xmm8:	{0, 0, 0, 0, 0, 0, 0, 0}
			 xmm9:	{0, 0, 0, 0, 0, 0, 0, 0}
			xmm10:	{0, 0, 0, 0, 0, 0, 0, 0}
			xmm11:	{0, 0, 0, 0, 0, 0, 0, 0}
			xmm12:	{0, 0, 0, 0, 0, 0, 0, 0}
			xmm13:	{0, 0, 0, 0, 0, 0, 0, 0}
			xmm14:	{0, 0, 0, 0, 0, 0, 0, 0}
			xmm15:	{0, 0, 0, 0, 0, 0, 0, 0}

Loaded Images:
	ID		Text Base	Text End	Data Base	Data End	Type	Name
	--------------------------------------------------------------------------------
	8735	0x45c3552000	0x45c3568000	0x45c3768000	0x45c3769000	lib    	/boot/system/lib/libgcc_s.so.1
	8742	0x470f4b7000	0x470f4ba000	0x470f6b9000	0x470f6ba000	lib    	/boot/system/lib/python3.9/lib-dynload/grp.cpython-39.so
	8733	0x4a01f4f000	0x4a02062000	0x4a02261000	0x4a022b4000	lib    	/boot/system/lib/libroot.so
	8773	0x5ed218e000	0x5ed21a4000	0x5ed23a3000	0x5ed23a4000	lib    	/boot/system/lib/libz.so.1.2.13
	8740	0x6040c66000	0x6040e3a000	0x604103a000	0x6041050000	lib    	/boot/system/lib/libicuuc.so.66.1
	8736	0x641bfd3000	0x641bfe5000	0x641c1e5000	0x641c1e6000	lib    	/boot/system/lib/libroot-addon-icu.so
	8745	0x69f1013000	0x69f1021000	0x69f1221000	0x69f1222000	lib    	/boot/system/lib/python3.9/lib-dynload/math.cpython-39.so
	8739	0x6b0c7c2000	0x6b0c7ce000	0x6b0c9cd000	0x6b0c9cf000	lib    	/boot/system/lib/libicuio.so.66.1
	8744	0x7890722000	0x7890726000	0x7890926000	0x7890927000	lib    	/boot/system/lib/python3.9/lib-dynload/select.cpython-39.so
	8776	0x84483fa000	0x8448402000	0x8448601000	0x8448602000	add-on 	/boot/system/add-ons/locale/catalogs/plaintext
	8731	0x85eb8ef000	0x85eb930000	0x85ebb2f000	0x85ebb38000	lib    	/boot/system/lib/libnetwork.so
	8741	0xc6e3b3c000	0xc6e3b40000	0xc6e3d3f000	0xc6e3d40000	lib    	/boot/system/lib/python3.9/lib-dynload/_heapq.cpython-39.so
	8734	0xc7e11a0000	0xc7e1380000	0xc7e1580000	0xc7e1596000	lib    	/boot/system/lib/libstdc++.so.6.0.29
	8737	0xf013ad0000	0xf013ad1000	0xf013cd0000	0xf013cd1000	lib    	/boot/system/lib/libicudata.so.66.1
	8729	0xffc004e000	0xffc004f000	0xffc024e000	0xffc024f000	app    	/boot/system/bin/python3.9
	8743	0x13cafc48000	0x13cafc4c000	0x13cafe4b000	0x13cafe4c000	lib    	/boot/system/lib/python3.9/lib-dynload/_posixsubprocess.cpython-39.so
	8772	0x140445e9000	0x14044918000	0x14044b17000	0x14044b45000	lib    	/boot/system/lib/libbe.so
	8738	0x14a7f815000	0x14a7fb0c000	0x14a7fd0b000	0x14a7fd24000	lib    	/boot/system/lib/libicui18n.so.66.1
	8777	0x16d9c2a2000	0x16d9c4b8000	0x16d9c6b8000	0x16d9c6c1000	lib    	/BeRepos/Haiku-PyAPI/bin/interface/InterfaceKit.so
	8732	0x17fd41b9000	0x17fd41c2000	0x17fd43c2000	0x17fd43c3000	lib    	/boot/system/lib/libbsd.so
	8774	0x1aa56fa0000	0x1aa5705e000	0x1aa5725e000	0x1aa5725f000	lib    	/boot/system/lib/libzstd.so.1.5.2
	8730	0x1b90ddeb000	0x1b90e10d000	0x1b90e30d000	0x1b90e36d000	lib    	/boot/system/lib/libpython3.9.so.1.0
	8771	0x1eddbc25000	0x1eddbf2f000	0x1eddc12e000	0x1eddc13a000	lib    	/BeRepos/Haiku-PyAPI/bin/app/AppKit.so
	8770	0x233911cb000	0x233911d6000	0x233913d5000	0x233913d7000	lib    	/boot/system/lib/python3.9/lib-dynload/_struct.cpython-39.so
	8728	0x24cc50ba000	0x24cc50d7000	0x24cc52d7000	0x24cc52d8000	lib    	/boot/system/runtime_loader
	8727	0x7ffff655a000	0x7ffff6562000	0x00000000	0x00000000	system 	commpage

Areas:
	ID		Base		End			Size (KiB)	Protection	Locking			Name
	--------------------------------------------------------------------------------
	29919	0x45c3552000	0x45c3568000	        88	r-x        	none          	libgcc_s.so.1_seg0ro
	29920	0x45c3768000	0x45c3769000	         4	rw-        	none          	libgcc_s.so.1_seg1rw
	29949	0x470f4b7000	0x470f4ba000	        12	r-x        	none          	grp.cpython-39.so_seg0ro
	29950	0x470f6b9000	0x470f6ba000	         4	rw-        	none          	grp.cpython-39.so_seg1rw
	29913	0x4a01f4f000	0x4a02062000	      1100	r-x        	none          	libroot.so_seg0ro
	29914	0x4a02261000	0x4a0226f000	        56	rw-        	none          	libroot.so_seg1rw
	29915	0x4a0226f000	0x4a022b4000	       276	rw-        	none          	libroot.so_seg2rw
	30041	0x5ed218e000	0x5ed21a4000	        88	r-x        	none          	libz.so.1.2.13_seg0ro
	30042	0x5ed23a3000	0x5ed23a4000	         4	rw-        	none          	libz.so.1.2.13_seg1rw
	29932	0x6040c66000	0x6040e3a000	      1872	r-x        	none          	libicuuc.so.66.1_seg0ro
	29933	0x604103a000	0x604104f000	        84	rw-        	none          	libicuuc.so.66.1_seg1rw
	29934	0x604104f000	0x6041050000	         4	rw-        	none          	libicuuc.so.66.1_seg2rw
	29923	0x641bfd3000	0x641bfe5000	        72	r-x        	none          	libroot-addon-icu.so_seg0ro
	29924	0x641c1e5000	0x641c1e6000	         4	rw-        	none          	libroot-addon-icu.so_seg1rw
	29901	0x64675f6000	0x6467606000	        64	rw-        	none          	rld heap
	29955	0x69f1013000	0x69f1021000	        56	r-x        	none          	math.cpython-39.so_seg0ro
	29956	0x69f1221000	0x69f1222000	         4	rw-        	none          	math.cpython-39.so_seg1rw
	29930	0x6b0c7c2000	0x6b0c7ce000	        48	r-x        	none          	libicuio.so.66.1_seg0ro
	29931	0x6b0c9cd000	0x6b0c9cf000	         8	rw-        	none          	libicuio.so.66.1_seg1rw
	29953	0x7890722000	0x7890726000	        16	r-x        	none          	select.cpython-39.so_seg0ro
	29954	0x7890926000	0x7890927000	         4	rw-        	none          	select.cpython-39.so_seg1rw
	30047	0x84483fa000	0x8448402000	        32	r-x        	none          	plaintext_seg0ro
	30048	0x8448601000	0x8448602000	         4	rw-        	none          	plaintext_seg1rw
	29908	0x85eb8ef000	0x85eb930000	       260	r-x        	none          	libnetwork.so_seg0ro
	29909	0x85ebb2f000	0x85ebb33000	        16	rw-        	none          	libnetwork.so_seg1rw
	29910	0x85ebb33000	0x85ebb38000	        20	rw-        	none          	libnetwork.so_seg2rw
	29902	0xaf43aec000	0xaf43aed000	         4	rw-cS      	none          	_rld_debug_
	29921	0xb1b3a21000	0xb1b3a31000	        64	rw-        	none          	rld heap
	29946	0xc6e3b3c000	0xc6e3b40000	        16	r-x        	none          	_heapq.cpython-39.so_seg0ro
	29947	0xc6e3d3f000	0xc6e3d40000	         4	rw-        	none          	_heapq.cpython-39.so_seg1rw
	29935	0xc6f0158000	0xc6f0170000	        96	rw-        	none          	rld heap
	29936	0xc730212000	0xc73022a000	        96	rw-        	none          	rld heap
	29937	0xc7d20c1000	0xc7d3b7c000	     27372	r--S       	none          	libicuuc.so.66 mmap area
	29938	0xc7d72b1000	0xc7d72f1000	       256	rw-        	none          	libpython3.9.so.1.0 mmap area
	29939	0xc7dd21c000	0xc7dd25c000	       256	rw-        	none          	libpython3.9.so.1.0 mmap area
	29940	0xc7df0af000	0xc7df0ef000	       256	rw-        	none          	libpython3.9.so.1.0 mmap area
	29941	0xc7dfb45000	0xc7dfb85000	       256	rw-        	none          	libpython3.9.so.1.0 mmap area
	29942	0xc7e0db7000	0xc7e0df7000	       256	rw-        	none          	libpython3.9.so.1.0 mmap area
	29943	0xc7e1081000	0xc7e10c1000	       256	rw-        	none          	libpython3.9.so.1.0 mmap area
	29944	0xc7e113c000	0xc7e117c000	       256	rw-        	none          	libpython3.9.so.1.0 mmap area
	29916	0xc7e11a0000	0xc7e1380000	      1920	r-x        	none          	libstdc++.so.6.0.29_seg0ro
	29917	0xc7e1580000	0xc7e158e000	        56	rw-        	none          	libstdc++.so.6.0.29_seg1rw
	29918	0xc7e158e000	0xc7e1596000	        32	rw-        	none          	libstdc++.so.6.0.29_seg2rw
	29945	0xe196b63000	0xe196ba3000	       256	rw-        	none          	libpython3.9.so.1.0 mmap area
	29948	0xe6df63b000	0xe6df67b000	       256	rw-        	none          	libpython3.9.so.1.0 mmap area
	30049	0xe856fe0000	0xe857020000	       256	rw-        	none          	libpython3.9.so.1.0 mmap area
	30053	0xee7972e000	0xee7976e000	       256	rw-        	none          	libpython3.9.so.1.0 mmap area
	29925	0xf013ad0000	0xf013ad1000	         4	r-x        	none          	libicudata.so.66.1_seg0ro
	29926	0xf013cd0000	0xf013cd1000	         4	rw-        	none          	libicudata.so.66.1_seg1rw
	29903	0xffc004e000	0xffc004f000	         4	r-x        	none          	python3.9_seg0ro
	29904	0xffc024e000	0xffc024f000	         4	rw-        	none          	python3.9_seg1rw
	29951	0x13cafc48000	0x13cafc4c000	        16	r-x        	none          	_posixsubprocess.cpython-39.so_
	29952	0x13cafe4b000	0x13cafe4c000	         4	rw-        	none          	_posixsubprocess.cpython-39.so_
	30039	0x140445e9000	0x14044918000	      3260	r-x        	none          	libbe.so_seg0ro
	30040	0x14044b17000	0x14044b45000	       184	rw-        	none          	libbe.so_seg1rw
	29927	0x14a7f815000	0x14a7fb0c000	      3036	r-x        	none          	libicui18n.so.66.1_seg0ro
	29928	0x14a7fd0b000	0x14a7fd23000	        96	rw-        	none          	libicui18n.so.66.1_seg1rw
	29929	0x14a7fd23000	0x14a7fd24000	         4	rw-        	none          	libicui18n.so.66.1_seg2rw
	30050	0x16d9c2a2000	0x16d9c4b8000	      2136	r-x        	none          	InterfaceKit.so_seg0ro
	30051	0x16d9c6b8000	0x16d9c6c0000	        32	rw-        	none          	InterfaceKit.so_seg1rw
	30052	0x16d9c6c0000	0x16d9c6c1000	         4	rw-        	none          	InterfaceKit.so_seg2rw
	29911	0x17fd41b9000	0x17fd41c2000	        36	r-x        	none          	libbsd.so_seg0ro
	29912	0x17fd43c2000	0x17fd43c3000	         4	rw-        	none          	libbsd.so_seg1rw
	30043	0x1aa56fa0000	0x1aa5705e000	       760	r-x        	none          	libzstd.so.1.5.2_seg0ro
	30044	0x1aa5725e000	0x1aa5725f000	         4	rw-        	none          	libzstd.so.1.5.2_seg1rw
	29905	0x1b90ddeb000	0x1b90e10d000	      3208	r-x        	none          	libpython3.9.so.1.0_seg0ro
	29906	0x1b90e30d000	0x1b90e34b000	       248	rw-        	none          	libpython3.9.so.1.0_seg1rw
	29907	0x1b90e34b000	0x1b90e36d000	       136	rw-        	none          	libpython3.9.so.1.0_seg2rw
	30036	0x1eddbc25000	0x1eddbf2f000	      3112	r-x        	none          	AppKit.so_seg0ro
	30037	0x1eddc12e000	0x1eddc139000	        44	rw-        	none          	AppKit.so_seg1rw
	30038	0x1eddc139000	0x1eddc13a000	         4	rw-        	none          	AppKit.so_seg2rw
	30034	0x233911cb000	0x233911d6000	        44	r-x        	none          	_struct.cpython-39.so_seg0ro
	30035	0x233913d5000	0x233913d7000	         8	rw-        	none          	_struct.cpython-39.so_seg1rw
	29899	0x24cc50ba000	0x24cc50d7000	       116	r-x        	none          	runtime_loader_seg0ro
	29900	0x24cc52d7000	0x24cc52d8000	         4	rw-        	none          	runtime_loader_seg1rw
	29922	0x10e36f781000	0x10e36fa41000	      2816	rw-        	none          	heap
	29897	0x7f8433d01000	0x7f8434d07000	     16408	rw-s       	none          	python3_1072_stack
	29894	0x7fff967ab000	0x7fff967af000	        16	rw-k       	full          	user area
	29898	0x7ffff655a000	0x7ffff6562000	        32	r-xSk      	full          	commpage

Protection Flags: r - read, w - write, x - execute, s - stack, o - overcommit, c - cloneable, S - shared, k - kernel

Semaphores:
	ID		Count	Last Holder	Name
	------------------------------------------------------------
	69412	    0	        750	some BBlockCache lock
	69415	    0	        750	token space
	69416	    0	       1072	BLooperList lock
	69417	    0	        752	Catalog
	69418	    0	        750	AppServerLink_sLock
	69419	    0	        750	some BLocker
	69420	    0	        750	some BLocker
	69421	    0	        750	some BLocker
	69422	    0	        752	LocaleRosterData
	69443	    0	        750	screen list
	69444	    0	        750	clipboard
	69447	    0	        752	width buffer

You have a heap corruption. To debug these it may be easier to run your application with libroot_debug

See this article explaining it: Using malloc_debug to Find Memory Related Bugs | Haiku Project