I ran into a wall with my add on development. (I am still a beginner with python and programming and add on development, so please be lenient).
I am running a modal operator to do some changes on the selected object (via raycast i get the face index under mouse cursor and on mouse click the mesh content gets deleted and new content, depending on the face index, will be generated).
Sometimes this works, sometimes it segfaults.
It segfaults more often when in texture display mode, less often in material display mode and even less often in solid display mode.
The crash happens after the new mesh content is created but before the modal operator checks for new events. (In the script itself nothing should happen inbetween).
So i used pdb.set_trace() to set a breakpoint right after the content creation and step through everything that happens after that. There is actually a lot of stuff going on (mostly (re)drawing the Ui afais ... it takes ages to step through everything).
Sadly it never crashes when stepping through it so i still do not know when (and why) exactly the crash happens and now i am lost, having no idea how to find the error.
I striped down the code a bit. As it is still quite big and a certain material is needed, so, here a blend file:
To produce the Error open the file (tested with Blender 2.79 and 2.79a) run the script, find the VA tab in the tool shelf, click the button in it and then click on the object. At least for me it sometimes works (The Part of the mesh under the cursor vanishes) but mostly it segfaults.
I startet Blender with
--debug until now but stumbled across
--debug-all. It gives a bit more information on what is going on and i might have found the culprit: Before the
EXCEPTION_ACCESS_VIOLATION there was no clue with only
--debug, but now with
--debug-all right before the crash it says:
WM_operator_last_properties_init: loading previous properties for 'VIEW3D_OT_select'
I am not 100% sure what it means but since i use left mouseclick in the modal operator as event to call the function that changes the mesh (delete all geometry and puts new in) and also to select objects in the scene there seems to be clash of those two maybe. At least when i use a keyboard key to call the function it does not crash (hopefully it remains like this).
Now i have to look if i can find a way to overwrite the mouse click selection while modal is running (prefered... if i cannot find it out on my own i might do a new question) or if i need to use keyboard instead. So this is now at least half solved.