https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111413
Bug ID: 111413 Summary: libgomp >= 13 segfault on loading if environ is NULL Product: gcc Version: og13 (devel/omp/gcc-13) Status: UNCONFIRMED Severity: normal Priority: P3 Component: libgomp Assignee: unassigned at gcc dot gnu.org Reporter: silvio at traversaro dot it CC: jakub at gcc dot gnu.org Target Milestone: --- Created attachment 55900 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55900&action=edit Example to reproduce the issue, compile with gcc -ldl test_gomp_segfault.c -o test_gomp_segfault Since release 13, it seems that libgomp fails on loading in the environ global variable is NULL, for example if clearenv (https://man7.org/linux/man-pages/man3/clearenv.3.html) was called before a dlopen. The problem seems in https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libgomp/env.c;hb=73a0d3bf895b5c322676178a51ac0d68cf603953#l2227, where `environ` is dereferenced without first checking if it is NULL. A minimal reproducer is attached to the issue, that can be compiled and run as: gcc -ldl test_gomp_segfault.c -o test_gomp_segfault ./test_gomp_segfault