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!



Crash in hash_free_items()

2022-12-30 Thread Gisle Vanem

Hello list.

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.

I've a hard time creating a minimal example, but running
with max debug (make --debug=verbose), I see this:

Considering target file 'objects/oleview.res'.
 File 'objects/oleview.res' does not exist.
Directory objects cache invalidated (count 1 != command 42)
Directory . cache invalidated (count 40 != command 42)
  Considering target file 'oleview.rc'.
Directory RCS cache invalidated (count 40 != command 42)
Directory ./objects cache invalidated (count 0 != command 42)

--

What does 'count 0' means?

So just sensing 'ctr == 0' is important, I did this:

--- a/dir.c 2022-11-27 02:43:12
+++ b/dir.c 2022-12-30 11:18:00
@@ -493,7 +493,7 @@
   DB (DB_VERBOSE, ("Directory %s cache invalidated (count %lu != command 
%lu)\n",
name, ctr, command_count));

-  if (dir->contents)
+  if (dir->contents && ctr > 0)
 clear_directory_contents (dir->contents);
 }
   else

---


and no more crash in that special Makefile.

--
--gv