google / tcmalloc

Apache License 2.0
4.31k stars 463 forks source link

Following QuickStart does not Build Successfully #209

Open DanielLee343 opened 10 months ago

DanielLee343 commented 10 months ago

Hi, I was following the exact steps in the quickstart guide but bazel test //tcmalloc/... shows me this:

...
//tcmalloc/internal:allocation_guard_test                                FAILED in 0.2s
  /home/lyuze/.cache/bazel/_bazel_lyuze/d4dc78efd13286779efefa456013cbee/execroot/com_google_tcmalloc/bazel-out/k8-fastbuild/testlogs/tcmalloc/internal/allocation_guard_test/test.log
//tcmalloc/internal:cache_topology_test                                  FAILED in 0.0s
  /home/lyuze/.cache/bazel/_bazel_lyuze/d4dc78efd13286779efefa456013cbee/execroot/com_google_tcmalloc/bazel-out/k8-fastbuild/testlogs/tcmalloc/internal/cache_topology_test/test.log
//tcmalloc/internal:config_test                                          FAILED in 0.1s
  /home/lyuze/.cache/bazel/_bazel_lyuze/d4dc78efd13286779efefa456013cbee/execroot/com_google_tcmalloc/bazel-out/k8-fastbuild/testlogs/tcmalloc/internal/config_test/test.log
//tcmalloc/internal:sysinfo_test                                         FAILED in 0.3s
  /home/lyuze/.cache/bazel/_bazel_lyuze/d4dc78efd13286779efefa456013cbee/execroot/com_google_tcmalloc/bazel-out/k8-fastbuild/testlogs/tcmalloc/internal/sysinfo_test/test.log
//tcmalloc/testing:memory_errors_test_256k_pages                         FAILED in 11.2s
  /home/lyuze/.cache/bazel/_bazel_lyuze/d4dc78efd13286779efefa456013cbee/execroot/com_google_tcmalloc/bazel-out/k8-fastbuild/testlogs/tcmalloc/testing/memory_errors_test_256k_pages/test.log
//tcmalloc/testing:memory_errors_test_256k_pages_pow2                    FAILED in 11.4s
  /home/lyuze/.cache/bazel/_bazel_lyuze/d4dc78efd13286779efefa456013cbee/execroot/com_google_tcmalloc/bazel-out/k8-fastbuild/testlogs/tcmalloc/testing/memory_errors_test_256k_pages_pow2/test.log
//tcmalloc/testing:memory_errors_test_256k_pages_pow2_sharded_transfer_cache FAILED in 11.2s
  /home/lyuze/.cache/bazel/_bazel_lyuze/d4dc78efd13286779efefa456013cbee/execroot/com_google_tcmalloc/bazel-out/k8-fastbuild/testlogs/tcmalloc/testing/memory_errors_test_256k_pages_pow2_sharded_transfer_cache/test.log
//tcmalloc/testing:memory_errors_test_256k_pages_sharded_transfer_cache  FAILED in 11.3s
  /home/lyuze/.cache/bazel/_bazel_lyuze/d4dc78efd13286779efefa456013cbee/execroot/com_google_tcmalloc/bazel-out/k8-fastbuild/testlogs/tcmalloc/testing/memory_errors_test_256k_pages_sharded_transfer_cache/test.log
//tcmalloc/testing:memory_errors_test_32k_pages                          FAILED in 8.8s
  /home/lyuze/.cache/bazel/_bazel_lyuze/d4dc78efd13286779efefa456013cbee/execroot/com_google_tcmalloc/bazel-out/k8-fastbuild/testlogs/tcmalloc/testing/memory_errors_test_32k_pages/test.log
//tcmalloc/testing:memory_errors_test_512k_slab                          FAILED in 7.6s
  /home/lyuze/.cache/bazel/_bazel_lyuze/d4dc78efd13286779efefa456013cbee/execroot/com_google_tcmalloc/bazel-out/k8-fastbuild/testlogs/tcmalloc/testing/memory_errors_test_512k_slab/test.log
//tcmalloc/testing:memory_errors_test_8k_pages                           FAILED in 7.6s
  /home/lyuze/.cache/bazel/_bazel_lyuze/d4dc78efd13286779efefa456013cbee/execroot/com_google_tcmalloc/bazel-out/k8-fastbuild/testlogs/tcmalloc/testing/memory_errors_test_8k_pages/test.log
//tcmalloc/testing:memory_errors_test_chunks_for_page_tracker_lists      FAILED in 7.8s
  /home/lyuze/.cache/bazel/_bazel_lyuze/d4dc78efd13286779efefa456013cbee/execroot/com_google_tcmalloc/bazel-out/k8-fastbuild/testlogs/tcmalloc/testing/memory_errors_test_chunks_for_page_tracker_lists/test.log
//tcmalloc/testing:memory_errors_test_deprecated_perthread               FAILED in 8.1s
  /home/lyuze/.cache/bazel/_bazel_lyuze/d4dc78efd13286779efefa456013cbee/execroot/com_google_tcmalloc/bazel-out/k8-fastbuild/testlogs/tcmalloc/testing/memory_errors_test_deprecated_perthread/test.log
//tcmalloc/testing:memory_errors_test_flat_cpu_caches                    FAILED in 7.8s
  /home/lyuze/.cache/bazel/_bazel_lyuze/d4dc78efd13286779efefa456013cbee/execroot/com_google_tcmalloc/bazel-out/k8-fastbuild/testlogs/tcmalloc/testing/memory_errors_test_flat_cpu_caches/test.log
//tcmalloc/testing:memory_errors_test_hpaa                               FAILED in 7.6s
  /home/lyuze/.cache/bazel/_bazel_lyuze/d4dc78efd13286779efefa456013cbee/execroot/com_google_tcmalloc/bazel-out/k8-fastbuild/testlogs/tcmalloc/testing/memory_errors_test_hpaa/test.log
//tcmalloc/testing:memory_errors_test_legacy_size_classes                FAILED in 7.6s
  /home/lyuze/.cache/bazel/_bazel_lyuze/d4dc78efd13286779efefa456013cbee/execroot/com_google_tcmalloc/bazel-out/k8-fastbuild/testlogs/tcmalloc/testing/memory_errors_test_legacy_size_classes/test.log
//tcmalloc/testing:memory_errors_test_no_hpaa                            FAILED in 7.6s
  /home/lyuze/.cache/bazel/_bazel_lyuze/d4dc78efd13286779efefa456013cbee/execroot/com_google_tcmalloc/bazel-out/k8-fastbuild/testlogs/tcmalloc/testing/memory_errors_test_no_hpaa/test.log
//tcmalloc/testing:memory_errors_test_numa_aware                         FAILED in 9.4s
  /home/lyuze/.cache/bazel/_bazel_lyuze/d4dc78efd13286779efefa456013cbee/execroot/com_google_tcmalloc/bazel-out/k8-fastbuild/testlogs/tcmalloc/testing/memory_errors_test_numa_aware/test.log
//tcmalloc/testing:memory_errors_test_real_cpu_caches                    FAILED in 7.7s
  /home/lyuze/.cache/bazel/_bazel_lyuze/d4dc78efd13286779efefa456013cbee/execroot/com_google_tcmalloc/bazel-out/k8-fastbuild/testlogs/tcmalloc/testing/memory_errors_test_real_cpu_caches/test.log
//tcmalloc/testing:memory_errors_test_small_but_slow                     FAILED in 7.2s
  /home/lyuze/.cache/bazel/_bazel_lyuze/d4dc78efd13286779efefa456013cbee/execroot/com_google_tcmalloc/bazel-out/k8-fastbuild/testlogs/tcmalloc/testing/memory_errors_test_small_but_slow/test.log
//tcmalloc/testing:memory_errors_test_use_all_buckets_for_few_object_spans FAILED in 7.9s
  /home/lyuze/.cache/bazel/_bazel_lyuze/d4dc78efd13286779efefa456013cbee/execroot/com_google_tcmalloc/bazel-out/k8-fastbuild/testlogs/tcmalloc/testing/memory_errors_test_use_all_buckets_for_few_object_spans/test.log
//tcmalloc/testing:memory_errors_test_use_extended_size_class_for_cold   FAILED in 7.7s
  /home/lyuze/.cache/bazel/_bazel_lyuze/d4dc78efd13286779efefa456013cbee/execroot/com_google_tcmalloc/bazel-out/k8-fastbuild/testlogs/tcmalloc/testing/memory_errors_test_use_extended_size_class_for_cold/test.log
...
Executed 20 out of 799 tests: 779 tests pass and 20 fail locally.

I noticed the mojority of tests failed in this line tcmalloc/testing/memory_errors_test.cc:432, at the EXPECT_DEATH

TEST_P(ParameterizedTcMallocTest, ReallocLarger) {
  // Note: sizes are chosen so that size + 2 access below
  // does not write out of actual allocation bounds.
  for (size_t size : {2, 29, 60, 505}) {
    EXPECT_DEATH(
        {
          fprintf(stderr, "size=%zu\n", size);
          ScopedAlwaysSample always_sample;
          ScopedImprovedGuardedSampling scoped_improved_guarded_sampling(
              GetParam());
          for (size_t i = 0; i < 10000; ++i) {
            char* volatile ptr = static_cast<char*>(malloc(size));
            ptr = static_cast<char*>(realloc(ptr, size + 1));
            ptr[size + 2] = 'A';
            free(ptr);
            MaybeResetStackTraceFilter(GetParam());
          }
        },
        "SIGSEGV");
  }
}

My system environment:

lyuze@wukong0:~/workspace/tcmalloc$ gcc --version
gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 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.
$ uname -r
6.2.0
$ gcc --version
gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 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.
$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.3 LTS"
$ bazel --version
bazel 6.4.0

Any reason for that, or hint for debug? Thanks!

ckennelly commented 10 months ago

Do you have the relevant errors from the log files?

For example, on memory_errors_test, does the test die successfully, but perhaps not with the expected error?

DanielLee343 commented 10 months ago

Thanks for reply. The log files show it does not meet with expected error:

tcmalloc/testing/memory_errors_test.cc:432: Failure
Death test: { fprintf(stderr, "size=%zu\n", size); ScopedAlwaysSample always_sample; ScopedImprovedGuardedSampling scoped_improved_guarded_sampling( GetParam()); for (size_t i = 0; i < 10000; ++i) { char* volatile ptr = static_cast<char*>(malloc(size)); ptr = static_cast<char*>(realloc(ptr, size + 1)); ptr[size + 2] = 'A'; free(ptr); MaybeResetStackTraceFilter(GetParam()); } }
    Result: died but not with expected error.
  Expected: contains regular expression "SIGSEGV"
Actual msg:
[  DEATH   ] size=2
[  DEATH   ] tcmalloc/segv_handler.cc:227] *** GWP-ASan (https://google.github.io/tcmalloc/gwp-asan.html)  has detected a memory error ***
[  DEATH   ] tcmalloc/segv_handler.cc:231] >>> Access at offset 0 into buffer of length 3
[  DEATH   ] tcmalloc/segv_handler.cc:233] Error originates from memory allocated in thread 42 at:
[  DEATH   ] tcmalloc/segv_handler.cc:101]   @   0x5555555bb500
[  DEATH   ] tcmalloc/segv_handler.cc:101]   @   0x5555555a7855
...
[  DEATH   ] tcmalloc/segv_handler.cc:275] Buffer overflow (write) detected in thread 42 at free:
...
[  DEATH   ] tcmalloc/segv_handler.cc:286] *** Try rerunning with --config=asan to get stack trace of overflow ***
[  DEATH   ] tcmalloc/segv_handler.cc:290] improved_guarded_sampling: 0
...

There's no --config=asan option for bazel. So I ran with -c dbg but no difference.

minjunjiang commented 3 months ago

I have the issue here, any update?

tcmalloc/internal/allocation_guard_test.cc:35: Failure Death test: { AllocationGuardSpinLockHolder h(&lock); } Result: died but not with expected error. Expected: contains regular expression "SIGABRT received" Actual msg:

@ckennelly Do you have any ideas? Anything will be helpful, Thanks in advance!