Re: Crash in hash_free_items()

2023-01-01 Thread Paul Smith
On Fri, 2022-12-30 at 11:34 +0100, Gisle Vanem wrote:
> I'm using the very latest GNU-make built on Win-10 by myself.
> Except I've disabled the call to 'SetUnhandledExceptionFilter()'.
> 
> In one particular Wine Makefile I get a crash in 'hash_free_items()':
>    gnumake!hash_free_items+0x22
>    gnumake!hash_free+0x30
>    gnumake!clear_directory_contents+0x34
>    gnumake!find_directory+0xed
>    gnumake!dir_file_exists_p+0xd
>    gnumake!selective_vpath_search+0x239
>    gnumake!vpath_search+0x9d
>    gnumake!pattern_search+0x1212
> ...
> 
> This is when creating an .res-file from a .rc-file.
> And I use this 'vpath %.rc obj' construct.

Can you try the following patch (after removing your change checking
the value of "ctr") and see if it solves the problem?

diff --git a/src/dir.c b/src/dir.c
index 1e6e7397..7a884d28 100644
--- a/src/dir.c
+++ b/src/dir.c
@@ -283,7 +283,8 @@ clear_directory_contents (struct directory_contents *dc)
   closedir (dc->dirstream);
   dc->dirstream = 0;
 }
-  hash_free (>dirfiles, 1);
+  if (dc->dirfiles.ht_vec != NULL)
+hash_free (>dirfiles, 1);

   return NULL;
 }




Re: Crash in hash_free_items()

2022-12-31 Thread Paul Smith
On Fri, 2022-12-30 at 11:34 +0100, Gisle Vanem wrote:
> I'm using the very latest GNU-make built on Win-10 by myself.

Thanks for this report.  Can you please be more clear about what you
mean by "the very latest"?  Do you mean the latest release 4.4?  Or do
you mean the latest code of the head of the Git branch?  If the latter
can you specify which SHA?

I don't think checking this count is the correct solution; if there's a
crash here it probably means we have either an uninitialized value, or
freeing memory twice.

Any information you can provide about the crash would be helpful.  Can
you provide information on which line in hash_free_items() actually
failed, and what kind of crash you got?

A repro case would be ideal but if that's too difficult we can try to
investigate remotely.

Thanks!