Follow-up Comment #1, bug #63045 (project make): Make crashes when makefile keeps the loaded shared object intact.
In this makefile make loads shared object hello.so, then unloads it in order to rebuild. The rule provided by the makefile keeps the shared object intact. Make does not re-execute itself and does not load the shared object. Make proceeds and attempts to call a function from this unloaded shared object and crashes. The patch in the attachment causes make to load the unloaded shared object again, if the rule keep the shared object intact. ++++ $ ls hello.c makefile $ cat hello.c #include <stdio.h> #include <gnumake.h> int plugin_is_GPL_compatible; static char * hello (const char *nm, unsigned int argc, char **argv) { printf ("hello world\n"); return 0; } int hello_gmk_setup () { gmk_add_function ("hello", hello, 1, 1, 1); return 1; } $ gcc -o hello.so -shared -fPIC hello.c $ cat makefile load hello.so all:; $(hello world) hello.so: force; : force:; .PHONY: force $ make-4.3 : Segmentation fault (core dumped) ---- Another, unrelated bug, but reported here in the same bug report, because the fixes for both bugs touch the same code. Make loads a shared object multiple times, if the setup routine returns -1. ++++ $ cat hello.c #include <stdio.h> #include <gnumake.h> int plugin_is_GPL_compatible; int hello_gmk_setup (const gmk_floc *floc) { printf ("hello plugin loaded from %s:%ld\n", floc->filenm, floc->lineno); return -1; } $ cat makefile -load hello.so -load hello.so load hello.so $(eval -load hello.so) $(eval load hello.so) all:; $(info $@) $ gcc -o hello.so -shared -fPIC hello.c $ make-4.3 hello plugin loaded from makefile:1 hello plugin loaded from makefile:2 hello plugin loaded from makefile:3 hello plugin loaded from makefile:4 hello plugin loaded from makefile:5 all make-4.3: 'all' is up to date. ---- _______________________________________________________ Reply to this item at: <https://savannah.gnu.org/bugs/?63045> _______________________________________________ Message sent via Savannah https://savannah.gnu.org/