"Source file is more recent than executable" except it isn't

Matthew Mitchell picture Matthew Mitchell · Apr 30, 2014 · Viewed 17k times · Source

GDB is complaining that my source file is more recent than the executable, and it appears the debugging information is indeed related to an older version of the source file, because gdb is stopping on a blank line:

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) up
#1  0x00007ffff7ba2d88 in CBKeyPairGenerate (keyPair=0x602010) at library/src/CBHDKeys.c:246
warning: Source file is more recent than executable.
246
(gdb) list
241             if (versionBytes == CB_HD_KEY_VERSION_TEST_PUBLIC
242                     || versionBytes == CB_HD_KEY_VERSION_TEST_PRIVATE)
243                     return CB_NETWORK_TEST;
244
245             return CB_NETWORK_UNKNOWN;
246
247     }
248
249     uint8_t * CBHDKeyGetPrivateKey(CBHDKey * key) {
250

But the executable is more recent than the source file, see here:

$ ls -l library/src/CBHDKeys.c 
-rw-r--r-- 1 matt matt 9249 Apr 29 22:40 library/src/CBHDKeys.c
$ ls -l bin/noLowerAddressGenerator 
-rwxr-xr-x 1 matt matt 17845 Apr 30 15:52 bin/noLowerAddressGenerator

I tried rebuilding after make clean and ccache -C but the same problem occurs. When I updated the source file I only added whitespace, so the program logic remains equal.I feel that has something to do with it, but since I cleared the ccache and cleaned the build and bin directory with make clean I'm not sure what is going on.

Versions:

  • GNU Make 3.81
  • gcc (Debian 4.8.2-16) 4.8.2
  • GNU gdb (GDB) 7.6.2 (Debian 7.6.2-1)
  • ccache version 3.1.9
  • SolydXK - SMP Debian 3.13.5-1 (2014-03-04)

Answer

Toby Speight picture Toby Speight · May 8, 2017

Perhaps you're not using the most recent compiled version of the code, if it's in a shared library. You could use ldd noLowerAddressGenerator to see the library dependencies of your program; I don't know if it's possible from within GDB to locate the relevant library, but there ought to be a way (please comment or edit if you know how).

If this is indeed the case, you might want to set environment LD_LIBRARY_PATH in GDB prior to running the program, to place your newly-built library ahead of any installed ones. You could look into setting the RPATH ELF variable when linking, but that's likely to be less help.

Another possibility is to run your debugger on a system where you know the library isn't installed. I've had good results using schroot to keep build/debug/install environments separated.