Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH] popen: fix 'may be clobbered' compiler warning
@ 2020-04-10 22:28 Alexander Turenko
  2020-04-11  7:30 ` Cyrill Gorcunov
  0 siblings, 1 reply; 3+ messages in thread
From: Alexander Turenko @ 2020-04-10 22:28 UTC (permalink / raw)
  To: Cyrill Gorcunov; +Cc: tarantool-patches

I guess a compiler assumes that the code inside vfork may use the stack
slot that corresponds the variable and so clobber it. The recent commit
07a07b3cc7b85375d20b3fc6ca1e5060304f337b ('popen: decouple logger fd
from stderr') adds read from this variable after vfork() in the parent
process.

The warning is produced on RelWithDebInfo build with LTO enabled on GCC
9.2.0 (locally) and on GCC 8.3.0 (in CI).

Part of #4031
---

We have -Werror enabled on some jobs in CI, so the warnings fails the CI
status. See https://gitlab.com/tarantool/tarantool/-/jobs/506891936

I verified the build locally and in CI.

https://github.com/tarantool/tarantool/tree/Totktonada/gh-4031-popen-fix-lto-build-full-ci

 src/lib/core/popen.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/lib/core/popen.c b/src/lib/core/popen.c
index 5d0587e00..df7f797b9 100644
--- a/src/lib/core/popen.c
+++ b/src/lib/core/popen.c
@@ -784,10 +784,11 @@ struct popen_handle *
 popen_new(struct popen_opts *opts)
 {
 	/*
-	 * Without volatile compiler claims that
-	 * handle might be clobbered from vfork.
+	 * Without volatile compiler claims that those
+	 * variables might be clobbered from vfork.
 	 */
 	struct popen_handle * volatile handle;
+	int volatile log_fd = -1;
 
 	int pfd[POPEN_FLAG_FD_STDEND_BIT][2] = {
 		{-1, -1}, {-1, -1}, {-1, -1},
@@ -853,7 +854,6 @@ popen_new(struct popen_opts *opts)
 	 * reached a file descriptor limit.
 	 */
 	int old_log_fd = log_get_fd();
-	int log_fd = -1;
 	if (old_log_fd >= 0) {
 		log_fd = dup_not_std_streams(old_log_fd);
 		if (log_fd < 0)
-- 
2.25.0

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Tarantool-patches] [PATCH] popen: fix 'may be clobbered' compiler warning
  2020-04-10 22:28 [Tarantool-patches] [PATCH] popen: fix 'may be clobbered' compiler warning Alexander Turenko
@ 2020-04-11  7:30 ` Cyrill Gorcunov
  2020-04-11  9:38   ` Alexander Turenko
  0 siblings, 1 reply; 3+ messages in thread
From: Cyrill Gorcunov @ 2020-04-11  7:30 UTC (permalink / raw)
  To: Alexander Turenko; +Cc: tarantool-patches

On Sat, Apr 11, 2020 at 01:28:07AM +0300, Alexander Turenko wrote:
> I guess a compiler assumes that the code inside vfork may use the stack
> slot that corresponds the variable and so clobber it. The recent commit
> 07a07b3cc7b85375d20b3fc6ca1e5060304f337b ('popen: decouple logger fd
> from stderr') adds read from this variable after vfork() in the parent
> process.
> 
> The warning is produced on RelWithDebInfo build with LTO enabled on GCC
> 9.2.0 (locally) and on GCC 8.3.0 (in CI).
> 
> Part of #4031
Acked-by: Cyrill Gorcunov <gorcunov@gmail.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Tarantool-patches] [PATCH] popen: fix 'may be clobbered' compiler warning
  2020-04-11  7:30 ` Cyrill Gorcunov
@ 2020-04-11  9:38   ` Alexander Turenko
  0 siblings, 0 replies; 3+ messages in thread
From: Alexander Turenko @ 2020-04-11  9:38 UTC (permalink / raw)
  To: Cyrill Gorcunov; +Cc: tarantool-patches

On Sat, Apr 11, 2020 at 10:30:26AM +0300, Cyrill Gorcunov wrote:
> On Sat, Apr 11, 2020 at 01:28:07AM +0300, Alexander Turenko wrote:
> > I guess a compiler assumes that the code inside vfork may use the stack
> > slot that corresponds the variable and so clobber it. The recent commit
> > 07a07b3cc7b85375d20b3fc6ca1e5060304f337b ('popen: decouple logger fd
> > from stderr') adds read from this variable after vfork() in the parent
> > process.
> > 
> > The warning is produced on RelWithDebInfo build with LTO enabled on GCC
> > 9.2.0 (locally) and on GCC 8.3.0 (in CI).
> > 
> > Part of #4031
> Acked-by: Cyrill Gorcunov <gorcunov@gmail.com>

Pushed to master.

WBR, Alexander Turenko.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-04-11  9:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-10 22:28 [Tarantool-patches] [PATCH] popen: fix 'may be clobbered' compiler warning Alexander Turenko
2020-04-11  7:30 ` Cyrill Gorcunov
2020-04-11  9:38   ` Alexander Turenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox