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

Build Failure becuase in map.h, the BucketNumber type is not specified. #12391

Closed
sanchayanghosh opened this issue Apr 2, 2023 · 2 comments
Closed
Assignees
Labels

Comments

@sanchayanghosh
Copy link

sanchayanghosh commented Apr 2, 2023

What version of protobuf and what language are you using?
Version: main/v3.6.0/v3.5.0 etc. (NOTE: please try updating to the latest version of protoc/runtime possible beforehand to attempt to resolve your problem)
Language: C++/Java/Python/C#/Ruby/PHP/Objective-C/Javascript

What operating system (Linux, Windows, ...) and version?

[bob@bob-systemproductname ~]$ uname -a
Linux bob-systemproductname 5.15.89-1-MANJARO #1 SMP PREEMPT Wed Jan 18 20:37:11 UTC 2023 x86_64 GNU/Linux
[bob@bob-systemproductname ~]$ 

Manjaro here has been given a full system update as of yesterday

What runtime / compiler are you using (e.g., python version or gcc version)

[bob@bob-systemproductname dependencies]$ gcc --version
gcc (GCC) 12.2.1 20230111
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[bob@bob-systemproductname dependencies]$ llvm --version
bash: llvm: command not found
[bob@bob-systemproductname dependencies]$ clang --version
clang version 15.0.7
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
[bob@bob-systemproductname dependencies]$ python --version
Python 3.10.9
[bob@bob-systemproductname dependencies]$ 

What did you do?
Steps to reproduce the behavior:

  1. Go to the bazel root build directory
  2. Try to build the protobuf_python target using the bazel command
bazel clean --expunge
     bazel build --sandbox_debug //:protobuf_python

(The entire log is attached here

What did you expect to see

Build completed successfully without errors.

What did you see instead?

     bazel-out/k8-opt-exec-2B5CBBC6/bin/src/google/protobuf/_virtual_includes/protobuf_lite/google/protobuf/map.h:1014:32: error: 'unsigned-integer-overflow' attribute directive ignored [-Werror=attributes]
 1014 |       BucketNumber(const K& k) const {
      |                                ^~~~~
cc1plus: all warnings being treated as errors

Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

Anything else we should know about your project / environment

Triaging the issue

In the file, protobuf/src/google/protobuf/map.h

  // size_type PROTOBUF_NO_SANITIZE("unsigned-integer-overflow")
    uint64_t  BucketNumber(const K& k) const {
    // We xor the hash value against the random seed so that we effectively
    // have a random hash function.
    uint64_t h = hash_function()(k) ^ seed_;

    // We use the multiplication method to determine the bucket number from
    // the hash value. The constant kPhi (suggested by Knuth) is roughly
    // (sqrt(5) - 1) / 2 * 2^64.
    constexpr uint64_t kPhi = uint64_t{0x9e3779b97f4a7c15};
    return ((kPhi * h) >> 32) & (num_buckets_ - 1);
  }

Here, when we allow integer sanitization, and provide a return type of uint64_t, the build succeeds.

@sanchayanghosh sanchayanghosh added the untriaged auto added to all issues by default when created. label Apr 2, 2023
sanchayanghosh added a commit to sanchayanghosh/protobuf that referenced this issue Apr 2, 2023
sanchayanghosh added a commit to sanchayanghosh/protobuf that referenced this issue Apr 2, 2023
@sanchayanghosh
Copy link
Author

Here is the success log, after making the changes -

1680429205.910746370: src/main/tools/linux-sandbox-pid1.cc:556: child exited normally with code 0
1680429205.910955021: src/main/tools/linux-sandbox.cc:233: child exited normally with code 0
Target //python:protobuf_python up-to-date (nothing to build)
INFO: Elapsed time: 32.073s, Critical Path: 20.73s
INFO: 388 processes: 61 internal, 327 linux-sandbox.
INFO: Build completed successfully, 388 total actions
[bob@bob-systemproductname protobuf]$ 

Please find the full log
success_log.log

sanchayanghosh added a commit to sanchayanghosh/protobuf that referenced this issue Apr 2, 2023
@fowles fowles added c++ and removed untriaged auto added to all issues by default when created. labels Apr 17, 2023
@acozzette
Copy link
Member

This was fixed in b9e056f.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants