Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

out of bound access when building TLegend

Chiusa
#23,767 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@vepadulano ci sta già lavorando.

Dal 20/10/2026.

  • #23768 di @vepadulano — integrata

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

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

Lingua principale
C++
Stelle
3.3k
Fork
1.6k
Merge medio
2g 14h
PR unite (30g)
192

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di root-project/root

Tutte le issue di root-project/root

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.