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

[Question]: About some alerts in code #368

Closed
Milerius opened this issue Aug 17, 2019 · 4 comments
Closed

[Question]: About some alerts in code #368

Milerius opened this issue Aug 17, 2019 · 4 comments
Assignees

Comments

@Milerius
Copy link

Milerius commented Aug 17, 2019

Hello, after reading the code through tooling there is some alerts that i want to share (maybe some are relevant):

(/absl/base/internal/spinlock.h line 231)
Capture d’écran 2019-08-17 à 10 37 38

same here (absl/flags/internal/commandlineflag.cc line 467):

Capture d’écran 2019-08-17 à 10 40 35

It's not better to do smth like: if not instead of leaving an empty block ? or there is a specific reason that i dont get ?

There is some warning about comparison too:

(absl/debugging/internal/demangle.cc line 1626)
Capture d’écran 2019-08-17 à 10 44 13

(absl/time/internal/cctz/src/time_zone_format.cc)
Capture d’écran 2019-08-17 à 10 51 31

some overflow warning:

(absl/time/internal/cctz/src/time_zone_posix.cc)
Capture d’écran 2019-08-17 à 10 52 35

(absl/debugging/symbolize_elf.inc)
Capture d’écran 2019-08-17 à 10 47 05
Capture d’écran 2019-08-17 à 10 47 13

(abseil-cpp-src/absl/synchronization/mutex.cc)
Capture d’écran 2019-08-17 à 10 49 49

@Milerius Milerius changed the title [Question]: Strange empty block in source code [Question]: About some alerts in code Aug 17, 2019
@zhangxy988
Copy link
Contributor

Thank you for your report!
The empty block warning seems valid to me. We will work on removing them.
The warnings in cctz might be valid, but you will need to report them to https://github.com/google/cctz. Abseil doesn't own cctz - it only holds a copy of it.
The other warnings look less straight-forward, so I will leave them for people who are more familiar with the code to comment.

@zhangxy988
Copy link
Contributor

@vslashg Could you please look at the other overflow warnings? Thx.

@vehystrix
Copy link

Using clang scan-build the following warnings show up, perhaps they could be looked at as well:

$ scan-build cmake ../../abseil-cpp
scan-build: Using '/usr/lib/llvm-6.0/bin/clang' for static analysis
-- The CXX compiler identification is GNU 7.4.0
-- Check for working CXX compiler: /usr/share/clang/scan-build-6.0/libexec/c++-analyzer
-- Check for working CXX compiler: /usr/share/clang/scan-build-6.0/libexec/c++-analyzer -- works

$ cmake --build .

Scanning dependencies of target malloc_internal
[ 10%] Building CXX object absl/base/CMakeFiles/malloc_internal.dir/internal/low_level_alloc.cc.o
/mnt/a/abseil-cpp/absl/base/internal/low_level_alloc.cc:163:42: warning: Dereference of undefined pointer value
  return (head->levels == 0) ? nullptr : prev[0]->next[0];
                                         ^~~~~~~~~~~~~~~~
/mnt/a/abseil-cpp/absl/base/internal/low_level_alloc.cc:176:18: warning: Dereference of undefined pointer value
    e->next[i] = prev[i]->next[i];
                 ^~~~~~~~~~~~~~~~
/mnt/a/abseil-cpp/absl/base/internal/low_level_alloc.cc:284:10: warning: Access to field 'flags' results in a dereference of a null pointer (loaded from variable 'arena')
    if ((arena->flags & LowLevelAlloc::kAsyncSignalSafe) != 0) {
         ^~~~~~~~~~~~
3 warnings generated.
[ 11%] Built target malloc_internal

Scanning dependencies of target debugging_internal
[ 18%] Building CXX object absl/debugging/CMakeFiles/debugging_internal.dir/internal/elf_mem_image.cc.o
/mnt/a/abseil-cpp/absl/debugging/internal/elf_mem_image.cc:351:52: warning: Access to field 'st_name' results in a dereference of a null pointer (loaded from variable 'symbol')
  const char *const symbol_name = image->GetDynstr(symbol->st_name);
                                                   ^~~~~~~~~~~~~~~
1 warning generated.
[ 20%] Built target debugging_internal

Scanning dependencies of target strings
[ 28%] Building CXX object absl/strings/CMakeFiles/strings.dir/ascii.cc.o
[ 29%] Building CXX object absl/strings/CMakeFiles/strings.dir/charconv.cc.o
In file included from /mnt/a/abseil-cpp/absl/strings/charconv.cc:24:
/mnt/a/abseil-cpp/absl/numeric/int128.h:644:45: warning: The result of the right shift is undefined because the right operand is negative
      return MakeUint128(Uint128High64(lhs) >> amount,
                         ~~~~~~~~~~~~~~~~~~~^~~~~~~~~
1 warning generated.
[ 29%] Building CXX object absl/strings/CMakeFiles/strings.dir/escaping.cc.o
/mnt/a/abseil-cpp/absl/strings/escaping.cc:888:9: warning: Value stored to 'szdest' is never read
        szdest -= 2;
        ^         ~
/mnt/a/abseil-cpp/absl/strings/escaping.cc:908:9: warning: Value stored to 'szdest' is never read
        szdest -= 1;
        ^         ~
/mnt/a/abseil-cpp/absl/strings/escaping.cc:926:7: warning: Value stored to 'szdest' is never read
      szdest -= 4;
      ^         ~
3 warnings generated.
[ 33%] Building CXX object absl/strings/CMakeFiles/strings.dir/numbers.cc.o
/mnt/a/abseil-cpp/absl/strings/numbers.cc:208:5: warning: Value stored to 'digits' is never read
    digits = i;
    ^        ~
/mnt/a/abseil-cpp/absl/strings/numbers.cc:373:34: warning: The result of the left shift is undefined due to shifting by '64', which is greater or equal to the width of type 'unsigned long'
    result.first = (result.first << shift) + (result.second >> (64 - shift));
                    ~~~~~~~~~~~~~^~~~~~~~
2 warnings generated.
[ 37%] Built target strings

Scanning dependencies of target graphcycles_internal
[ 37%] Building CXX object absl/synchronization/CMakeFiles/graphcycles_internal.dir/internal/graphcycles.cc.o
/mnt/a/abseil-cpp/absl/synchronization/internal/graphcycles.cc:648:7: warning: Called C++ object pointer is null
      path[path_len] = MakeId(n, rep_->nodes_[n]->version);
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
[ 38%] Built target graphcycles_internal

absl-federation-github pushed a commit that referenced this issue Aug 23, 2019
--
d6748c733a70cd74ad9b76a0c9cd6b3fe2cecacf by Xiaoyi Zhang <zhangxy@google.com>:

Remove empty block, to address alerts reported in
#368.

PiperOrigin-RevId: 265099887

--
232e2036b5668d6d1296b881f9347756d84541ee by Derek Mauro <dmauro@google.com>:

Make the Linux Bazel CI scripts test with the exception mode explicitly set.

PiperOrigin-RevId: 265092105

--
942a40696c2c9b833be03e92d22a6ede7bccb6d4 by Xiaoyi Zhang <zhangxy@google.com>:

Import #372.
Suppress the unused variable warning on GCC, i.e. "-Wunused-variable".

PiperOrigin-RevId: 265063925

--
7ef90796b52cbdc260afc77cf47206f9356471d0 by Xiaoyi Zhang <zhangxy@google.com>:

Add quotes to `ABSL_COMMON_INCLUDE_DIRS` since it's a list and may contain a
`;`. This addresses #373.

PiperOrigin-RevId: 265059077

--
43f3ae742e00b83672ad6c5bc5b17fdb8f9fe6fe by Gennadiy Rozental <rogeeff@google.com>:

Internal re-organization

PiperOrigin-RevId: 264913945

--
6a2adf9c08ee1d98cc6b2855a676345c6495294a by Andy Soffer <asoffer@google.com>:

Publicly expose type names for uniform interval tags as in, for example, absl::IntervalClosedClosedTag, and add equality comparison operators.

PiperOrigin-RevId: 264861162

--
3c90c6e05fd61d56b419cd2d39dab8f17b8711b8 by Abseil Team <absl-team@google.com>:

Add validity check on returned frame pointer.

PiperOrigin-RevId: 264858823

--
2db87e0cfa0c6bea7ba81684b834cb8a73b7d748 by Gennadiy Rozental <rogeeff@google.com>:

Add MUST_USE_RESULT attribute to absl::GetFlag to prevent accidental misuse.

PiperOrigin-RevId: 264782762
GitOrigin-RevId: d6748c733a70cd74ad9b76a0c9cd6b3fe2cecacf
Change-Id: I169e9c5358e4f63000c1255e806d26b8afecf5ff
@rogeeff
Copy link
Member

rogeeff commented Jul 8, 2020

I believe empty braces are addressed. If you still observe other warnings please file separate issue per occurrence.

@rogeeff rogeeff closed this as completed Jul 8, 2020
4s5t2os41n added a commit to 4s5t2os41n/abseil-cpp that referenced this issue Jul 4, 2024
--
d6748c733a70cd74ad9b76a0c9cd6b3fe2cecacf by Xiaoyi Zhang <zhangxy@google.com>:

Remove empty block, to address alerts reported in
abseil/abseil-cpp#368.

PiperOrigin-RevId: 265099887

--
232e2036b5668d6d1296b881f9347756d84541ee by Derek Mauro <dmauro@google.com>:

Make the Linux Bazel CI scripts test with the exception mode explicitly set.

PiperOrigin-RevId: 265092105

--
942a40696c2c9b833be03e92d22a6ede7bccb6d4 by Xiaoyi Zhang <zhangxy@google.com>:

Import abseil/abseil-cpp#372.
Suppress the unused variable warning on GCC, i.e. "-Wunused-variable".

PiperOrigin-RevId: 265063925

--
7ef90796b52cbdc260afc77cf47206f9356471d0 by Xiaoyi Zhang <zhangxy@google.com>:

Add quotes to `ABSL_COMMON_INCLUDE_DIRS` since it's a list and may contain a
`;`. This addresses abseil/abseil-cpp#373.

PiperOrigin-RevId: 265059077

--
43f3ae742e00b83672ad6c5bc5b17fdb8f9fe6fe by Gennadiy Rozental <rogeeff@google.com>:

Internal re-organization

PiperOrigin-RevId: 264913945

--
6a2adf9c08ee1d98cc6b2855a676345c6495294a by Andy Soffer <asoffer@google.com>:

Publicly expose type names for uniform interval tags as in, for example, absl::IntervalClosedClosedTag, and add equality comparison operators.

PiperOrigin-RevId: 264861162

--
3c90c6e05fd61d56b419cd2d39dab8f17b8711b8 by Abseil Team <absl-team@google.com>:

Add validity check on returned frame pointer.

PiperOrigin-RevId: 264858823

--
2db87e0cfa0c6bea7ba81684b834cb8a73b7d748 by Gennadiy Rozental <rogeeff@google.com>:

Add MUST_USE_RESULT attribute to absl::GetFlag to prevent accidental misuse.

PiperOrigin-RevId: 264782762
GitOrigin-RevId: d6748c733a70cd74ad9b76a0c9cd6b3fe2cecacf
Change-Id: I169e9c5358e4f63000c1255e806d26b8afecf5ff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants