From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chong Yidong Newsgroups: gmane.emacs.devel Subject: Re: allocate_string_data memory corruption Date: Thu, 26 Jan 2006 14:45:14 -0500 Message-ID: <871wyuixit.fsf@stupidchicken.com> References: <87vewha2zl.fsf@stupidchicken.com> <87zmlq6w62.fsf-monnier+emacs@gnu.org> <874q3v6a65.fsf-monnier+emacs@gnu.org> <873bjbahq6.fsf@stupidchicken.com> <87r76usumg.fsf-monnier+emacs@gnu.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1138304900 9384 80.91.229.2 (26 Jan 2006 19:48:20 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 26 Jan 2006 19:48:20 +0000 (UTC) Cc: rms@gnu.org, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jan 26 20:48:15 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1F2D65-0001Sp-OI for ged-emacs-devel@m.gmane.org; Thu, 26 Jan 2006 20:47:58 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1F2D8t-0001UG-Ac for ged-emacs-devel@m.gmane.org; Thu, 26 Jan 2006 14:50:51 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1F2D5M-0006XN-2n for emacs-devel@gnu.org; Thu, 26 Jan 2006 14:47:12 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1F2D5K-0006Vv-Dl for emacs-devel@gnu.org; Thu, 26 Jan 2006 14:47:10 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1F2D5J-0006VU-Pq for emacs-devel@gnu.org; Thu, 26 Jan 2006 14:47:09 -0500 Original-Received: from [18.19.6.82] (helo=localhost.localdomain) by monty-python.gnu.org with esmtp (Exim 4.52) id 1F2D2n-00071H-B1; Thu, 26 Jan 2006 14:44:33 -0500 Original-Received: by localhost.localdomain (Postfix, from userid 1000) id 470AB1208EA; Thu, 26 Jan 2006 14:45:15 -0500 (EST) Original-To: Stefan Monnier In-Reply-To: <87r76usumg.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Thu, 26 Jan 2006 13:40:35 -0500") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:49595 Archived-At: >> 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++;