emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: allocate_string_data memory corruption


From: Chong Yidong
Subject: Re: allocate_string_data memory corruption
Date: Thu, 26 Jan 2006 14:45:14 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

>> But can all the known problems be fixed this way?
>
> At the cost of adding BLOCK_INPUT for each allocation function?  Sure, but
> I'd rather not do that.

I don't see any better solution.  It is non-trivial to fix the
behavior of handle_one_xevent with synched input.  I, for one, don't
see any clean way to fix note note_mouse_highlight and
x_handle_dnd_message.  And we can't be sure that we fixed all the bugs
in the signal handler.

Fixing DSYNC_INPUT so that RMS is happy with it would also delay the
release considerably.

Finally, putting the BLOCK_INPUT's does not seem to affect performance
noticeably.

 rm -f *.elc; time emacs --batch -f batch-byte-compile-if-not-done *.el

goes from

 real  0m53.052s         real  0m53.303s
 user  0m50.528s   to    user  0m50.511s
 sys   0m0.537s          sys   0m0.526s

If there are no objections, I'll commit this, and we can consider this
issue closed until *after* the release.


*** emacs/src/alloc.c.~1.388.~  2006-01-26 13:44:24.000000000 -0500
--- emacs/src/alloc.c   2006-01-26 14:03:45.000000000 -0500
***************
*** 1422,1428 ****
  {
    INTERVAL val;
  
!   eassert (!handling_signal);
  
    if (interval_free_list)
      {
--- 1422,1432 ----
  {
    INTERVAL val;
  
!   /* eassert (!handling_signal); */
! 
! #ifndef SYNC_INPUT
!   BLOCK_INPUT;
! #endif
  
    if (interval_free_list)
      {
***************
*** 1445,1450 ****
--- 1449,1459 ----
        }
        val = &interval_block->intervals[interval_block_index++];
      }
+ 
+ #ifndef SYNC_INPUT
+   UNBLOCK_INPUT;
+ #endif
+ 
    consing_since_gc += sizeof (struct interval);
    intervals_consed++;
    RESET_INTERVAL (val);
***************
*** 1842,1848 ****
  {
    struct Lisp_String *s;
  
!   eassert (!handling_signal);
  
    /* If the free-list is empty, allocate a new string_block, and
       add all the Lisp_Strings in it to the free-list.  */
--- 1851,1861 ----
  {
    struct Lisp_String *s;
  
!   /* eassert (!handling_signal); */
! 
! #ifndef SYNC_INPUT
!   BLOCK_INPUT;
! #endif
  
    /* If the free-list is empty, allocate a new string_block, and
       add all the Lisp_Strings in it to the free-list.  */
***************
*** 1873,1878 ****
--- 1886,1895 ----
    s = string_free_list;
    string_free_list = NEXT_FREE_LISP_STRING (s);
  
+ #ifndef SYNC_INPUT
+   UNBLOCK_INPUT;
+ #endif
+ 
    /* Probably not strictly necessary, but play it safe.  */
    bzero (s, sizeof *s);
  
***************
*** 1920,1925 ****
--- 1937,1948 ----
    /* Determine the number of bytes needed to store NBYTES bytes
       of string data.  */
    needed = SDATA_SIZE (nbytes);
+   old_data = s->data ? SDATA_OF_STRING (s) : NULL;
+   old_nbytes = GC_STRING_BYTES (s);
+ 
+ #ifndef SYNC_INPUT
+   BLOCK_INPUT;
+ #endif
  
    if (nbytes > LARGE_STRING_BYTES)
      {
***************
*** 1974,1985 ****
    else
      b = current_sblock;
  
-   old_data = s->data ? SDATA_OF_STRING (s) : NULL;
-   old_nbytes = GC_STRING_BYTES (s);
- 
    data = b->next_free;
    b->next_free = (struct sdata *) ((char *) data + needed + GC_STRING_EXTRA);
  
    data->string = s;
    s->data = SDATA_DATA (data);
  #ifdef GC_CHECK_STRING_BYTES
--- 1997,2009 ----
    else
      b = current_sblock;
  
    data = b->next_free;
    b->next_free = (struct sdata *) ((char *) data + needed + GC_STRING_EXTRA);
  
+ #ifndef SYNC_INPUT
+   UNBLOCK_INPUT;
+ #endif
+ 
    data->string = s;
    s->data = SDATA_DATA (data);
  #ifdef GC_CHECK_STRING_BYTES
***************
*** 2560,2566 ****
  {
    register Lisp_Object val;
  
!   eassert (!handling_signal);
  
    if (float_free_list)
      {
--- 2584,2594 ----
  {
    register Lisp_Object val;
  
!   /* eassert (!handling_signal); */
! 
! #ifndef SYNC_INPUT
!   BLOCK_INPUT;
! #endif
  
    if (float_free_list)
      {
***************
*** 2587,2592 ****
--- 2615,2624 ----
        float_block_index++;
      }
  
+ #ifndef SYNC_INPUT
+   UNBLOCK_INPUT;
+ #endif
+ 
    XFLOAT_DATA (val) = float_value;
    eassert (!FLOAT_MARKED_P (XFLOAT (val)));
    consing_since_gc += sizeof (struct Lisp_Float);
***************
*** 2681,2687 ****
  {
    register Lisp_Object val;
  
!   eassert (!handling_signal);
  
    if (cons_free_list)
      {
--- 2713,2723 ----
  {
    register Lisp_Object val;
  
!   /* eassert (!handling_signal); */
! 
! #ifndef SYNC_INPUT
!   BLOCK_INPUT;
! #endif
  
    if (cons_free_list)
      {
***************
*** 2707,2712 ****
--- 2743,2752 ----
        cons_block_index++;
      }
  
+ #ifndef SYNC_INPUT
+   UNBLOCK_INPUT;
+ #endif
+ 
    XSETCAR (val, car);
    XSETCDR (val, cdr);
    eassert (!CONS_MARKED_P (XCONS (val)));
***************
*** 2880,2887 ****
--- 2920,2936 ----
    consing_since_gc += nbytes;
    vector_cells_consed += len;
  
+ #ifndef SYNC_INPUT
+   BLOCK_INPUT;
+ #endif
+ 
    p->next = all_vectors;
    all_vectors = p;
+ 
+ #ifndef SYNC_INPUT
+   UNBLOCK_INPUT;
+ #endif
+ 
    ++n_vectors;
    return p;
  }
***************
*** 3162,3167 ****
--- 3211,3220 ----
  
    eassert (!handling_signal);
  
+ #ifndef SYNC_INPUT
+   BLOCK_INPUT;
+ #endif
+ 
    if (symbol_free_list)
      {
        XSETSYMBOL (val, symbol_free_list);
***************
*** 3183,3188 ****
--- 3236,3245 ----
        symbol_block_index++;
      }
  
+ #ifndef SYNC_INPUT
+   UNBLOCK_INPUT;
+ #endif
+ 
    p = XSYMBOL (val);
    p->xname = name;
    p->plist = Qnil;
***************
*** 3242,3248 ****
  {
    Lisp_Object val;
  
!   eassert (!handling_signal);
  
    if (marker_free_list)
      {
--- 3299,3309 ----
  {
    Lisp_Object val;
  
!   /* eassert (!handling_signal); */
! 
! #ifndef SYNC_INPUT
!   BLOCK_INPUT;
! #endif
  
    if (marker_free_list)
      {
***************
*** 3266,3271 ****
--- 3327,3336 ----
        marker_block_index++;
      }
  
+ #ifndef SYNC_INPUT
+   UNBLOCK_INPUT;
+ #endif
+ 
    --total_free_markers;
    consing_since_gc += sizeof (union Lisp_Misc);
    misc_objects_consed++;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]