Home

ValueError in bpy_struct.callback_add() crashes Blender
Closed, InvalidPublic

Description
See the attached file (run the script and call the 'Crash' opertaor).
But basically passing the wrong value for callback_add() is crashing Blender.

e.g. context.region.callback_add(draw_callback_px, (self, context), 'BUGBUGBUGBUG')
ValueError: bpy_struct.callback_add(): 'BUGBUGBUGBUG' not found in ('POST_PIXEL', 'POST_VIEW', 'PRE_VIEW')

###################
Program received signal SIGSEGV, Segmentation fault.
0x00000000012c74f0 in wm_event_modalkeymap (C=0x3be8a18, op=0x58610a0,
event=0x5665b68)
at /home/dfelinto/blender/bf/source/blender/windowmanager/intern/wm_event_system.c:1331
1331 if (op->type->modalkeymap) {

#0 0x00000000012c74f0 in wm_event_modalkeymap (C=0x3be8a18, op=0x58610a0,
event=0x5665b68)
at /home/dfelinto/blender/bf/source/blender/windowmanager/intern/wm_event_system.c:1331
#1 0x00000000012c7642 in wm_handler_operator_call (C=0x3be8a18,
handlers=0x58698a8, handler=0x56a7da8, event=0x5665b68, properties=0x0)
at /home/dfelinto/blender/bf/source/blender/windowmanager/intern/wm_event_system.c:1364
#2 0x00000000012c826c in wm_handlers_do (C=0x3be8a18, event=0x5665b68,
handlers=0x58698a8)
at /home/dfelinto/blender/bf/source/blender/windowmanager/intern/wm_event_system.c:1723
#3 0x00000000012c8de2 in wm_event_do_handlers (C=0x3be8a18)
at /home/dfelinto/blender/bf/source/blender/windowmanager/intern/wm_event_system.c:1983
#4 0x00000000012c2312 in WM_main (C=0x3be8a18)
at /home/dfelinto/blender/bf/source/blender/windowmanager/intern/wm.c:366
#5 0x00000000012c18a0 in main (argc=1, argv=0x7fffffffe1e8)
at /home/dfelinto/blender/bf/source/creator/creator.c:1319
###################

Blender svn (> 2.62) linux
sergey (Sergey Sharybin) added a comment.Via Old WorldMar 26 2012, 6:58 PM
You're using API in a wrong way: last argument of callback_add is supposed to be in ('POST_PIXEL', 'POST_VIEW', 'PRE_VIEW'). Your code throws an exception here which ends up partially initialized modal operator which confuses operator system at all.
Campbell, can you check if it can be easily fixed? But personally do't actually consider this is a bug, so if it'll lead to some hackinsh ways to support nicer behavior here prefer not to change this.
dfelinto (Dalai Felinto) added a comment.Via Old WorldApr 20 2012, 7:42 PM
I know the last argument is supposed to be one of them. But segfault is always a bad deal.
In fact I have often faced that almost any problem in the callback function will segfault blender
campbellbarton (Campbell Barton) added a comment.Via Old WorldNov 4 2012, 4:12 PM
I've modified our examples so `modal_handler_add` is always called _just_ before returning, this way avoids possability that `self` is freed.

crashing is bad but this is low level window api.
closing.
campbellbarton (Campbell Barton) closed this task as "Invalid".Via Old WorldNov 4 2012, 4:12 PM

Add Comment