https://github.com/antirez/redis/blob/8f5c2bc8aa79985f6767e4847cc5a5d9606b1b5c/src/rdb.c#L1307
in rdbSave(char filename, rdbSaveInfo rsi), If first fclose() return EOF, function goto werr, excute fclose() again.
But the Linux Programmer's Manual indicate that any further access (including another call to fclose()) to the stream results in undefined behavior.
It is possible that A segfault or any error occurred.
Linux Programmer's Manual ###
FCLOSE(3) Linux Programmer's Manual FCLOSE(3)
NAME fclose - close a stream
SYNOPSIS
#include
int fclose(FILE *stream);
DESCRIPTION The fclose() function flushes the stream pointed to by stream (writing any buffered output data using fflush(3)) and closes the underlying file descriptor.
The behaviour of fclose() is undefined if the stream parameter is an
illegal pointer, or is a descriptor already passed to a previous invo‐
cation of fclose().
RETURN VALUE Upon successful completion 0 is returned. Otherwise, EOF is returned and errno is set to indicate the error. In either case any further access (including another call to fclose()) to the stream results in undefined behavior.
Comment From: hwware
@luoyuyan hello, thank you for reporting this issue, in my point of view this make sense to me, I just opened a pr for fix this..
Comment From: hwware
pinging @oranagra regarding this issue and fix.