From owner-freebsd-current Thu Dec 4 20:00:26 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id UAA08436 for current-outgoing; Thu, 4 Dec 1997 20:00:26 -0800 (PST) (envelope-from owner-freebsd-current) Received: from austin.polstra.com (austin.polstra.com [206.213.73.10]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id UAA08348 for ; Thu, 4 Dec 1997 20:00:10 -0800 (PST) (envelope-from jdp@austin.polstra.com) Received: from austin.polstra.com (jdp@localhost) by austin.polstra.com (8.8.8/8.8.7) with ESMTP id TAA17097; Thu, 4 Dec 1997 19:58:33 -0800 (PST) (envelope-from jdp) Message-Id: <199712050358.TAA17097@austin.polstra.com> To: Poul-Henning Kamp cc: current@FreeBSD.ORG Subject: Re: Heads up: recent ld.so changes broke emacs In-reply-to: Your message of "Thu, 04 Dec 1997 10:19:30 +0100." <7661.881227170@critter.freebsd.dk> Date: Thu, 04 Dec 1997 19:58:33 -0800 From: John Polstra Sender: owner-freebsd-current@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > Emacs may think that it has a monopoly on calling sbrk() that would > be bad :-( Luckily, that's not it. The problem, essentially, is that the emacs executable is invalid. When emacs is built, first the Makefile builds a virgin version named "temacs" using normal cc commands. Then it runs temacs in batch mode, telling it to load all the common built-in lisp modules. After loading them into memory, temacs then "unexec"s itself. What does that mean? It copies its address space out to a file, and fakes up an a.out header at the beginning of it so that the file can be executed directly. That file becomes the emacs that is installed. Unfortunately, the file isn't quite a valid executable. The special symbols "_edata" and "_end", which would normally be be be generated by the linker, have incorrect values. The dynamic linker was using the value of "_end" to set the initial break level that sbrk uses. Since the value was wrong, the memory allocations were trampling on emacs data, thereby causing it to coredump. To work around the bug, I changed the dynamic linker to calculate its break level based on the segment sizes in the a.out header. Luckily, it can access the header, because under FreeBSD the a.out header is mapped into memory near the beginning of the program's address space. Xemacs has a better unexec package, which sets the values of the special symbols correctly. That's why it worked but GNU emacs didn't. I committed the workaround this evening, and everything should function fine again. John -- John Polstra jdp@polstra.com John D. Polstra & Co., Inc. Seattle, Washington USA "Self-knowledge is always bad news." -- John Barth