delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2015/04/30/13:00:41

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp AT delorie DOT com
Message-ID: <55425FAB.4020908@iki.fi>
Date: Thu, 30 Apr 2015 20:00:27 +0300
From: Andris Pavenis <andris DOT pavenis AT iki DOT fi>
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0
MIME-Version: 1.0
To: "DJGPP List (E-mail)" <djgpp AT delorie DOT com>
Subject: gcc-5.1.0 and calloc
Reply-To: djgpp AT delorie DOT com

DJGPP libc built with gcc-5.1.0 has broken calloc()

I noticed it already some time ago with earlier gcc-5 snapshots.

Source of problem is over-optimization of code:

GCC recognizes source of function calloc() to be calloc and as result
optimizes it to infinite tail recursion. No no actual call happen, just jump.
So there is no stack overflow but only infinite loop.

Initially failed to debug this with GDB under WIndows Vista. Ancient FSDB however
allowed to reveal problem easily.

The solution is to use -fno-builtin-malloc  for this source

One can see that this problem is known by looking into sources of DJGPP port of GCC-5.1.0
(archive gcc510s.zip, file gnu/gcc-5.10/gcc/config/i386/x-djgpp).

This really looks like GCC bug. It can also be reproduced on Linux, so it is not DJGPP specific.

Andris

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019