emacs-bug-tracker
[Top][All Lists]
Advanced

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

[debbugs-tracker] bug#22085: closed (25.0.50; src/gmalloc.c hit by gcc >


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#22085: closed (25.0.50; src/gmalloc.c hit by gcc >= 5 optimization )
Date: Sat, 26 Dec 2015 20:17:01 +0000

Your message dated Sat, 26 Dec 2015 12:15:54 -0800
with message-id <address@hidden>
and subject line Re: 25.0.50; src/gmalloc.c hit by gcc >= 5 optimization
has caused the debbugs.gnu.org bug report #22085,
regarding 25.0.50; src/gmalloc.c hit by gcc >= 5 optimization 
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
22085: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=22085
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: 25.0.50; src/gmalloc.c hit by gcc >= 5 optimization Date: Thu, 03 Dec 2015 18:53:25 +0100 User-agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.1.50 (berkeley-unix)
On systems which use src/gmalloc.c but don't define HYBRID_MALLOC that
file defines global replacements for malloc and other memory management
functions.

Strictly speaking, this results in undefined behaviour according to ISO
C11 (wg14 n1570 draft) 7.1.3 and 7.22.3.

But it used to work.  However, with recent gcc versions and the default
optimization level (-O2), most of the definition of calloc is replaced
with a call to calloc (which the linker resolves to a call to that same
calloc).  Chances are temacs crashes because some library calls calloc.

This happens with the gcc 5.2.0 release and also with the 6.0.0 20151108
snapshot.

Please find below a self-contained test program which shows the problem
(try gcc5 -Wall -g -O2 callocopt.c -o callocopt && ./callocopt 666, and
then with -O instead of -O2, or even with -O2 -fno-optimize-strlen).

For comparison purposes, I note that, meanwhile, the issue has also
surfaced here

http://permalink.gmane.org/gmane.os.freebsd.devel.cvs.src/210733

Back to the problem with gmalloc.c, I'd suggest the simple
toolchain-independent work-around given in the patch below.

A real fix is to use hybrid malloc.

Attachment: callocopt.c
Description: Test program

Attachment: 0001-src-gmalloc.c-Always-define-gmalloc-and-friends.patch
Description: gcc 5 optimization work-around for gmalloc


--- End Message ---
--- Begin Message --- Subject: Re: 25.0.50; src/gmalloc.c hit by gcc >= 5 optimization Date: Sat, 26 Dec 2015 12:15:54 -0800 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 Thanks for the fix; I have applied this patch to the emacs-25 branch and am closing Bug#22085. The companion Bug#22086 will require more thinking, and I plan to follow up there.


--- End Message ---

reply via email to

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