Subject: Re: bug#11236: 24.1.50; Maximum buffer size exceeded

From: Peter Dyballa <[email-masked]>
Date: Sat, 14 Apr 2012 17:27:03 +0200

Am 13.04.2012 um 17:31 schrieb Eli Zaretskii:

> Can you run under a debugger, but a breakpoint inside buffer_overflow,
> and when it breaks, look around in make_gap_larger and see why exactly
> this overflow happens?

I did that, and the gdb stopped at the proper moment and showed the  
source code of the function buffer_overflow () at insdel.c:391 in a  
new window:

	Loading window (source)...
	Loading .../emacs-24.1.50/lisp/files.el (source)...
	
	Breakpoint 2, buffer_overflow () at insdel.c:391

> E.g., what are the values of current_size and
> of nbytes_added?  Please compile without optimizations, to make
> debugging reliable.

With optimisation on not that much is shown:

	(gdb) bt
	#0  buffer_overflow () at insdel.c:391
	#1  0x0017c028 in Finsert_file_contents (filename=34582793,  
visit=33560610, beg=<value temporarily unavailable, due to  
optimizations>, end=33560610, replace=-2113924036) at fileio.c:3424
	#2  0x001d5b20 in eval_sub (form=33560610) at eval.c:2297
	#3  0x001d725c in Flet (args=21916334) at eval.c:364
	#4  0x001d5be0 in eval_sub (form=21916350) at eval.c:2231
	#5  0x001d6afc in Fprogn (args=<value temporarily unavailable, due to  
optimizations>) at eval.c:364
	#6  0x001c2c08 in Fsave_current_buffer (args=21997158) at editfns.c:987
	#7  0x001d5be0 in eval_sub (form=21997134) at eval.c:2231
	#8  0x001d59f8 in eval_sub (form=21916390) at eval.c:2344
	#9  0x001d725c in Flet (args=21916398) at eval.c:364
	#10 0x001d5be0 in eval_sub (form=21916478) at eval.c:2231
	#11 0x001d60d8 in Funwind_protect (args=21916030) at eval.c:1304
	#12 0x001d5be0 in eval_sub (form=21916486) at eval.c:2231
	#13 0x001d6efc in FletX (args=21886046) at eval.c:364
	#14 0x001d5be0 in eval_sub (form=21886238) at eval.c:2231
	#15 0x001d6d2c in Fif (args=<value temporarily unavailable, due to  
optimizations>) at eval.c:364
	#16 0x001d5be0 in eval_sub (form=21886406) at eval.c:2231
	#17 0x001d7c8c in funcall_lambda (fun=21915766, nargs=4,  
arg_vector=0xbfffdbfc) at eval.c:364
	#18 0x001d22fc in Ffuncall (nargs=<value temporarily unavailable, due  
to optimizations>, args=<value temporarily unavailable, due to  
optimizations>) at eval.c:2996
	#19 0x001d28dc in call4 (fn=<value temporarily unavailable, due to  
optimizations>, arg1=<value temporarily unavailable, due to  
optimizations>, arg2=<value temporarily unavailable, due to  
optimizations>, arg3=<value temporarily unavailable, due to  
optimizations>, arg4=<value temporarily unavailable, due to  
optimizations>) at eval.c:2753
	#20 0x0020d388 in Fload (file=<value temporarily unavailable, due to  
optimizations>, noerror=33560610, nomessage=33560610, nosuffix=<value  
temporarily unavailable, due to optimizations>, must_suffix=<value  
temporarily unavailable, due to optimizations>) at lread.c:1256
	#21 0x001d5b20 in eval_sub (form=33560610) at eval.c:2297
	#22 0x0020c55c in readevalloop (readcharfun=33623138,  
stream=0xa04e04c8, sourcename=33709753, printflag=0, unibyte=<value  
temporarily unavailable, due to optimizations>, readfun=33560610,  
start=33560610, end=33560610) at lread.c:1838
	#23 0x0020d850 in Fload (file=33709625, noerror=<value temporarily  
unavailable, due to optimizations>, nomessage=33560610,  
nosuffix=<value temporarily unavailable, due to optimizations>,  
must_suffix=<value temporarily unavailable, due to optimizations>) at  
lread.c:1316
	#24 0x001d5b20 in eval_sub (form=33560610) at eval.c:2297
	#25 0x001d5fbc in Feval (form=21684678, lexical=<value temporarily  
unavailable, due to optimizations>) at eval.c:2137
	#26 0x001d0010 in internal_condition_case (bfun=0x1376a0  
<top_level_2>, handlers=33589130, hfun=0x13fef0 <cmd_error>) at eval.c: 
1448
	#27 0x00137728 in top_level_1 (ignore=<value temporarily unavailable,  
due to optimizations>) at keyboard.c:1177
	#28 0x001cfea8 in internal_catch (tag=<value temporarily unavailable,  
due to optimizations>, func=0x1376d0 <top_level_1>, arg=33560610) at  
eval.c:1205
	#29 0x001375dc in recursive_edit_1 () at keyboard.c:1132
	#30 0x001403a8 in Frecursive_edit () at keyboard.c:823
	#31 0x001368bc in main (argc=<value temporarily unavailable, due to  
optimizations>, argv=0xbffff244) at emacs.c:1711
	
	Lisp Backtrace:
	"insert-file-contents" (0xbfffd160)
	"let" (0xbfffd2ac)
	"save-current-buffer" (0xbfffd41c)
	"with-current-buffer" (0xbfffd4ec)
	"let" (0xbfffd65c)
	"unwind-protect" (0xbfffd79c)
	"let*" (0xbfffd8ec)
	"if" (0xbfffda0c)
	"load-with-code-conversion" (0xbfffdbfc)
	"load" (0xbfffe1a0)
	"load" (0xbfffe820)
	(gdb) pr current_size
	The history is empty.
	(gdb) pr nbytes_added
	The history is empty.
	(gdb) The program is running.  Exit anyway? (y or n) y
	
	Debugger finished

I think this was a Friday the 13th issue... because I can't reproduce  
the failure with and without optimisation. Maybe I need to fail  
rebuilding the NS variant first, which was my start yesterday (the NS  
variant installs a /usr/local/bin/emacs and a /usr/local/bin/emacs- 
yversion> that cannot be used as is, so they need to be overwritten  
with usable stuff)

--
Greetings

   Pete

When confronted with actual numbers, a mathematician is at a loss.
				– Steffen Hokland