Git 2.41.0-rc0 - Compile Error ALLOC_GROW
Hi Git Team,
I am getting a compile error on rc0:
ALLOC_GROW(git_atexit_hdlrs.handlers, git_atexit_hdlrs.nr + 1,
git_atexit_hdlrs.alloc);
^
"/home/ituglib/randall/jenkins/.jenkins/workspace/Git_Pipeline/run-command.c ", line 1103: error(114): identifier "ALLOC_GROW" is undefined
Any help o nthis?
Thanks,
Randall
--
Brief whoami: NonStop&UNIX developer since approximately UNIX(421664400)
NonStop(211288444200000000)
-- In real life, I talk too much.
Quoted 11 lines · On Tue, May 16, 2023 at 12:58:15PM -0400, [email protected] wrote:
Hi Git Team,
I am getting a compile error on rc0:
ALLOC_GROW(git_atexit_hdlrs.handlers, git_atexit_hdlrs.nr + 1,
git_atexit_hdlrs.alloc);
^
"/home/ituglib/randall/jenkins/.jenkins/workspace/Git_Pipeline/run-command.c", line 1103: error(114): identifier "ALLOC_GROW" is undefinedAny help o nthis?
None of the code in run-command.c has changed much recently, but this bisects to 36bf195890 (alloc.h: move ALLOC_GROW() functions from cache.h, 2023-02-24).
Note that it only affects when building with NO_PTHREADS=1 (which I suspect is the case on NonStop). Here's the bisection:
$ git bisect start
$ git bisect bad
$ git bisect good v2.40.0
$ git bisect run sh -c 'make DEVELOPER=1 NO_PTHREADS=1 run-command.o'I'll attach a patch in a separate message.
Thanks,
Taylor
Taylor Blau <[email protected]> writes:
Ah, alloc.h was introduced and everybody who took ALLOC_GROW() from git-compat-util.h (or was it cache.h?) now includes it, but apparently Elijah forgot run-command.c and nobody caught this.
I wonder if there are other leftover ones that we haven't caught?
$ git grep -l '[^_]ALLOC_GROW(' \*.c | sort >/var/tmp/1
$ git grep -l 'alloc\.h' \*.c | sort >/var/tmp/2
$ comm -23 /var/tmp/[12]
compat/simple-ipc/ipc-unix-socket.c
run-command.cBut the former one is only in a comment, so it probably is OK.
PATCH 1/1 run-command.c: need alloc.h for our own at-exit handler emulation
Recent header file shuffling missed this old user of ALLOC_GROW() that was inside "#ifdef NO_PTHREADS' section and forgot to include the new file, alloc.h, that defines the macro.
--- run-command.c | 1 + 1 file changed, 1 insertion(+)
run-command.c +1 -0
@@ -1073,6 +1073,7 @@ static void NORETURN async_exit(int code) } #else +#include <alloc.h> static struct { void (**handlers)(void);
RE: [PATCH] run-command.c: need alloc.h for our own at-exit handler emulation
Quoted 1 line · Junio C Hamano
Recent header file shuffling missed this old user of
ALLOC_GROW()that was
inside
Quoted 1 line
"#ifdef
NO_PTHREADS' section and forgot to include the new file,alloc.h,
that defines
w/run-command.c index d4247d5fcc..1affea48af
Quoted 9 lines
the macro.
Signed-off-by Junio C Hamano <[email protected]>---
run-command.c| 1 +1 file changed, 1 insertion(+)w/run-command.c index d4247d5fcc..1affea48af renamed from c/run-command.c +0
-0
100644
run-command.c static void NORETURN async_exit(int code) } · line 1078
Quoted 9 lines
run-command.c +1
-0@@ -1073,6 +1073,7 @@ static void NORETURN async_exit(int code) } #else +#include <alloc.h> static struct { void (**handlers)(void);
Thanks gents.
Regards,
Randall
PATCH 1/1 run-command.c: fix missing include under `NO_PTHREADS`
In reply to Taylor BlauWhen building git with NO_PTHREADS=YesPlease, we fail to build run-command.o since we don't have a definition for ALLOC_GROW:
$ make NO_PTHREADS=1 DEVELOPER=1 run-command.o
GIT_VERSION = 2.41.0.rc0.1.g787eb3beae.dirty
CC run-command.o
run-command.c: In function ‘git_atexit’:
run-command.c:1103:9: error: implicit declaration of function ‘ALLOC_GROW’ [-Werror=implicit-function-declaration]
1103 | ALLOC_GROW(git_atexit_hdlrs.handlers, git_atexit_hdlrs.nr + 1, git_atexit_hdlrs.alloc);
| ^~~~~~~~~~
cc1: all warnings being treated as errors
make: *** [Makefile:2715: run-command.o] Error 1This bisects to 36bf195890 (alloc.h: move ALLOC_GROW() functions from cache.h, 2023-02-24), which replaced includes of "cache.h" with "alloc.h", which is the new home of ALLOC_GROW() (and ALLOC_GROW_BY()).
run-command.c compiles fine when NO_PTHREADS is undefined, since its use of ALLOC_GROW() is behind a #ifndef NO_PTHREADS. (Everything else compiles fine when NO_PTHREADS is defined, so this is the only spot that needs fixing).
We could fix this by conditionally including "alloc.h" when NO_PTHREADS is defined. But we have relatively few examples of conditional includes throughout the tree[^1].
Instead, include "alloc.h" unconditionally in run-command.c to allow it to successfully compile even when NO_PTHREADS is defined.
[^1]: With git grep -E -A1 '#if(n)?def' -- **/*.c | grep '#include' -B1.
--- run-command.c | 1 + 1 file changed, 1 insertion(+)
run-command.c +1 -0
@@ -16,6 +16,7 @@#include "packfile.h" #include "hook.h" #include "compat/nonblock.h" +#include "alloc.h" void child_process_init (struct child_process *child) {
Signature · 1 line
2.41.0.rc0.dirty
Re: [PATCH] run-command.c: need alloc.h for our own at-exit handler emulation
In reply to Junio C HamanoQuoted 3 lines · Junio C Hamano
Recent header file shuffling missed this old user of
ALLOC_GROW()that was inside "#ifdefNO_PTHREADS' section and forgot to include the new file,alloc.h, that defines the macro.
Heh. I wrote an identical patch before lunch (which I just came back from). Feel free to queue either, I honestly do not care which as long as the bug is fixed :-).
https://lore.kernel.org/git/db403de74da839084165f11dab05d71484457c6f.1684259780.git.me@ttaylorr.com/
Thanks,
Taylor
Re: [PATCH] run-command.c: need alloc.h for our own at-exit handler emulation
Quoted 10 lines · Taylor Blau
Quoted 3 lines · Junio C Hamano
Recent header file shuffling missed this old user of
ALLOC_GROW()that was inside "#ifdefNO_PTHREADS' section and forgot to include the new file,alloc.h, that defines the macro.Heh. I wrote an identical patch before lunch (which I just came back from). Feel free to queue either, I honestly do not care which as long as the bug is fixed :-).
https://lore.kernel.org/git/db403de74da839084165f11dab05d71484457c6f.1684259780.git.me@ttaylorr.com/
OK, having now read both completely, I would say I have a vague preference for my version since it keeps the include at the top and unconditional, and has slightly more information in the patch message.
But I do not prefer it so much over yours that I would be sad if you had already queued yours and didn't want to bother shuffling it around.
Thanks,
Taylor
Re: [PATCH] run-command.c: need alloc.h for our own at-exit handler emulation
Quoted 6 lines · Taylor Blau
OK, having now read both completely, I would say I have a vague preference for my version since it keeps the include at the top and unconditional, and has slightly more information in the patch message.
But I do not prefer it so much over yours that I would be sad if you had already queued yours and didn't want to bother shuffling it around.
I do not have much preference between the two, either. Both lack one important description that we are reasonably confident that this breakage is limited to run-command.c and no other files.
Thanks.
Re: [PATCH] run-command.c: need alloc.h for our own at-exit handler emulation
Quoted 6 lines · Junio C Hamano
Quoted 4 lines · Taylor Blau
OK, having now read both completely, I would say I have a vague preference for my version since it keeps the include at the top and unconditional, and has slightly more information in the patch message.
Quoted 6 lines
Quoted 2 lines
But I do not prefer it so much over yours that I would be sad if you had already queued yours and didn't want to bother shuffling it around.
I do not have much preference between the two, either. Both lack one important description that we are reasonably confident that this breakage is limited to
run-command.cand no other files.
I believe that mine does:
(Everything else compiles fine when NO_PTHREADS is defined, so this is the only spot that needs fixing).
Thanks,
Taylor
Re: [PATCH] run-command.c: need alloc.h for our own at-exit handler emulation
Quoted 10 lines · Taylor Blau
Quoted 9 lines · Junio C Hamano
Quoted 6 lines · Taylor Blau
OK, having now read both completely, I would say I have a vague preference for my version since it keeps the include at the top and unconditional, and has slightly more information in the patch message.
But I do not prefer it so much over yours that I would be sad if you had already queued yours and didn't want to bother shuffling it around.
Quoted 8 lines
Quoted 3 lines
I do not have much preference between the two, either. Both lack one important description that we are reasonably confident that this breakage is limited to
run-command.cand no other files.I believe that mine does:
(Everything else compiles fine when
NO_PTHREADSis defined, so this is the only spot that needs fixing).
Not quite. Who says NO_PTHREADS is the only conditional that may hide use of ALLOC_GROW()?
Re: [PATCH] run-command.c: fix missing include under `NO_PTHREADS`
In reply to Taylor BlauQuoted 12 lines · Taylor Blau
When building git with
NO_PTHREADS=YesPlease, we fail to build run-command.o since we don't have a definition forALLOC_GROW:$ make NO_PTHREADS=1 DEVELOPER=1 run-command.o GIT_VERSION = 2.41.0.rc0.1.g787eb3beae.dirty CC run-command.o run-command.c: In function ‘git_atexit’: run-command.c:1103:9: error: implicit declaration of function ‘ALLOC_GROW’ [-Werror=implicit-function-declaration] 1103 | ALLOC_GROW(git_atexit_hdlrs.handlers, git_atexit_hdlrs.nr + 1, git_atexit_hdlrs.alloc); | ^~~~~~~~~~ cc1: all warnings being treated as errors make: *** [Makefile:2715: run-command.o] Error 1
I am OK to give a reproduction recipe, i.e. the "$ make" command line, to make it easy for people, who cannot remember how to define make variables from the command line, to try out themselves, but I hate the "build transcript" in the log message, when a few lines of prose suffices.
How about this?
Git 2.41-rc0 fails to compile run-command.c with NO_PTHREADS defined, i.e.
$ make NO_PTHREADS=1 run-command.o
as ALLOC_GROW() macro is used in the atexit() emulation but the macro definition is not available.
Quoted 4 lines
This bisects to
36bf195890(alloc.h: moveALLOC_GROW()functions fromcache.h, 2023-02-24), which replaced includes of "cache.h" with "alloc.h", which is the new home ofALLOC_GROW()(andALLOC_GROW_BY()).
Good.
Insert something like:
We can see that run-command.c is the only one that try to use these macros without including <alloc.h>.
$ git grep -l -e '[^_]ALLOC_GROW(' -e 'ALLOC_GROW_BY(' \*.c | sort >/tmp/1 $ git grep -l 'alloc\.h' \*.c | sort >/tmp/2
$ comm -23 /tmp/[12]
compat/simple-ipc/ipc-unix-socket.c
run-command.c
The "compat/" file only talks about the macro in the comment, and is not broken.
here. What I am aiming for is to tell readers what they do not have to spend their time on. As we encourage people to make sure to look for other errors that come from the same root cause when making a fix, avoiding duplicated work by telling what they do not have to look at is rather important.
Quoted 4 lines
run-command.ccompiles fine whenNO_PTHREADSis undefined, since its use ofALLOC_GROW()is behind a#ifndef NO_PTHREADS. (Everything else compiles fine whenNO_PTHREADSis defined, so this is the only spot that needs fixing).
I think we can say that, but is probably coered by the three-line summary I gave above.
Quoted 6 lines
We could fix this by conditionally including "
alloc.h" whenNO_PTHREADSis defined. But we have relatively few examples of conditional includes throughout the tree[^1].Instead, include "
alloc.h" unconditionally inrun-command.cto allow it to successfully compile even whenNO_PTHREADSis defined.
Good.
Quoted 1 line
[^1]: With
git grep -E -A1 '#if(n)?def' -- **/*.c | grep '#include' -B1.
Good.
RE: [PATCH] run-command.c: fix missing include under `NO_PTHREADS`
Quoted 69 lines · Junio C Hamano
Quoted 8 lines · Taylor Blau
When building git with
NO_PTHREADS=YesPlease, we fail to build run-command.o since we don't have a definition forALLOC_GROW:$ make NO_PTHREADS=1 DEVELOPER=1 run-command.o GIT_VERSION = 2.41.0.rc0.1.g787eb3beae.dirty CC run-command.o run-command.c: In function ‘git_atexit’: run-command.c:1103:9: error: implicit declaration of function ‘ALLOC_GROW’ [-Werror=implicit-function-declaration]
Quoted 1 line
1103 | ALLOC_GROW(git_atexit_hdlrs.handlers, git_atexit_hdlrs.nr + 1,
git_atexit_hdlrs.alloc);
Quoted 3 lines
| ^~~~~~~~~~ cc1: all warnings being treated as errors make: *** [Makefile:2715: run-command.o] Error 1I am OK to give a reproduction recipe, i.e. the "$ make" command line, to make it easy for people, who cannot remember how to define make variables from the command line, to try out themselves, but I hate the "build transcript" in the log message, when a few lines of prose suffices.
How about this?
Git 2.41-rc0 fails to compile
run-command.cwithNO_PTHREADSdefined, i.e.$ make NO_PTHREADS=1 run-command.oas
ALLOC_GROW()macro is used in theatexit()emulation but the macro definition is not available.Quoted 4 lines
This bisects to
36bf195890(alloc.h: moveALLOC_GROW()functions fromcache.h, 2023-02-24), which replaced includes of "cache.h" with "alloc.h", which is the new home ofALLOC_GROW()(andALLOC_GROW_BY()).Good.
Insert something like:We can see that
run-command.cis the only one that try to use these macros without including <alloc.h>.$ git grep -l -e '[^_]ALLOC_GROW(' -e 'ALLOC_GROW_BY(' \*.c | sort >/tmp/1 $ git grep -l 'alloc\.h' \*.c | sort >/tmp/2 $ comm -23 /tmp/[12] compat/simple-ipc/ipc-unix-socket.c run-command.cThe "compat/" file only talks about the macro in the comment, and is not broken.
here. What I am aiming for is to tell readers what they do not have to spend their time on. As we encourage people to make sure to look for other errors that come from the same root cause when making a fix, avoiding duplicated work by telling what they do not have to look at is rather important.
Quoted 4 lines
run-command.ccompiles fine whenNO_PTHREADSis undefined, since its use ofALLOC_GROW()is behind a#ifndef NO_PTHREADS. (Everything else compiles fine whenNO_PTHREADSis defined, so this is the only spot that needs fixing).I think we can say that, but is probably coered by the three-line summary I gave above.
Quoted 4 lines
We could fix this by conditionally including "
alloc.h" whenNO_PTHREADSis defined. But we have relatively few examples of conditional includes throughout the tree[^1].
Quoted 8 lines
Quoted 2 lines
Instead, include "
alloc.h" unconditionally inrun-command.cto allow it to successfully compile even whenNO_PTHREADSis defined.Good.
Quoted 1 line
[^1]: With
git grep -E -A1 '#if(n)?def' -- **/*.c | grep '#include' -B1.Good.
This all makes sense to me.
Re: [PATCH] run-command.c: fix missing include under `NO_PTHREADS`
In reply to Junio C HamanoQuoted 15 lines · Junio C Hamano
Quoted 12 lines · Taylor Blau
When building git with
NO_PTHREADS=YesPlease, we fail to build run-command.o since we don't have a definition forALLOC_GROW:$ make NO_PTHREADS=1 DEVELOPER=1 run-command.o GIT_VERSION = 2.41.0.rc0.1.g787eb3beae.dirty CC run-command.o run-command.c: In function ‘git_atexit’: run-command.c:1103:9: error: implicit declaration of function ‘ALLOC_GROW’ [-Werror=implicit-function-declaration] 1103 | ALLOC_GROW(git_atexit_hdlrs.handlers, git_atexit_hdlrs.nr + 1, git_atexit_hdlrs.alloc); | ^~~~~~~~~~ cc1: all warnings being treated as errors make: *** [Makefile:2715: run-command.o] Error 1
Quoted 5 lines
I am OK to give a reproduction recipe, i.e. the "$ make" command line, to make it easy for people, who cannot remember how to define make variables from the command line, to try out themselves, but I hate the "build transcript" in the log message, when a few lines of prose suffices.
Much appreciated. Here's a version with your changes include that is suitable for queueing:
--- 8< ---
Subject: [PATCH] run-command.c: fix missing include under NO_PTHREADS
Git 2.41-rc0 fails to compile run-command.c with NO_PTHREADS defined, i.e.
$ make NO_PTHREADS=1 run-command.o
as ALLOC_GROW() macro is used in the atexit() emulation but the macro definition is not available.
This bisects to 36bf195890 (alloc.h: move ALLOC_GROW() functions from cache.h, 2023-02-24), which replaced includes of <cache.h> with <alloc.h>, which is the new home of ALLOC_GROW() (and ALLOC_GROW_BY()).
We can see that run-command.c is the only one that try to use these macros without including <alloc.h>.
$ git grep -l -e '[^_]ALLOC_GROW(' -e 'ALLOC_GROW_BY(' \*.c | sort >/tmp/1
$ git grep -l 'alloc\.h' \*.c | sort >/tmp/2
$ comm -23 /tmp/[12]
compat/simple-ipc/ipc-unix-socket.c
run-command.cThe "compat/" file only talks about the macro in the comment, and is not broken.
We could fix this by conditionally including "alloc.h" when NO_PTHREADS is defined. But we have relatively few examples of conditional includes throughout the tree[^1].
Instead, include "alloc.h" unconditionally in run-command.c to allow it to successfully compile even when NO_PTHREADS is defined.
[^1]: With git grep -E -A1 '#if(n)?def' -- **/*.c | grep '#include' -B1.
--- run-command.c | 1 + 1 file changed, 1 insertion(+)
run-command.c +1 -0
@@ -16,6 +16,7 @@#include "packfile.h" #include "hook.h" #include "compat/nonblock.h" +#include "alloc.h" void child_process_init (struct child_process *child) {
--
2.41.0.rc0.dirty
Re: [PATCH] run-command.c: fix missing include under `NO_PTHREADS`
Quoted 85 lines · Taylor Blau
Quoted 15 lines · Junio C Hamano
Quoted 12 lines · Taylor Blau
When building git with
NO_PTHREADS=YesPlease, we fail to build run-command.o since we don't have a definition forALLOC_GROW:$ make NO_PTHREADS=1 DEVELOPER=1 run-command.o GIT_VERSION = 2.41.0.rc0.1.g787eb3beae.dirty CC run-command.o run-command.c: In function ‘git_atexit’: run-command.c:1103:9: error: implicit declaration of function ‘ALLOC_GROW’ [-Werror=implicit-function-declaration] 1103 | ALLOC_GROW(git_atexit_hdlrs.handlers, git_atexit_hdlrs.nr + 1, git_atexit_hdlrs.alloc); | ^~~~~~~~~~ cc1: all warnings being treated as errors make: *** [Makefile:2715: run-command.o] Error 1Quoted 5 lines
I am OK to give a reproduction recipe, i.e. the "$ make" command line, to make it easy for people, who cannot remember how to define make variables from the command line, to try out themselves, but I hate the "build transcript" in the log message, when a few lines of prose suffices.
Much appreciated. Here's a version with your changes include that is suitable for queueing:
--- 8< ---
Subject: [PATCH]
run-command.c: fix missing include underNO_PTHREADSGit 2.41-rc0 fails to compile
run-command.cwithNO_PTHREADSdefined, i.e.$ make NO_PTHREADS=1 run-command.oas
ALLOC_GROW()macro is used in theatexit()emulation but the macro definition is not available.This bisects to
36bf195890(alloc.h: moveALLOC_GROW()functions fromcache.h, 2023-02-24), which replaced includes of <cache.h> with <alloc.h>, which is the new home ofALLOC_GROW()(andALLOC_GROW_BY()).We can see that
run-command.cis the only one that try to use these macros without including <alloc.h>.$ git grep -l -e '[^_]ALLOC_GROW(' -e 'ALLOC_GROW_BY(' \*.c | sort >/tmp/1 $ git grep -l 'alloc\.h' \*.c | sort >/tmp/2 $ comm -23 /tmp/[12] compat/simple-ipc/ipc-unix-socket.c run-command.cThe "compat/" file only talks about the macro in the comment, and is not broken.
We could fix this by conditionally including "
alloc.h" whenNO_PTHREADSis defined. But we have relatively few examples of conditional includes throughout the tree[^1].Instead, include "
alloc.h" unconditionally inrun-command.cto allow it to successfully compile even whenNO_PTHREADSis defined.[^1]: With
git grep -E -A1 '#if(n)?def' -- **/*.c | grep '#include' -B1.Reported-by Randall S. Becker <[email protected]>Co-authored-by Junio C Hamano <[email protected]>Signed-off-by Junio C Hamano <[email protected]>Signed-off-by Taylor Blau <[email protected]>--- run-command.c | 1 + 1 file changed, 1 insertion(+)run-command.c +1
-1@@ -16,6 +16,7 @@#include "packfile.h" #include "hook.h" #include "compat/nonblock.h" +#include "alloc.h" void child_process_init (struct child_process *child) { --
Quoted 1 line
2.41.0.rc0.dirty
Thanks everyone for fixing up my issue, and my other issue in the imap-send/strbuf.h thread. Sorry for any headaches.