I have this very simple source code used as a test program:
#include <stdio.h>
#include <stdlib.h>
int main()
{
FILE *fp;
fp = fopen("file.txt", "w");
fclose(fp);
fclose(fp);
printf("Completed successfully\n\n");
return(0);
}
I am running this code on two Ubuntu servers, both running Ubuntu 18.04 LTS. It is dying on MachA at the fopen, while on MachB it runs fine and gets to "Completed successfully".
The exact error is:
./testpgm
free(): double free detected in tcache 2
Abort(coredump)
Using gdb, it appears the code is using the same search path. The same shared libraries are reported in both systems:
(gdb) info sharedlibrary
From To Syms Read Shared Object Library
0x00007ffff7dd3f10 0x00007ffff7df4570 Yes /lib64/ld-linux-x86-64.so.2
0x00007ffff7a032d0 0x00007ffff7b7bb7c Yes /lib/x86_64-linux-gnu/libc.so.6
The only thing I can think of that might affect this is on the problem machine, I have g++-9 and I am not sure how I got that installed because it does not appear to be listed in the apt-get as an installable package anymore.
Problem server:
g++-7/bionic-updates,bionic-security,now 7.5.0-3ubuntu1~18.04 amd64 [installed]
g++-8/bionic-updates,bionic-security,now 8.4.0-1ubuntu1~18.04 amd64 [installed]
g++-9/bionic,now 9.3.0-11ubuntu0~18.04.1 amd64 [installed]
Working server:
g++-8/bionic-updates,bionic-security,now 8.4.0-1ubuntu1~18.04 amd64 [installed]
Is it possible that the g++-9 was available in apt for download and then was removed due to problems? I'm debating trying to remove that package to see if it solves the issue, but wanted to know if anyone else has encountered this issue, or has any suggestions for other things to look for.
UPDATE:
As suggested by waltinator, I tried the strace command, but it did not offer much insight as to why this may be happening. The strace shows pretty much the same data between the working and problem system. Only difference at the beginning was an attempt to access ld.so.preload on the copy that is working.
Where it actually fails, I still don't understand why.
WORKING SYSTEM
openat(AT_FDCWD, "file.txt", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
close(3) = 0
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
write(1, "Completed successfully\n", 23Completed successfully
) = 23
write(1, "\n", 1
) = 1
FAILING SYSTEM
brk(NULL) = 0x5559121ec000
brk(0x55591220d000) = 0x55591220d000
openat(AT_FDCWD, "file.txt", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
close(3) = 0
writev(2, [{iov_base="free(): double free detected in "..., iov_len=40}, {iov_base="\n", iov_len=1}], 2free(): double free detected in tcache 2
) = 41
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7faddf948000
rt_sigprocmask(SIG_UNBLOCK, [ABRT], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1], [], 8) = 0
The ulimit values only differ because the amount of memory is 64GB on failing system and 128GB on working system. thought maybe it was a memory shortage, but I can run other programs, such as starting Postgres and access a database.
0 Answers