[PATCH 2/3] Consistently use BFD's time

Tom Tromey tom@tromey.com
Thu Jun 18 14:14:18 GMT 2020


>>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:

>> From: Tom Tromey <tromey@adacore.com>
>> Cc: Tom Tromey <tromey@adacore.com>
>> Date: Tue, 14 Jan 2020 14:09:55 -0700
>> 
>> gdb uses the gnulib stat, while BFD does not.  This can lead to
>> inconsistencies between the two, because the gnulib stat adjusts for
>> timezones.

Eli> There's one more potential issue with Gnulib's replacement of 'fstat':
Eli> it also replaces the definition of 'struct stat', and it does that in
Eli> a way that might yield incompatibility between the definition on
Eli> <sys/stat.h> the system header and Gnulib's sys/stat.h replacement.

I am looking into this issue again for the upcoming gdb 10 release.

Looking at the gnulib in the gdb tree, as far as I can tell, it doesn't
actually override struct stat.  The code is all there:

    /* Optionally, override 'struct stat' on native Windows.  */
    #if @GNULIB_OVERRIDES_STRUCT_STAT@
    [...]

... however, this is only ever set to 0 in our tree:

    $ git grep 'GNULIB_OVERRIDES_STRUCT_STAT.*=' -- gnulib/import/
    gnulib/import/Makefile.in:GNULIB_OVERRIDES_STRUCT_STAT = @GNULIB_OVERRIDES_STRUCT_STAT@
    gnulib/import/m4/sys_stat_h.m4:  GNULIB_OVERRIDES_STRUCT_STAT=0; AC_SUBST([GNULIB_OVERRIDES_STRUCT_STAT])

(I chose a tighter grep for the purposes of posting, but in reality I
looked at all mentions of GNULIB_OVERRIDES_STRUCT_STAT.)

So, I think this is maybe not an issue.

The timezone thing, however, remains an issue.  It seems dangerous to me
that we would have two implementations of stat that would give different
answers.  It's too easy, IMO, to accidentally compare values from one
with values from the other -- in fact, that's what lead to the patches
in this thread I'm replying to.

Based on this, my inclination is to patch our copy of gnulib to avoid
replacing stat on Windows.  I'm looking into how to do this.

Much of the rest of this series will still be needed.  In particular it
unearths a real race in the BFD cache.

Let me know what you think.

Tom


More information about the Gdb-patches mailing list