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

ZOOKEEPER-3954: C client: GCC 10 compilation fixes #1481

Closed

Conversation

ztzg
Copy link
Contributor

@ztzg ztzg commented Oct 5, 2020

The most important change in this PR avoids a confusing and scary compilation issue encountered by Michael Hudson-Doyle when building the C client with GCC 10 and "aggressive" optimization settings:

free_auth_completions is being inlined into free_completions, and this lets gcc see that members of a_list are being accessed without initialization

This is (fortunately!) a red herring: what GCC doesn't see is that, in practice, zoo_lock_auth always returns zero, and that a_list is always initialized in the conditional block which follows it.

That issue is easily "fixed" by removing the if. The rest of the client code doesn't check zoo_lock_auth's return value--and we have bigger issues if unconditional locks start failing anyway.

The remaining changes get rid of a couple of innocuous warnings, to that the client can successfully build even when configured with -Werror.

…ining

Michael Hudson-Doyle experienced an error while compiling the C client
with GCC 10 and "aggressive" optimization settings:

> 'free_auth_completions' is being inlined into 'free_completions',
> and this lets gcc see that members of 'a_list' are being accessed
> without initialization

This is (fortunately!) a red herring: what GCC doesn't see is that, in
practice, 'zoo_lock_auth' always returns zero, and that 'a_list' is
always initialized in the conditional block which follows it.

Let's "fix" this by removing the 'if'.  The rest of the client code
doesn't check 'zoo_lock_auth's return value--and we have bigger issues
if unconditional locks start failing anyway.
The "unused" function causes a warning in GCC 10, which in turn causes
the build to fail when '-Werror' is enabled (as in the ticket's
compilation log excerpt).
The unused variable causes a warning in GCC 10, which in turn causes
the build to fail when '-Werror' is enabled (as in the ticket's
compilation log excerpt).
@ztzg
Copy link
Contributor Author

ztzg commented Oct 5, 2020

This PR is against the 3.5 branch, but the commits, once reviewed, should also be cherry-picked to 3.6 and (partially) to master. (Only the first commit is necessary on master; the other two create trivial conflicts because they have already been fixed there.)

Cc: @mwhudson, @eolivelli, @symat.

@eolivelli
Copy link
Contributor

The best practice is to send the PR against master, then send amended patches for other active branches when needed.

Btw thank you very much for this fix.

Please send the patch for master as well

@ztzg
Copy link
Contributor Author

ztzg commented Oct 6, 2020

The best practice is to send the PR against master, then send amended patches for other active branches when needed.

Okay; here is a patch against master and one against branch-3.6.

Copy link
Contributor

@symat symat left a comment

Choose a reason for hiding this comment

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

LGTM, +1
(I'm not sure if you need separate PRs for branch-3.5 and branch-3.6 if the cherrypick is clean. but anyway, this way we had CI running on all branches, which never hurt)

@ztzg
Copy link
Contributor Author

ztzg commented Oct 9, 2020

Okay, noted. (But in this case, I just thought I'd push the branch as I had created it for testing anyway.)

asfgit pushed a commit that referenced this pull request Oct 12, 2020
The in this PR avoids a confusing and scary compilation issue [encountered by Michael Hudson-Doyle](https://issues.apache.org/jira/browse/ZOOKEEPER-3954) when building the C client with GCC 10 and "aggressive" optimization settings:

> `free_auth_completions` is being inlined into `free_completions`, and this lets gcc see that members of `a_list` are being accessed without initialization

This is (fortunately!) a red herring: what GCC doesn't see is that, in practice, `zoo_lock_auth` always returns zero, and that `a_list` is always initialized in the conditional block which follows it.

That issue is easily "fixed" by removing the `if`.  The rest of the client code doesn't check `zoo_lock_auth`'s return value--and we have bigger issues if unconditional locks start failing anyway.

See also #1481 and #1486.

Author: Damien Diederen <dd@crosstwine.com>

Reviewers: Enrico Olivelli <eolivelli@apache.org>, Mate Szalay-Beko <symat@apache.org>

Closes #1487 from ztzg/ZOOKEEPER-3954-gcc10-compilation-fixes-master
asfgit pushed a commit that referenced this pull request Oct 12, 2020
The most important change in this PR avoids a confusing and scary compilation issue [encountered by Michael Hudson-Doyle](https://issues.apache.org/jira/browse/ZOOKEEPER-3954) when building the C client with GCC 10 and "aggressive" optimization settings:

> `free_auth_completions` is being inlined into `free_completions`, and this lets gcc see that members of `a_list` are being accessed without initialization

This is (fortunately!) a red herring: what GCC doesn't see is that, in practice, `zoo_lock_auth` always returns zero, and that `a_list` is always initialized in the conditional block which follows it.

That issue is easily "fixed" by removing the `if`.  The rest of the client code doesn't check `zoo_lock_auth`'s return value--and we have bigger issues if unconditional locks start failing anyway.

The remaining changes get rid of a couple of innocuous warnings, to that the client can successfully build even when configured with `-Werror`.

See also #1481.

Author: Damien Diederen <dd@crosstwine.com>

Reviewers: Mate Szalay-Beko <symat@apache.org>

Closes #1486 from ztzg/ZOOKEEPER-3954-gcc10-compilation-fixes-3.6
asfgit pushed a commit that referenced this pull request Oct 12, 2020
The most important change in this PR avoids a confusing and scary compilation issue [encountered by Michael Hudson-Doyle](https://issues.apache.org/jira/browse/ZOOKEEPER-3954) when building the C client with GCC 10 and "aggressive" optimization settings:

> `free_auth_completions` is being inlined into `free_completions`, and this lets gcc see that members of `a_list` are being accessed without initialization

This is (fortunately!) a red herring: what GCC doesn't see is that, in practice, `zoo_lock_auth` always returns zero, and that `a_list` is always initialized in the conditional block which follows it.

That issue is easily "fixed" by removing the `if`.  The rest of the client code doesn't check `zoo_lock_auth`'s return value--and we have bigger issues if unconditional locks start failing anyway.

The remaining changes get rid of a couple of innocuous warnings, to that the client can successfully build even when configured with `-Werror`.

Author: Damien Diederen <dd@crosstwine.com>

Reviewers: Mate Szalay-Beko <symat@apache.org>

Closes #1481 from ztzg/ZOOKEEPER-3954-gcc10-compilation-fixes
@symat symat closed this Oct 12, 2020
RokLenarcic pushed a commit to RokLenarcic/zookeeper that referenced this pull request Aug 31, 2022
The in this PR avoids a confusing and scary compilation issue [encountered by Michael Hudson-Doyle](https://issues.apache.org/jira/browse/ZOOKEEPER-3954) when building the C client with GCC 10 and "aggressive" optimization settings:

> `free_auth_completions` is being inlined into `free_completions`, and this lets gcc see that members of `a_list` are being accessed without initialization

This is (fortunately!) a red herring: what GCC doesn't see is that, in practice, `zoo_lock_auth` always returns zero, and that `a_list` is always initialized in the conditional block which follows it.

That issue is easily "fixed" by removing the `if`.  The rest of the client code doesn't check `zoo_lock_auth`'s return value--and we have bigger issues if unconditional locks start failing anyway.

See also apache#1481 and apache#1486.

Author: Damien Diederen <dd@crosstwine.com>

Reviewers: Enrico Olivelli <eolivelli@apache.org>, Mate Szalay-Beko <symat@apache.org>

Closes apache#1487 from ztzg/ZOOKEEPER-3954-gcc10-compilation-fixes-master
RokLenarcic pushed a commit to RokLenarcic/zookeeper that referenced this pull request Aug 31, 2022
The in this PR avoids a confusing and scary compilation issue [encountered by Michael Hudson-Doyle](https://issues.apache.org/jira/browse/ZOOKEEPER-3954) when building the C client with GCC 10 and "aggressive" optimization settings:

> `free_auth_completions` is being inlined into `free_completions`, and this lets gcc see that members of `a_list` are being accessed without initialization

This is (fortunately!) a red herring: what GCC doesn't see is that, in practice, `zoo_lock_auth` always returns zero, and that `a_list` is always initialized in the conditional block which follows it.

That issue is easily "fixed" by removing the `if`.  The rest of the client code doesn't check `zoo_lock_auth`'s return value--and we have bigger issues if unconditional locks start failing anyway.

See also apache#1481 and apache#1486.

Author: Damien Diederen <dd@crosstwine.com>

Reviewers: Enrico Olivelli <eolivelli@apache.org>, Mate Szalay-Beko <symat@apache.org>

Closes apache#1487 from ztzg/ZOOKEEPER-3954-gcc10-compilation-fixes-master
RokLenarcic pushed a commit to RokLenarcic/zookeeper that referenced this pull request Aug 31, 2022
The in this PR avoids a confusing and scary compilation issue [encountered by Michael Hudson-Doyle](https://issues.apache.org/jira/browse/ZOOKEEPER-3954) when building the C client with GCC 10 and "aggressive" optimization settings:

> `free_auth_completions` is being inlined into `free_completions`, and this lets gcc see that members of `a_list` are being accessed without initialization

This is (fortunately!) a red herring: what GCC doesn't see is that, in practice, `zoo_lock_auth` always returns zero, and that `a_list` is always initialized in the conditional block which follows it.

That issue is easily "fixed" by removing the `if`.  The rest of the client code doesn't check `zoo_lock_auth`'s return value--and we have bigger issues if unconditional locks start failing anyway.

See also apache#1481 and apache#1486.

Author: Damien Diederen <dd@crosstwine.com>

Reviewers: Enrico Olivelli <eolivelli@apache.org>, Mate Szalay-Beko <symat@apache.org>

Closes apache#1487 from ztzg/ZOOKEEPER-3954-gcc10-compilation-fixes-master
RokLenarcic pushed a commit to RokLenarcic/zookeeper that referenced this pull request Sep 3, 2022
The in this PR avoids a confusing and scary compilation issue [encountered by Michael Hudson-Doyle](https://issues.apache.org/jira/browse/ZOOKEEPER-3954) when building the C client with GCC 10 and "aggressive" optimization settings:

> `free_auth_completions` is being inlined into `free_completions`, and this lets gcc see that members of `a_list` are being accessed without initialization

This is (fortunately!) a red herring: what GCC doesn't see is that, in practice, `zoo_lock_auth` always returns zero, and that `a_list` is always initialized in the conditional block which follows it.

That issue is easily "fixed" by removing the `if`.  The rest of the client code doesn't check `zoo_lock_auth`'s return value--and we have bigger issues if unconditional locks start failing anyway.

See also apache#1481 and apache#1486.

Author: Damien Diederen <dd@crosstwine.com>

Reviewers: Enrico Olivelli <eolivelli@apache.org>, Mate Szalay-Beko <symat@apache.org>

Closes apache#1487 from ztzg/ZOOKEEPER-3954-gcc10-compilation-fixes-master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants