-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Check duplicate issues.
- Checked for duplicates
Description
In ATLAS, we make use of custom TTree
indices via TTree::BuildIndex()
. Recently, we encountered an issue when running jobs under Valgrind: entries that are accessible under normal execution become unreadable when running the same code under Valgrind.
Upon investigation, it appears that TTreeIndex
uses long double
for internal calculations. However, Valgrind does not fully emulate 80-bit long double
precision on x86_64
systems. It simulates long double
as a 64-bit double
, losing precision beyond a certain limit.
As a result, when index values fall in the range where double
loses precision but long double
remains exact, the index lookup fails under Valgrind. This affects our ability to read ROOT files in Valgrind-based memory checks when using such index values.
We understand that this is fundamentally a limitation of Valgrind’s long double
emulation, not ROOT itself, but we’re wondering if anything can be done on the ROOT side to work around the issue. Many thanks.
Reproducer
#include <TFile.h>
#include <TTree.h>
#include <TTreeIndex.h>
#include <format>
#include <iostream>
int main() {
// A large enough index that can be represented by long double but not double
const Long64_t value = 9007199254743041LL;
// Write
{
TFile file("file.root", "RECREATE");
TTree tree("tree", "tree");
Long64_t index{value};
tree.Branch("index", &index);
tree.Fill();
tree.Write();
file.Close();
}
//Read
{
TFile file("file.root", "READ");
TTree* tree = file.Get<TTree>("tree");
tree->BuildIndex("index");
auto entry = tree->GetEntryNumberWithIndex(value);
std::cout << std::format("Entry: {} for Value: {}", entry, value) << std::endl;
file.Close();
}
return 0;
}
Running this against the head of main (e.g., dev3LCG
nightly), one gets:
Entry: 0 for Value: 9007199254743041
under normal execution while it fails under Valgrind with:
Warning in <TTreeIndex::TTreeIndex>: In tree entry 0, major value index=9007199254743040.000000 possibly out of range for internal `long double`
Entry: -1 for Value: 9007199254743041
ROOT version
ROOT Version: 6.37.01
Built for linuxx8664gcc on Aug 05 2025, 22:50:58
From heads/master@v6-37-01-7673-g25c19af92e
Installation method
LCG
Operating system
EL9
Additional context
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status