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

Using time() leads to binary incompatibility of static executables



Dear all,

We have come across a binary compatibility problem involving
Debian-testing: an executable built from the trivial test program at
the end of this message segfaults on Debian-testing in the call to the
time() function, when the executable was built on a CentOS 6 or CentOS
5 system. We have tested this (both compiling and running) on a
variety of other distributions, and we have found that the following
conditions must all be satisfied to trigger the segfault:

 * compilation/linking (with 'gcc -g --static test_time.c'):
   - on CentOS 5 or CentOS 6
   - the executable must be static
   - the executable must be 64-bit
 * running
   - must be run on Debian-testing (kernel 4.11)

The other distributions that we have used to investigate this further
include:

 * Debian Stretch (kernel 4.9)
 * CentOS 7 (stock kernel, also kernels 4.4 and 4.12 from <http://elrepo.org/>)
 * openSUSE 42.2 (kernel 4.4)
 * openSUSE Tumbleweed (kernel 4.11)
 * Fedora 26 (kernel 4.11)

In our hands, the segfault does not happen if the executable is either
built on one of these other distributions, run on one of them, or
both.

For what it is worth, we observe the same behaviour when building with
various versions of the Intel compilers.

We have not tested building the executable on RedHat or Scientific Linux
systems, but it seems likely that the behaviour would be the same.

I have tried to search the existing bug list to see if anyone else has
reported this. I haven't found anything, but my efforts may not have
been very effective: the search terms for this problem are rather
general, and some of the search engines that are linked to in the
section "Searching bug reports" on <https://www.debian.org/Bugs/>
appear to be broken.

We would be grateful for any comments from someone with more expertise
than us in this area. In particular:

  * have we found a bug in Debian-testing, or is binary compatibility
    not to be expected under these circumstances?

  * if it is a bug, which package should we report it under? (glibc?
    linux? some other package?)

  * have upcoming changes in unstable or experimental already
    addressed this issue?

We are concerned about the possibility that this behaviour might be
present in Debian Buster when it is officially released.

Regards,
Peter Keller

--------------- test_time.c begins here ------------------
#include <stdio.h>
#include <time.h>
int main()
{
    time_t now;
    char buffer[26];
    struct tm* tm_info;
    now = time(NULL);
    tm_info = localtime(&now);
    strftime(buffer, 26, "%Y-%m-%d %H:%M:%S", tm_info);
    puts(buffer);
    return 0;
}
--------------- test_time.c ends here-- ------------------


Reply to: