m4 crashes during exit when compiled with -fprofile-generate. m4 closes all standard streams in an atexit handler (close_stdin from gnulib) which results in _IO_list_all == NULL. The gcov destructor function then opens a file to write out the profiling data which crashes here: 122 _IO_list_all->file._prevchain = &fp->file._chain;
#include <stdio.h> static void close_stdin (void) { fclose (stdin); fclose (stdout); fclose (stderr); } static void final (void) { FILE *f = fopen ("/dev/null", "w"); fprintf (f, "final\n"); fclose (f); } int main (void) { close_stdin (); final (); }
There's two semantically equivalent patches: * https://inbox.sourceware.org/libc-alpha/mvmwmlwgf66.fsf@suse.de/T/#u * https://inbox.sourceware.org/libc-alpha/20240708220201.3252178-1-hjl.tools@gmail.com/
Fixed in commit 2213b37b70.