comparison src/redisplay.c @ 2518:cc24b630b1d6

[xemacs-hg @ 2005-01-26 10:33:40 by ben] Fix some race conditions in redisplay/signal redisplay.c, redisplay.h, signal.c: Move backtraces to internals manual. Fix some race conditions leading to crashes due to incomplete protection of critical sections. In signal.c, be more aggressive in catching incomplete critical section protection -- we cannot even check for QUIT, *EVER*, in a critical section.
author ben
date Wed, 26 Jan 2005 10:33:42 +0000
parents 3d8143fc88e1
children 9f70af3ac939
comparison
equal deleted inserted replaced
2517:9b0afdac688e 2518:cc24b630b1d6
5283 create_right_glyph_block (w, dl); 5283 create_right_glyph_block (w, dl);
5284 5284
5285 return ret_charcount; 5285 return ret_charcount;
5286 } 5286 }
5287 5287
5288 5288 /*
5289 /* Tricky tricky tricky. generate_displayable_area() can (could) be called reentrantly, and redisplay is not prepared to handle this: 5289
5290 5290 Info on Re-entrancy crashes, with backtraces given:
5291 assert_failed(const char * 0x0129c8c8 `string', int 5328, const char * 0x01274068 `string') line 3620 5291
5292 Dynarr_verify_mod_1(void * 0x0250f228, const char * 0x0129c8c8 `string', int 5328) line 1256 + 36 bytes 5292 (Info-goto-node "(internals)Nasty Bugs due to Reentrancy in Redisplay Structures handling QUIT")
5293 generate_displayable_area(window * 0x02480028, long 38776292, int 0, int 0, int 265, int 169, display_line_dynarr * 0x0250f228, long 0, int 2) line 5328 + 25 bytes
5294 output_gutter(frame * 0x0228ad90, gutter_pos TOP_GUTTER, int 1) line 409 + 69 bytes
5295 redraw_exposed_gutter(frame * 0x0228ad90, gutter_pos TOP_GUTTER, int 8, int 23, int 249, int 127) line 687 + 15 bytes
5296 redraw_exposed_gutters(frame * 0x0228ad90, int 8, int 23, int 249, int 127) line 703 + 29 bytes
5297 mswindows_redraw_exposed_area(frame * 0x0228ad90, int 8, int 23, int 249, int 127) line 862 + 25 bytes
5298 mswindows_handle_paint(frame * 0x0228ad90) line 2176 + 25 bytes
5299 mswindows_wnd_proc(HWND__ * 0x001003e2, unsigned int 15, unsigned int 0, long 0) line 3233 + 45 bytes
5300 intercepted_wnd_proc(HWND__ * 0x001003e2, unsigned int 15, unsigned int 0, long 0) line 2488
5301 USER32! 77e3a244()
5302 USER32! 77e14730()
5303 USER32! 77e1558a()
5304 NTDLL! KiUserCallbackDispatcher@12 + 19 bytes
5305 USER32! 77e14680()
5306 USER32! 77e1a792()
5307 qxeIsDialogMessage(HWND__ * 0x001003e2, tagMSG * 0x0082a93c {msg=0x0000000f wp=0x00000000 lp=0x00000000}) line 2298 + 14 bytes
5308 mswindows_is_dialog_msg(tagMSG * 0x0082a93c {msg=0x0000000f wp=0x00000000 lp=0x00000000}) line 165 + 13 bytes
5309 mswindows_drain_windows_queue(int 0) line 1282 + 9 bytes
5310 emacs_mswindows_drain_queue() line 1326 + 7 bytes
5311 event_stream_drain_queue() line 1887
5312 event_stream_quit_p() line 1992
5313 check_quit() line 993
5314 unbind_to_hairy(int 35) line 5963
5315 unbind_to_1(int 35, long 20888208) line 5945 + 200 bytes
5316 specifier_instance_from_inst_list(long 21379344, long 38135616, long 36220304, long 20888208, _error_behavior_struct_ {...}, int 1, long 3) line 2522 + 16 bytes
5317 specifier_instance(long 21379344, long 38135616, long 36220304, _error_behavior_struct_ {...}, int 1, int 0, long 3) line 2625 + 65 bytes
5318 specifier_instance_no_quit(long 21379344, long 38135616, long 36220304, _error_behavior_struct_ {...}, int 0, long 1) line 2658 + 31 bytes
5319 face_property_matching_instance(long 22612340, long 20860632, long 22530956, long 36220304, _error_behavior_struct_ {...}, int 0, long 1) line 565 + 48 bytes
5320 ensure_face_cachel_contains_charset(face_cachel * 0x0082b014, long 36220304, long 22530956) line 1104 + 35 bytes
5321 update_face_cachel_data(face_cachel * 0x0082b014, long 36220304, long 22612340) line 1304 + 19 bytes
5322 query_string_geometry(long 21110576, long 22612340, int * 0x00000000, int * 0x0082b5b4, int * 0x00000000, long 38852960) line 2370 + 23 bytes
5323 mswindows_widget_query_string_geometry(long 21110576, long 22612340, int * 0x0082b5b8, int * 0x0082b5b4, long 38852960) line 2914 + 25 bytes
5324 widget_query_string_geometry(long 21110576, long 22612340, int * 0x0082b5b8, int * 0x0082b5b4, long 38852960) line 514 + 32 bytes
5325 edit_field_query_geometry(long 38857648, int * 0x0082b7b4, int * 0x0082b7b8, image_instance_geometry IMAGE_DESIRED_GEOMETRY, long 38852960) line 920 + 390 bytes
5326 widget_query_geometry(long 38857648, int * 0x0082b7b4, int * 0x0082b7b8, image_instance_geometry IMAGE_DESIRED_GEOMETRY, long 38852960) line 567 + 26 bytes
5327 image_instance_query_geometry(long 38857648, int * 0x0082b7b4, int * 0x0082b7b8, image_instance_geometry IMAGE_DESIRED_GEOMETRY, long 38852960) line 2015 + 26 bytes
5328 glyph_query_geometry(long 38853384, int * 0x0082b7b4, int * 0x0082b7b8, image_instance_geometry IMAGE_DESIRED_GEOMETRY, long 38852960) line 4197 + 25 bytes
5329 layout_query_geometry(long 38852960, int * 0x0082b9cc, int * 0x0082b9d0, image_instance_geometry IMAGE_DESIRED_GEOMETRY, long 38404624) line 1351 + 25 bytes
5330 widget_query_geometry(long 38852960, int * 0x0082b9cc, int * 0x0082b9d0, image_instance_geometry IMAGE_DESIRED_GEOMETRY, long 38404624) line 567 + 26 bytes
5331 image_instance_query_geometry(long 38852960, int * 0x0082b9cc, int * 0x0082b9d0, image_instance_geometry IMAGE_DESIRED_GEOMETRY, long 38404624) line 2015 + 26 bytes
5332 glyph_query_geometry(long 38537976, int * 0x0082b9cc, int * 0x0082b9d0, image_instance_geometry IMAGE_DESIRED_GEOMETRY, long 38404624) line 4197 + 25 bytes
5333 layout_layout(long 38404624, int 265, int 156, int -2, int -2, long 38273064) line 1468 + 23 bytes
5334 widget_layout(long 38404624, int 265, int 156, int -2, int -2, long 38273064) line 626 + 30 bytes
5335 image_instance_layout(long 38404624, int 265, int 156, int -2, int -2, long 38273064) line 2102 + 51 bytes
5336 glyph_ascent(long 38404624, long 38273064) line 4009 + 21 bytes
5337 update_glyph_cachel_data(window * 0x02480028, long 36201168, glyph_cachel * 0x0248c3d8) line 4272 + 13 bytes
5338 get_glyph_cachel_index(window * 0x02480028, long 36201168) line 4306 + 17 bytes
5339 add_glyph_rune(position_redisplay_data_type * 0x0082bf2c, glyph_block * 0x024bd028, int 0, int 0, glyph_cachel * 0x00000000) line 1800 + 15 bytes
5340 add_glyph_runes(position_redisplay_data_type * 0x0082bf2c, int 0) line 2085 + 31 bytes
5341 create_string_text_block(window * 0x02480028, long 38776292, display_line * 0x02514500, long 0, prop_block_dynarr * * 0x0082c13c, int 2) line 4907 + 14 bytes
5342 generate_string_display_line(window * 0x02480028, long 38776292, display_line * 0x02514500, long 0, prop_block_dynarr * * 0x0082c13c, int 2) line 5293 + 29 bytes
5343 generate_displayable_area(window * 0x02480028, long 38776292, int 0, int 0, int 265, int 169, display_line_dynarr * 0x0250f228, long 0, int 2) line 5372 + 29 bytes
5344 output_gutter(frame * 0x0228ad90, gutter_pos TOP_GUTTER, int 0) line 409 + 69 bytes
5345 update_frame_gutters(frame * 0x0228ad90) line 639 + 15 bytes
5346 redisplay_frame(frame * 0x0228ad90, int 1) line 6792 + 9 bytes
5347 redisplay_device(device * 0x0171df00, int 1) line 6911 + 11 bytes
5348 redisplay_without_hooks() line 6957 + 11 bytes
5349 redisplay_no_pre_idle_hook() line 7029
5350 redisplay() line 7011
5351 mswindows_wnd_proc(HWND__ * 0x001003e2, unsigned int 5, unsigned int 0, long 10223881) line 3424
5352 intercepted_wnd_proc(HWND__ * 0x001003e2, unsigned int 5, unsigned int 0, long 10223881) line 2488
5353 USER32! 77e3a244()
5354 USER32! 77e16362()
5355 USER32! 77e14c1a()
5356 USER32! 77e1dd30()
5357 mswindows_wnd_proc(HWND__ * 0x001003e2, unsigned int 71, unsigned int 0, long 8578308) line 3926 + 21 bytes
5358 intercepted_wnd_proc(HWND__ * 0x001003e2, unsigned int 71, unsigned int 0, long 8578308) line 2488
5359 USER32! 77e3a244()
5360 USER32! 77e14730()
5361 USER32! 77e174b4()
5362 NTDLL! KiUserCallbackDispatcher@12 + 19 bytes
5363 mswindows_set_frame_size(frame * 0x0228ad90, int 265, int 156) line 355
5364 internal_set_frame_size(frame * 0x0228ad90, int 265, int 156, int 0) line 2754 + 24 bytes
5365 Fset_frame_displayable_pixel_size(long 36220304, long 531, long 313, long 20888208) line 3004 + 32 bytes
5366 Ffuncall(int 4, long * 0x0082e778) line 3844 + 168 bytes
5367 execute_optimized_program(const unsigned char * 0x02286e48, int 40, long * 0x01529b80) line 609 + 16 bytes
5368 funcall_compiled_function(long 22433308, int 0, long * 0x0082ec08) line 3452 + 85 bytes
5369 Ffuncall(int 1, long * 0x0082ec04) line 3883 + 17 bytes
5370 execute_optimized_program(const unsigned char * 0x02286d40, int 6, long * 0x01548ddc) line 609 + 16 bytes
5371 funcall_compiled_function(long 22505864, int 11, long * 0x0082f00c) line 3452 + 85 bytes
5372 Ffuncall(int 12, long * 0x0082f008) line 3883 + 17 bytes
5373 execute_optimized_program(const unsigned char * 0x02503e38, int 47, long * 0x0152dc48) line 609 + 16 bytes
5374 funcall_compiled_function(long 22436784, int 0, long * 0x0082f534) line 3452 + 85 bytes
5375 Ffuncall(int 1, long * 0x0082f530) line 3883 + 17 bytes
5376 apply1(long 22436784, long 20888208) line 4458 + 11 bytes
5377 Fcall_interactively(long 20742816, long 20888208, long 20888208) line 460 + 13 bytes
5378 Ffuncall(int 2, long * 0x0082f8ec) line 3844 + 127 bytes
5379 call1(long 20854392, long 20742816) line 4489 + 11 bytes
5380 execute_command_event(command_builder * 0x01798f98, long 24439276) line 4198 + 69 bytes
5381 Fdispatch_event(long 24439276) line 4569 + 13 bytes
5382 Fcommand_loop_1() line 569 + 9 bytes
5383 command_loop_1(long 20888208) line 489
5384 condition_case_1(long 20886024, long (long)* 0x010955a0 command_loop_1(long), long 20888208, long (long, long)* 0x01095150 cmd_error(long, long), long 20888208) line 1917 + 7 bytes
5385 command_loop_3() line 251 + 35 bytes
5386 command_loop_2(long 20888208) line 264
5387 internal_catch(long 20650992, long (long)* 0x010952c0 command_loop_2(long), long 20888208, int * volatile 0x00000000, long * volatile 0x00000000) line 1527 + 7 bytes
5388 initial_command_loop(long 20888208) line 300 + 28 bytes
5389 xemacs_21_5_b10_i586_pc_win32(int 1, char * * 0x00e52620, char * * 0x00e52bb0, int 0) line 2356
5390 main(int 1, char * * 0x00e52620, char * * 0x00e52bb0) line 2733
5391 mainCRTStartup() line 338 + 17 bytes
5392 KERNEL32! 77ea847c()
5393
5394 */ 5293 */
5395 5294
5396 5295
5397 /* This is ripped off from regenerate_window. All we want to do is 5296 /* This is ripped off from regenerate_window. All we want to do is
5398 loop through elements in the string creating display lines until we 5297 loop through elements in the string creating display lines until we
5404 Charcount start_pos, 5303 Charcount start_pos,
5405 face_index default_face) 5304 face_index default_face)
5406 { 5305 {
5407 int yend = ypos + height; 5306 int yend = ypos + height;
5408 Charcount s_zv; 5307 Charcount s_zv;
5409
5410 prop_block_dynarr *prop = 0; 5308 prop_block_dynarr *prop = 0;
5411 layout_bounds bounds; 5309 layout_bounds bounds;
5412 assert (dla); 5310 int depth = -1;
5413 5311
5414 Dynarr_reset (dla);
5415 /* if there's nothing to do then do nothing. code after this assumes 5312 /* if there's nothing to do then do nothing. code after this assumes
5416 there is something to do. */ 5313 there is something to do. */
5417 if (NILP (disp_string)) 5314 if (NILP (disp_string))
5418 return; 5315 return;
5316
5317 /* See comment in regenerate_window() */
5318 if (!in_display)
5319 depth = enter_redisplay_critical_section ();
5320
5321 assert (dla);
5322 Dynarr_reset (dla);
5419 5323
5420 s_zv = string_char_length (disp_string); 5324 s_zv = string_char_length (disp_string);
5421 5325
5422 bounds.left_out = xpos; 5326 bounds.left_out = xpos;
5423 bounds.right_out = xpos + width; 5327 bounds.right_out = xpos + width;
5494 break; 5398 break;
5495 } 5399 }
5496 5400
5497 if (prop) 5401 if (prop)
5498 Dynarr_free (prop); 5402 Dynarr_free (prop);
5403
5404 if (depth >= 0)
5405 exit_redisplay_critical_section (depth);
5499 } 5406 }
5500 5407
5501 5408
5502 /***************************************************************************/ 5409 /***************************************************************************/
5503 /* */ 5410 /* */
5510 presentation of the window. We pass the buffer instead of getting 5417 presentation of the window. We pass the buffer instead of getting
5511 it from the window since redisplay_window may have temporarily 5418 it from the window since redisplay_window may have temporarily
5512 changed it to the echo area buffer. */ 5419 changed it to the echo area buffer. */
5513 5420
5514 static void 5421 static void
5515 regenerate_window (struct window *w, Charbpos start_pos, Charbpos point, int type) 5422 regenerate_window (struct window *w, Charbpos start_pos, Charbpos point,
5423 int type)
5516 { 5424 {
5517 struct frame *f = XFRAME (w->frame); 5425 struct frame *f = XFRAME (w->frame);
5518 struct buffer *b = XBUFFER (w->buffer); 5426 struct buffer *b = XBUFFER (w->buffer);
5519 int ypos = WINDOW_TEXT_TOP (w); 5427 int ypos = WINDOW_TEXT_TOP (w);
5520 int yend; /* set farther down */ 5428 int yend; /* set farther down */
5521 int yclip = WINDOW_TEXT_TOP_CLIP (w); 5429 int yclip = WINDOW_TEXT_TOP_CLIP (w);
5522 int force; 5430 int force;
5431 int depth = -1;
5523 5432
5524 prop_block_dynarr *prop; 5433 prop_block_dynarr *prop;
5525 layout_bounds bounds; 5434 layout_bounds bounds;
5526 display_line_dynarr *dla; 5435 display_line_dynarr *dla;
5527 int need_modeline; 5436 int need_modeline;
5528 5437
5529 /* The lines had better exist by this point. */ 5438 /* The lines had better exist by this point. */
5530 if (!(dla = window_display_lines (w, type))) 5439 if (!(dla = window_display_lines (w, type)))
5531 ABORT (); 5440 ABORT ();
5441
5442 if (!in_display)
5443 depth = enter_redisplay_critical_section ();
5444
5445 /* This is one spot where a re-entrancy crash will occur, due to a check
5446 in the dynarr to make sure it isn't "locked" */
5447 /*
5448
5449 Info on Re-entrancy crashes, with backtraces given:
5450
5451 (Info-goto-node "(internals)Nasty Bugs due to Reentrancy in Redisplay Structures handling QUIT")
5452 */
5453
5532 Dynarr_reset (dla); 5454 Dynarr_reset (dla);
5533 w->max_line_len = 0; 5455 w->max_line_len = 0;
5534 5456
5535 /* Normally these get updated in redisplay_window but it is possible 5457 /* Normally these get updated in redisplay_window but it is possible
5536 for this function to get called from some other points where that 5458 for this function to get called from some other points where that
5707 { 5629 {
5708 /* We know that this is the right thing to use because we put it 5630 /* We know that this is the right thing to use because we put it
5709 there when we first started working in this function. */ 5631 there when we first started working in this function. */
5710 generate_modeline (w, Dynarr_atp (dla, 0), type); 5632 generate_modeline (w, Dynarr_atp (dla, 0), type);
5711 } 5633 }
5634
5635 if (depth >= 0)
5636 exit_redisplay_critical_section (depth);
5712 } 5637 }
5713 5638
5714 #define REGEN_INC_FIND_START_END \ 5639 #define REGEN_INC_FIND_START_END \
5715 do { \ 5640 do { \
5716 /* Determine start and end of lines. */ \ 5641 /* Determine start and end of lines. */ \