Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

out of bound access when building TLegend

Đã đóng
#23,767 0 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@vepadulano đang làm issue này rồi.

Từ ngày 20/10/2026.

  • #23768 của @vepadulano — đã merge

Đánh giá

Issue này chưa được đánh giá.

Mô tả

bug in:Graphics
Check duplicate issues.
  • Checked for duplicates
Description

A simple plotting example of a histogram produces

/usr/include/c++/16/bits/stl_bvector.h:1158: constexpr std::vector<bool, _Alloc>::reference std::vector<bool, _Alloc>::operator[](size_type) [with _Alloc = std::allocator<bool>; reference = std::vector<bool>::reference; size_type = long unsigned int]: Assertion '__n < this->size()' failed.

In a debug build with GCC 16. See reproducer below.

The issue stems from https://github.com/root-project/root/blob/94606761150e817bf1c91c76fc1083deecfdcf33/graf2d/gpad/src/TPad.cxx#L3171 which allows accessing the one-after-last element of the vector.

Reproducer
#include <gtest/gtest.h>
#include <TCanvas.h>
#include <TH1D.h>

TEST(TH2D, DrawWithBuildLegend)
{

   TH1D h1{"h1", "h1", 10, 0, 1};
   auto nFills{10};
   for (auto i = 0; i < nFills; i++) {
      h1.Fill(0.45);
   }

   // Set a range on the Y axis lower cannot contain the maximum value: this triggered a bug in TPad::FillCollideGridTH1
   // which would access the vector to find empty spaces for the legend out of bounds.
   h1.GetYaxis()->SetRangeUser(0, 8);

   TCanvas c;
   h1.Draw();
   // Need to check that BuildLegend can work also when the Y axis does not contain the maximum value
   c.BuildLegend();
}

int main(int argc, char **argv)
{
   ::testing::InitGoogleTest(&argc, argv);
   return RUN_ALL_TESTS();
}
ROOT version

Any

Installation method

From source

Operating system

Linux

Additional context

No response

Ngôn ngữ chính
C++
Star
3.3k
Fork
1.6k
Merge trung bình
2 ngày 17 giờ
Pull request đã merge (30 ngày)
188

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của root-project/root

Tất cả issue của root-project/root

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.