unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#24065: commit 09ece4d341a7 (Restore the calloc family) causes miscompile for gcc-5 and higher
@ 2016-07-25  7:22 Markus Trippelsdorf
  2016-07-25 12:38 ` Wolfgang Jenkner
  0 siblings, 1 reply; 8+ messages in thread
From: Markus Trippelsdorf @ 2016-07-25  7:22 UTC (permalink / raw)
  To: 24065; +Cc: Wolfgang Jenkner

commit 09ece4d341a7e07fab7be22868ebcadae8641c79
Author: Wolfgang Jenkner <wjenkner@inode.at>
Date:   Tue Feb 9 15:04:40 2016 -0800

    Restore the calloc family.

causes gcc-5 and higher to compile calloc to an endless loop.
-fno-builtin-malloc should be used to work around the problem.

See: https://gcc.gnu.org/ml/gcc-help/2015-03/msg00109.html
for a similar example.


-- 
Markus





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#24065: commit 09ece4d341a7 (Restore the calloc family) causes miscompile for gcc-5 and higher
  2016-07-25  7:22 bug#24065: commit 09ece4d341a7 (Restore the calloc family) causes miscompile for gcc-5 and higher Markus Trippelsdorf
@ 2016-07-25 12:38 ` Wolfgang Jenkner
  2016-07-25 12:55   ` Markus Trippelsdorf
  0 siblings, 1 reply; 8+ messages in thread
From: Wolfgang Jenkner @ 2016-07-25 12:38 UTC (permalink / raw)
  To: markus; +Cc: 24065

Markus Trippelsdorf <markus@trippelsdorf.de> wrote:

> commit 09ece4d341a7e07fab7be22868ebcadae8641c79
> Author: Wolfgang Jenkner <wjenkner@inode.at>
> Date:   Tue Feb 9 15:04:40 2016 -0800
>
>     Restore the calloc family.
>
> causes gcc-5 and higher to compile calloc to an endless loop.
> -fno-builtin-malloc should be used to work around the problem.

This was the reason for the (compiler-independent) work-around
discussed in

http://debbugs.gnu.org/cgi/bugreport.cgi?bug=22085

and committed in

commit 4b1436b702d56eedd27a0777fc7232cdfb7ac4f6
Author: Wolfgang Jenkner <wjenkner@inode.at>
Date:   Sat Dec 26 12:12:02 2015 -0800

    Always define gmalloc etc. in src/gmalloc.c
     
The commit you cited shouldn't change that, I think.

In any case, that work-around seems to work for DragonflyBSD, which
has gcc 5 as base compiler, and, for the time being (i.e., emacs-25
branch), actually uses the malloc implemented in src/gmalloc, cf.

https://github.com/DragonFlyBSD/DPorts/tree/master/editors/emacs-devel

So, it would be useful to know on which system compilation fails.







^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#24065: commit 09ece4d341a7 (Restore the calloc family) causes miscompile for gcc-5 and higher
  2016-07-25 12:38 ` Wolfgang Jenkner
@ 2016-07-25 12:55   ` Markus Trippelsdorf
  2016-07-25 13:27     ` Wolfgang Jenkner
  0 siblings, 1 reply; 8+ messages in thread
From: Markus Trippelsdorf @ 2016-07-25 12:55 UTC (permalink / raw)
  To: Wolfgang Jenkner; +Cc: 24065

On 2016.07.25 at 14:38 +0200, Wolfgang Jenkner wrote:
> Markus Trippelsdorf <markus@trippelsdorf.de> wrote:
> 
> > commit 09ece4d341a7e07fab7be22868ebcadae8641c79
> > Author: Wolfgang Jenkner <wjenkner@inode.at>
> > Date:   Tue Feb 9 15:04:40 2016 -0800
> >
> >     Restore the calloc family.
> >
> > causes gcc-5 and higher to compile calloc to an endless loop.
> > -fno-builtin-malloc should be used to work around the problem.
> 
> This was the reason for the (compiler-independent) work-around
> discussed in
> 
> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=22085
> 
> and committed in
> 
> commit 4b1436b702d56eedd27a0777fc7232cdfb7ac4f6
> Author: Wolfgang Jenkner <wjenkner@inode.at>
> Date:   Sat Dec 26 12:12:02 2015 -0800
> 
>     Always define gmalloc etc. in src/gmalloc.c
>      
> The commit you cited shouldn't change that, I think.
> 
> In any case, that work-around seems to work for DragonflyBSD, which
> has gcc 5 as base compiler, and, for the time being (i.e., emacs-25
> branch), actually uses the malloc implemented in src/gmalloc, cf.
> 
> https://github.com/DragonFlyBSD/DPorts/tree/master/editors/emacs-devel
> 
> So, it would be useful to know on which system compilation fails.

This happens on a Gentoo system (glibc trunk, gcc-6 latest branch):

(gdb) run
Starting program: /var/tmp/portage/app-editors/emacs-24.5-r3/work/emacs-24.5/src/temacs --batch --load loadup bootstrap

Program received signal SIGSEGV, Segmentation fault.
0x00000000005cac25 in calloc (nmemb=<error reading variable: DWARF-2 expression error: Loop detected (257).>, size=size@entry=1) at gmalloc.c:1529
1529      result = malloc (bytes);
(gdb) bt
#0  0x00000000005cac25 in calloc (nmemb=<error reading variable: DWARF-2 expression error: Loop detected (257).>, size=size@entry=1) at gmalloc.c:1529
#1  0x00000000005cac2a in calloc (nmemb=<error reading variable: DWARF-2 expression error: Loop detected (257).>, size=size@entry=1) at gmalloc.c:1529
#2  0x00000000005cac2a in calloc (nmemb=<error reading variable: DWARF-2 expression error: Loop detected (257).>, size=size@entry=1) at gmalloc.c:1529
...

Adding -fno-builtin-malloc to CFLAGS fixes the issue for me.

-- 
Markus





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#24065: commit 09ece4d341a7 (Restore the calloc family) causes miscompile for gcc-5 and higher
  2016-07-25 12:55   ` Markus Trippelsdorf
@ 2016-07-25 13:27     ` Wolfgang Jenkner
  2016-07-25 14:24       ` Markus Trippelsdorf
  0 siblings, 1 reply; 8+ messages in thread
From: Wolfgang Jenkner @ 2016-07-25 13:27 UTC (permalink / raw)
  To: markus; +Cc: 24065

Markus Trippelsdorf <markus@trippelsdorf.de> wrote:

> On 2016.07.25 at 14:38 +0200, Wolfgang Jenkner wrote:
[...]
> > Author: Wolfgang Jenkner <wjenkner@inode.at>
> > Date:   Sat Dec 26 12:12:02 2015 -0800
> > 
> >     Always define gmalloc etc. in src/gmalloc.c
> >      
[...]
> > So, it would be useful to know on which system compilation fails.
>
> This happens on a Gentoo system (glibc trunk, gcc-6 latest branch):
>
> (gdb) run
> Starting program: /var/tmp/portage/app-editors/emacs-24.5-r3/work/emacs-24.5/src/temacs --batch --load loadup bootstrap

According to ftp://alpha.gnu.org/gnu/emacs/pretest/ your emacs
version has been made available in April 2015 and so predates
the fix from December 2015 above.  Also, your version belongs to
an older (and effectively unmaintained) release series.

tl; dr: Please update to a current release candidate. 







^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#24065: commit 09ece4d341a7 (Restore the calloc family) causes miscompile for gcc-5 and higher
  2016-07-25 13:27     ` Wolfgang Jenkner
@ 2016-07-25 14:24       ` Markus Trippelsdorf
  2016-07-25 15:48         ` Wolfgang Jenkner
  0 siblings, 1 reply; 8+ messages in thread
From: Markus Trippelsdorf @ 2016-07-25 14:24 UTC (permalink / raw)
  To: Wolfgang Jenkner; +Cc: 24065

On 2016.07.25 at 15:27 +0200, Wolfgang Jenkner wrote:
> Markus Trippelsdorf <markus@trippelsdorf.de> wrote:
> 
> > On 2016.07.25 at 14:38 +0200, Wolfgang Jenkner wrote:
> [...]
> > > Author: Wolfgang Jenkner <wjenkner@inode.at>
> > > Date:   Sat Dec 26 12:12:02 2015 -0800
> > > 
> > >     Always define gmalloc etc. in src/gmalloc.c
> > >      
> [...]
> > > So, it would be useful to know on which system compilation fails.
> >
> > This happens on a Gentoo system (glibc trunk, gcc-6 latest branch):
> >
> > (gdb) run
> > Starting program: /var/tmp/portage/app-editors/emacs-24.5-r3/work/emacs-24.5/src/temacs --batch --load loadup bootstrap
> 
> According to ftp://alpha.gnu.org/gnu/emacs/pretest/ your emacs
> version has been made available in April 2015 and so predates
> the fix from December 2015 above.  Also, your version belongs to
> an older (and effectively unmaintained) release series.
> 
> tl; dr: Please update to a current release candidate. 

Ok. Sorry for pointing to the wrong commit.

But version 24.5 is the latest stable release. 
It is sad, that it cannot be compiled with gcc-5 or gcc-6.

-- 
Markus





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#24065: commit 09ece4d341a7 (Restore the calloc family) causes miscompile for gcc-5 and higher
  2016-07-25 14:24       ` Markus Trippelsdorf
@ 2016-07-25 15:48         ` Wolfgang Jenkner
  2016-07-25 15:58           ` Markus Trippelsdorf
  2016-07-26  7:08           ` Paul Eggert
  0 siblings, 2 replies; 8+ messages in thread
From: Wolfgang Jenkner @ 2016-07-25 15:48 UTC (permalink / raw)
  To: markus; +Cc: eggert, 24065

Markus Trippelsdorf <markus@trippelsdorf.de> wrote:

> > > This happens on a Gentoo system (glibc trunk, gcc-6 latest branch):

> But version 24.5 is the latest stable release. 
> It is sad, that it cannot be compiled with gcc-5 or gcc-6.

Actually, on GNU/Linux src/gmalloc.c (which contains the code in
question) is not even compiled, normally.

The reason for your compilation troubles seems to be that you use
a recent git checkout of glibc (as you stated above) which I guess
already contains

http://repo.or.cz/glibc.git/commitdiff/2ba3cfa1607c36613f3b30fb1ae4ec530245ce64

IIUC, this commit removes  the declaration of __malloc_initialize_hook,
so the emacs configure check for "whether malloc is Doug Lea style"
will fail.

And this is the reason why you suddenly need malloc etc. from
src/gmalloc.c.







^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#24065: commit 09ece4d341a7 (Restore the calloc family) causes miscompile for gcc-5 and higher
  2016-07-25 15:48         ` Wolfgang Jenkner
@ 2016-07-25 15:58           ` Markus Trippelsdorf
  2016-07-26  7:08           ` Paul Eggert
  1 sibling, 0 replies; 8+ messages in thread
From: Markus Trippelsdorf @ 2016-07-25 15:58 UTC (permalink / raw)
  To: Wolfgang Jenkner; +Cc: eggert, 24065

On 2016.07.25 at 17:48 +0200, Wolfgang Jenkner wrote:
> Markus Trippelsdorf <markus@trippelsdorf.de> wrote:
> 
> > > > This happens on a Gentoo system (glibc trunk, gcc-6 latest branch):
> 
> > But version 24.5 is the latest stable release. 
> > It is sad, that it cannot be compiled with gcc-5 or gcc-6.
> 
> Actually, on GNU/Linux src/gmalloc.c (which contains the code in
> question) is not even compiled, normally.
> 
> The reason for your compilation troubles seems to be that you use
> a recent git checkout of glibc (as you stated above) which I guess
> already contains
> 
> http://repo.or.cz/glibc.git/commitdiff/2ba3cfa1607c36613f3b30fb1ae4ec530245ce64
> 
> IIUC, this commit removes  the declaration of __malloc_initialize_hook,
> so the emacs configure check for "whether malloc is Doug Lea style"
> will fail.
> 
> And this is the reason why you suddenly need malloc etc. from
> src/gmalloc.c.

Thanks for finding the root cause.
I can confirm that my glibc versions contains the commit in question.

-- 
Markus





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#24065: commit 09ece4d341a7 (Restore the calloc family) causes miscompile for gcc-5 and higher
  2016-07-25 15:48         ` Wolfgang Jenkner
  2016-07-25 15:58           ` Markus Trippelsdorf
@ 2016-07-26  7:08           ` Paul Eggert
  1 sibling, 0 replies; 8+ messages in thread
From: Paul Eggert @ 2016-07-26  7:08 UTC (permalink / raw)
  To: Wolfgang Jenkner, markus; +Cc: 24065-done

On 07/25/2016 05:48 PM, Wolfgang Jenkner wrote:
> IIUC, this commit removes  the declaration of __malloc_initialize_hook,
> so the emacs configure check for "whether malloc is Doug Lea style"
> will fail.

This problem should be fixed on Emacs master and emacs-25, as well as in 
the current release candidate for Emacs 25 
<ftp://alpha.gnu.org/gnu/emacs/pretest/emacs-25.1-rc1.tar.xz>. If you're 
still observing the problem in any of these editions of Emacs, please 
let us know. In the meantime I will close the bug report as I think this 
bug is fixed now.






^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-07-26  7:08 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-25  7:22 bug#24065: commit 09ece4d341a7 (Restore the calloc family) causes miscompile for gcc-5 and higher Markus Trippelsdorf
2016-07-25 12:38 ` Wolfgang Jenkner
2016-07-25 12:55   ` Markus Trippelsdorf
2016-07-25 13:27     ` Wolfgang Jenkner
2016-07-25 14:24       ` Markus Trippelsdorf
2016-07-25 15:48         ` Wolfgang Jenkner
2016-07-25 15:58           ` Markus Trippelsdorf
2016-07-26  7:08           ` Paul Eggert

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).