Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] Pass envp to posix_spawn in ld_logger #4146

Merged
merged 1 commit into from
May 2, 2024

Conversation

bruntib
Copy link
Contributor

@bruntib bruntib commented Jan 4, 2024

GNU make 4.3 uses posix_spawn() for initiating recursive make calls in subdirectories:

make -C <subdirectory>

Since we overwrote posix_spawn() through LD_PRELOAD and we didn't forward environment variables to the subprocess, the build of the submodule didn't get the environment variables set by a Makefile. This commit fixes this issue so the logging phase behaves the same way as the original build.

Fixes #3860

Comment on lines -49 to -54
/* \
Note that envp is not passed through (which would be the environment that \
that the process will be spawned it), but is replaced by environ, which is \
a global variable that stores our environment. We added quite a few \
variables into it, and for some reason, they are not present in envp. \
*/ \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a while since I wrote this, but I recall that some codechecker (CC_*) and logger related variables were not present in envp, but should've been. Can you verify thats not an issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, which environment variable was involved in your case, but this function call blocked the forwarding of all environment variable. I assume, this cc_ was among them too.

@whisperity whisperity changed the title [fix] Pass argp to posix_spawn in ld_logger [fix] Pass argp to posix_spawn in ld_logger Mar 21, 2024
@whisperity whisperity changed the title [fix] Pass argp to posix_spawn in ld_logger [fix] Pass envp to posix_spawn in ld_logger Mar 21, 2024
@bruntib bruntib requested a review from Szelethus March 21, 2024 11:56
Copy link
Contributor

@whisperity whisperity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test for this?

Something along the lines of a Makefile which calls gcc ${ENVIRONMENT_VARIABLE} and a /usr/bin/env ENVIRONMENT_VARIABLE=foo.cpp CodeChecker log -b "make"?

@whisperity whisperity added the tools 🛠️ Meta-tag for all the additional tools supplied with CodeChecker: plist2html, tu_collector, etc. label Mar 27, 2024
@bruntib bruntib force-pushed the logger_env_posix_spawn branch 3 times, most recently from f7c5a9a to 5e72ecf Compare April 3, 2024 13:04
GNU make 4.3 uses posix_spawn() for initiating recursive make calls
in subdirectories:

make -C <subdirectory>

Since we overwrote posix_spawn() through LD_PRELOAD and we didn't
forward environment variables to the subprocess, the build of the
submodule didn't get the environment variables set by a Makefile.
This commit fixes this issue so the logging phase behaves the same
way as the original build.

Fixes Ericsson#3860
@bruntib bruntib force-pushed the logger_env_posix_spawn branch from 5e72ecf to 32e4366 Compare April 3, 2024 13:06
@bruntib bruntib requested a review from whisperity April 3, 2024 13:08
@bruntib bruntib merged commit 9a15a36 into Ericsson:master May 2, 2024
7 of 8 checks passed
@bruntib bruntib deleted the logger_env_posix_spawn branch May 7, 2024 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix 🔨 ld-logger 📃 tools 🛠️ Meta-tag for all the additional tools supplied with CodeChecker: plist2html, tu_collector, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

«log» sometimes does not put in "file": the subpath
3 participants