bugmake - Bugs: bug #63045, Make crashes when makefile keeps...

 
 

bug #63045: Make crashes when makefile keeps the loaded shared object intact.

Submitter:  Dmitry Goncharov <dgoncharov>
Submitted:  Sun 11 Sep 2022 03:13:13 AM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  Fixed Privacy:  Public
Assigned to:  None Open/Closed:  Closed
Component Version:  4.3 Operating System:  POSIX-Based
Fixed Release:  4.4 Triage Status:  Medium Effort
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 12 Sep 2022 06:09:56 AM UTC, comment #2: 

Applied; thanks Dmitry!

Paul D. Smith <psmith>
Group administrator
Sun 11 Sep 2022 03:14:47 AM UTC, comment #1: 

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.


Dmitry Goncharov <dgoncharov>
Sun 11 Sep 2022 03:13:13 AM UTC, original submission:  

.

Dmitry Goncharov <dgoncharov>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #53678:  sv63045_fix.diff added by dgoncharov (12KiB - text/x-patch)
file #53679:  sv63045_test.diff added by dgoncharov (4KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by psmith (Posted a comment)
  • -email is unavailable- added by dgoncharov (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-09-12 psmith StatusNone Fixed
        Open/ClosedOpen Closed
        Component Version4.4 4.3
        Fixed ReleaseNone 4.4
        Triage StatusNone Medium Effort
    2022-09-11 dgoncharov Attached File- Added sv63045_fix.diff, #53678
        Attached File- Added sv63045_test.diff, #53679

    Back to the top

    Powered by Savane 3.13-da57.
    Corresponding source code