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

Using LZMA compression with RNTupleWriter leads to memory corruption #14508

Closed
1 task done
Dr15Jones opened this issue Jan 31, 2024 · 1 comment · Fixed by #14523
Closed
1 task done

Using LZMA compression with RNTupleWriter leads to memory corruption #14508

Dr15Jones opened this issue Jan 31, 2024 · 1 comment · Fixed by #14523
Assignees
Labels
bug experiment Affects an experiment / reported by its software & computimng experts in:RNTuple

Comments

@Dr15Jones
Copy link
Contributor

Dr15Jones commented Jan 31, 2024

Check duplicate issues.

  • Checked for duplicates

Description

When I used RNTupleWriter to store CMS miniAOD like data using LZMA compression with level 4 I got libc errors about problems with free. Running valgrind on the job turned up many 'invalid writes' in calls to lzma

==1855575== Invalid write of size 1
==1855575==    at 0x4046BE3: memmove (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/external/valgrind/3.22.0-e989c977f8949fc48f1bc1206f1f87c8/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==1855575==    by 0x700C7DA: ??? (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/external/xz/5.2.5-6f3f49b07db84e10c9be594a1176c114/lib/liblzma.so.5.2.5)
==1855575==    by 0x7011C2F: ??? (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/external/xz/5.2.5-6f3f49b07db84e10c9be594a1176c114/lib/liblzma.so.5.2.5)
==1855575==    by 0x700CB55: lzma_code (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/external/xz/5.2.5-6f3f49b07db84e10c9be594a1176c114/lib/liblzma.so.5.2.5)
==1855575==    by 0x596A683: R__zipLZMA (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libCore.so)
==1855575==    by 0x4D6E315: ROOT::Experimental::Detail::RPageSink::SealPage(ROOT::Experimental::Detail::RPage const&, ROOT::Experimental::Detail::RColumnElementBase const&, int, void*, bool) (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1855575==    by 0x4D6378E: ROOT::Experimental::Detail::RPageSinkBuf::CommitPage(ROOT::Experimental::Detail::RPageStorage::RColumnHandle, ROOT::Experimental::Detail::RPage const&) (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1855575==    by 0x4CDDA89: ROOT::Experimental::Detail::RColumn::Flush() (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1855575==    by 0x4CE95CB: ROOT::Experimental::Detail::RFieldBase::CommitCluster() (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1855575==    by 0x4D24A3C: ROOT::Experimental::RNTupleWriter::CommitCluster(bool) (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1855575==    by 0x4D24D9D: ROOT::Experimental::RNTupleWriter::~RNTupleWriter() (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1855575==    by 0x459E52: cce::tf::RNTupleOutputer::~RNTupleOutputer() (in /uscms_data/d2/cdj/build/temp/rntuple/root_serialization/build-root-serialization/threaded_io_test)
==1855575==  Address 0x29d07560 is 0 bytes after a block of size 16 alloc'd
==1855575==    at 0x403C617: operator new[](unsigned long) (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/external/valgrind/3.22.0-e989c977f8949fc48f1bc1206f1f87c8/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==1855575==    by 0x4D63568: ROOT::Experimental::Detail::RPageSinkBuf::CommitPage(ROOT::Experimental::Detail::RPageStorage::RColumnHandle, ROOT::Experimental::Detail::RPage const&) (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1855575==    by 0x4CDDA89: ROOT::Experimental::Detail::RColumn::Flush() (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1855575==    by 0x4CE95CB: ROOT::Experimental::Detail::RFieldBase::CommitCluster() (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1855575==    by 0x4D24A3C: ROOT::Experimental::RNTupleWriter::CommitCluster(bool) (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1855575==    by 0x4D24D9D: ROOT::Experimental::RNTupleWriter::~RNTupleWriter() (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1855575==    by 0x459E52: cce::tf::RNTupleOutputer::~RNTupleOutputer() (in /uscms_data/d2/cdj/build/temp/rntuple/root_serialization/build-root-serialization/threaded_io_test)
==1855575==    by 0x4114AE: main (in /uscms_data/d2/cdj/build/temp/rntuple/root_serialization/build-root-serialization/threaded_io_test)
==1855575== 
==1855575== Invalid write of size 2
==1855575==    at 0x4046BB3: memmove (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/external/valgrind/3.22.0-e989c977f8949fc48f1bc1206f1f87c8/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==1855575==    by 0x7023ABA: ??? (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/external/xz/5.2.5-6f3f49b07db84e10c9be594a1176c114/lib/liblzma.so.5.2.5)
==1855575==    by 0x7018963: ??? (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/external/xz/5.2.5-6f3f49b07db84e10c9be594a1176c114/lib/liblzma.so.5.2.5)
==1855575==    by 0x701014B: ??? (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/external/xz/5.2.5-6f3f49b07db84e10c9be594a1176c114/lib/liblzma.so.5.2.5)
==1855575==    by 0x7011B46: ??? (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/external/xz/5.2.5-6f3f49b07db84e10c9be594a1176c114/lib/liblzma.so.5.2.5)
==1855575==    by 0x700CB55: lzma_code (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/external/xz/5.2.5-6f3f49b07db84e10c9be594a1176c114/lib/liblzma.so.5.2.5)
==1855575==    by 0x596A683: R__zipLZMA (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libCore.so)
==1855575==    by 0x4D6E315: ROOT::Experimental::Detail::RPageSink::SealPage(ROOT::Experimental::Detail::RPage const&, ROOT::Experimental::Detail::RColumnElementBase const&, int, void*, bool) (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1855575==    by 0x4D6378E: ROOT::Experimental::Detail::RPageSinkBuf::CommitPage(ROOT::Experimental::Detail::RPageStorage::RColumnHandle, ROOT::Experimental::Detail::RPage const&) (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1855575==    by 0x4CDDA89: ROOT::Experimental::Detail::RColumn::Flush() (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1855575==    by 0x4CE95CB: ROOT::Experimental::Detail::RFieldBase::CommitCluster() (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1855575==    by 0x4D24A3C: ROOT::Experimental::RNTupleWriter::CommitCluster(bool) (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1855575==  Address 0x32f0a6b4 is 0 bytes after a block of size 36 alloc'd
==1855575==    at 0x403C617: operator new[](unsigned long) (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/external/valgrind/3.22.0-e989c977f8949fc48f1bc1206f1f87c8/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==1855575==    by 0x4D63568: ROOT::Experimental::Detail::RPageSinkBuf::CommitPage(ROOT::Experimental::Detail::RPageStorage::RColumnHandle, ROOT::Experimental::Detail::RPage const&) (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1855575==    by 0x4CDDA89: ROOT::Experimental::Detail::RColumn::Flush() (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1855575==    by 0x4CE95CB: ROOT::Experimental::Detail::RFieldBase::CommitCluster() (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1855575==    by 0x4D24A3C: ROOT::Experimental::RNTupleWriter::CommitCluster(bool) (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1855575==    by 0x4D24D9D: ROOT::Experimental::RNTupleWriter::~RNTupleWriter() (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1855575==    by 0x459E52: cce::tf::RNTupleOutputer::~RNTupleOutputer() (in /uscms_data/d2/cdj/build/temp/rntuple/root_serialization/build-root-serialization/threaded_io_test)
==1855575==    by 0x4114AE: main (in /uscms_data/d2/cdj/build/temp/rntuple/root_serialization/build-root-serialization/threaded_io_test)
==1855575== 
==1855575== Invalid write of size 1
==1855575==    at 0x4046BE3: memmove (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/external/valgrind/3.22.0-e989c977f8949fc48f1bc1206f1f87c8/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==1855575==    by 0x7023ABA: ??? (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/external/xz/5.2.5-6f3f49b07db84e10c9be594a1176c114/lib/liblzma.so.5.2.5)
==1855575==    by 0x7018963: ??? (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/external/xz/5.2.5-6f3f49b07db84e10c9be594a1176c114/lib/liblzma.so.5.2.5)
==1855575==    by 0x701014B: ??? (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/external/xz/5.2.5-6f3f49b07db84e10c9be594a1176c114/lib/liblzma.so.5.2.5)
==1855575==    by 0x7011B46: ??? (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/external/xz/5.2.5-6f3f49b07db84e10c9be594a1176c114/lib/liblzma.so.5.2.5)
==1855575==    by 0x700CB55: lzma_code (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/external/xz/5.2.5-6f3f49b07db84e10c9be594a1176c114/lib/liblzma.so.5.2.5)
==1855575==    by 0x596A683: R__zipLZMA (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libCore.so)
==1855575==    by 0x4D6E315: ROOT::Experimental::Detail::RPageSink::SealPage(ROOT::Experimental::Detail::RPage const&, ROOT::Experimental::Detail::RColumnElementBase const&, int, void*, bool) (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1855575==    by 0x4D6378E: ROOT::Experimental::Detail::RPageSinkBuf::CommitPage(ROOT::Experimental::Detail::RPageStorage::RColumnHandle, ROOT::Experimental::Detail::RPage const&) (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1855575==    by 0x4CDDA89: ROOT::Experimental::Detail::RColumn::Flush() (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1855575==    by 0x4CE95CB: ROOT::Experimental::Detail::RFieldBase::CommitCluster() (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1855575==    by 0x4D24A3C: ROOT::Experimental::RNTupleWriter::CommitCluster(bool) (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1855575==  Address 0x32f0a6bc is 8 bytes after a block of size 36 alloc'd
==1855575==    at 0x403C617: operator new[](unsigned long) (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/external/valgrind/3.22.0-e989c977f8949fc48f1bc1206f1f87c8/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==1855575==    by 0x4D63568: ROOT::Experimental::Detail::RPageSinkBuf::CommitPage(ROOT::Experimental::Detail::RPageStorage::RColumnHandle, ROOT::Experimental::Detail::RPage const&) (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1855575==    by 0x4CDDA89: ROOT::Experimental::Detail::RColumn::Flush() (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1855575==    by 0x4CE95CB: ROOT::Experimental::Detail::RFieldBase::CommitCluster() (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1855575==    by 0x4D24A3C: ROOT::Experimental::RNTupleWriter::CommitCluster(bool) (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1855575==    by 0x4D24D9D: ROOT::Experimental::RNTupleWriter::~RNTupleWriter() (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1855575==    by 0x459E52: cce::tf::RNTupleOutputer::~RNTupleOutputer() (in /uscms_data/d2/cdj/build/temp/rntuple/root_serialization/build-root-serialization/threaded_io_test)
==1855575==    by 0x4114AE: main (in /uscms_data/d2/cdj/build/temp/rntuple/root_serialization/build-root-serialization/threaded_io_test)

I see the same valgrind error when just storing one std::vector<int> and one std::vector<float> to RNTuple. In this case, the job completes without the error from 'free'.

==1920683== Invalid write of size 1
==1920683==    at 0x4046BE3: memmove (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/external/valgrind/3.22.0-e989c977f8949fc48f1bc1206f1f87c8/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==1920683==    by 0x700C7DA: ??? (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/external/xz/5.2.5-6f3f49b07db84e10c9be594a1176c114/lib/liblzma.so.5.2.5)
==1920683==    by 0x7011C2F: ??? (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/external/xz/5.2.5-6f3f49b07db84e10c9be594a1176c114/lib/liblzma.so.5.2.5)
==1920683==    by 0x700CB55: lzma_code (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/external/xz/5.2.5-6f3f49b07db84e10c9be594a1176c114/lib/liblzma.so.5.2.5)
==1920683==    by 0x596A683: R__zipLZMA (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libCore.so)
==1920683==    by 0x4D6E315: ROOT::Experimental::Detail::RPageSink::SealPage(ROOT::Experimental::Detail::RPage const&, ROOT::Experimental::Detail::RColumnElementBase const&, int, void*, bool) (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.
01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1920683==    by 0x4D6378E: ROOT::Experimental::Detail::RPageSinkBuf::CommitPage(ROOT::Experimental::Detail::RPageStorage::RColumnHandle, ROOT::Experimental::Detail::RPage const&) (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee4
2f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1920683==    by 0x4CDDA89: ROOT::Experimental::Detail::RColumn::Flush() (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1920683==    by 0x4CE95CB: ROOT::Experimental::Detail::RFieldBase::CommitCluster() (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1920683==    by 0x4D24A3C: ROOT::Experimental::RNTupleWriter::CommitCluster(bool) (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1920683==    by 0x4D24D9D: ROOT::Experimental::RNTupleWriter::~RNTupleWriter() (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1920683==    by 0x459E52: cce::tf::RNTupleOutputer::~RNTupleOutputer() (in /uscms_data/d2/cdj/build/temp/rntuple/root_serialization/build-root-serialization/threaded_io_test)
==1920683==  Address 0xe6151ac is 0 bytes after a block of size 12 alloc'd
==1920683==    at 0x403C617: operator new[](unsigned long) (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/external/valgrind/3.22.0-e989c977f8949fc48f1bc1206f1f87c8/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==1920683==    by 0x4D63568: ROOT::Experimental::Detail::RPageSinkBuf::CommitPage(ROOT::Experimental::Detail::RPageStorage::RColumnHandle, ROOT::Experimental::Detail::RPage const&) (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee4
2f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1920683==    by 0x4CDDA89: ROOT::Experimental::Detail::RColumn::Flush() (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1920683==    by 0x4CE95CB: ROOT::Experimental::Detail::RFieldBase::CommitCluster() (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1920683==    by 0x4D24A3C: ROOT::Experimental::RNTupleWriter::CommitCluster(bool) (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1920683==    by 0x4D24D9D: ROOT::Experimental::RNTupleWriter::~RNTupleWriter() (in /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02821/el8_amd64_gcc12/lcg/root/6.31.01-184a5ee42f3c094c02e1b303c901e8e4/lib/libROOTNTuple.so)
==1920683==    by 0x459E52: cce::tf::RNTupleOutputer::~RNTupleOutputer() (in /uscms_data/d2/cdj/build/temp/rntuple/root_serialization/build-root-serialization/threaded_io_test)
==1920683==    by 0x4114AE: main (in /uscms_data/d2/cdj/build/temp/rntuple/root_serialization/build-root-serialization/threaded_io_test)
==1920683== 

Reproducer

The following shows the problem when run using valgrind.

#include <ROOT/RNTupleModel.hxx>
#include <ROOT/RField.hxx>
#include <ROOT/RNTuple.hxx>

#include <vector>

int main() {
  auto model = ROOT::Experimental::RNTupleModel::Create();
  model->AddField( ROOT::Experimental::Detail::RFieldBase::Create("ints","std::vector<int>").Unwrap());
  model->AddField( ROOT::Experimental::Detail::RFieldBase::Create("floats","std::vector<float>").Unwrap());
  auto writeOptions = ROOT::Experimental::RNTupleWriteOptions();
  writeOptions.SetCompression(ROOT::RCompressionSetting::EAlgorithm::kLZMA, 4);

  auto writer = ROOT::Experimental::RNTupleWriter::Recreate(std::move(model), "Events", "dummy.root", writeOptions);

  std::vector<int> ints ={1,2,3};
  void* pInts = &ints;
  void** ppInts = &pInts;
  std::vector<float> floats = {2.0, 4.0, 6.0};
  void* pFloats = &floats;
  void** ppFloats = &pFloats;
  {
    auto entry = writer->CreateEntry();
    entry->CaptureValueUnsafe("ints", *ppInts);
    entry->CaptureValueUnsafe("floats", *ppFloats);
    writer->Fill(*entry);
  }
  writer.reset();

  return 0;
}

ROOT version

   ------------------------------------------------------------------
  | Welcome to ROOT 6.31/01                        https://root.cern |
  | (c) 1995-2023, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for linuxx8664gcc on Jan 21 2024, 23:43:23                 |
  | From heads/master@tags/v6-31-01                                  |
  | With g++ (GCC) 12.3.1 20230527                                   |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |
   ------------------------------------------------------------------

Installation method

CMSSW release

Operating system

linux

Additional context

No response

@Dr15Jones Dr15Jones added the bug label Jan 31, 2024
@hahnjo hahnjo self-assigned this Feb 2, 2024
@hahnjo hahnjo added in:RNTuple experiment Affects an experiment / reported by its software & computimng experts labels Feb 2, 2024
@hahnjo
Copy link
Member

hahnjo commented Feb 2, 2024

Thanks @Dr15Jones for this excellent report and reproducer; here's the test case updated for ROOT master APIs:

#include <ROOT/RNTupleModel.hxx>
#include <ROOT/RField.hxx>
#include <ROOT/RNTuple.hxx>

#include <vector>

int main() {
  auto model = ROOT::Experimental::RNTupleModel::Create();
  model->AddField( ROOT::Experimental::RFieldBase::Create("ints","std::vector<int>").Unwrap());
  model->AddField( ROOT::Experimental::RFieldBase::Create("floats","std::vector<float>").Unwrap());
  auto writeOptions = ROOT::Experimental::RNTupleWriteOptions();
  writeOptions.SetCompression(ROOT::RCompressionSetting::EAlgorithm::kLZMA, 4);

  auto writer = ROOT::Experimental::RNTupleWriter::Recreate(std::move(model), "Events", "dummy.root", writeOptions);

  std::vector<int> ints ={1,2,3};
  void* pInts = &ints;
  void** ppInts = &pInts;
  std::vector<float> floats = {2.0, 4.0, 6.0};
  void* pFloats = &floats;
  void** ppFloats = &pFloats;
  {
    auto entry = writer->CreateEntry();
    entry->BindRawPtr("ints", *ppInts);
    entry->BindRawPtr("floats", *ppFloats);
    writer->Fill(*entry);
  }
  writer.reset();

  return 0;
}

I see the problem, we are hitting the exact case where the buffer size minus the compression header (which is not properly accounted for!) is not sufficient to hold the compressed content. I have a fix, PR will come soon.

hahnjo added a commit to hahnjo/root that referenced this issue Feb 2, 2024
lzma_code must only see the buffers without the header, so the sizes
have to be adjusted accordingly.

Fixes root-project#14508
hahnjo added a commit to hahnjo/root that referenced this issue Feb 2, 2024
lzma_code must only see the buffers without the header, so the sizes
have to be adjusted accordingly.

Fixes root-project#14508
hahnjo added a commit to hahnjo/root that referenced this issue Feb 3, 2024
lzma_code must only see the buffers without the header, so the sizes
have to be adjusted accordingly.

Fixes root-project#14508
hahnjo added a commit to hahnjo/root that referenced this issue Feb 7, 2024
lzma_code must only see the buffers without the header, so the sizes
have to be adjusted accordingly.

Fixes root-project#14508
hahnjo added a commit that referenced this issue Feb 8, 2024
lzma_code must only see the buffers without the header, so the sizes
have to be adjusted accordingly.

Fixes #14508
@hahnjo hahnjo added this to Issues in Fixed in 6.32.00 via automation Feb 8, 2024
hahnjo added a commit to hahnjo/root that referenced this issue Feb 8, 2024
lzma_code must only see the buffers without the header, so the sizes
have to be adjusted accordingly.

Fixes root-project#14508

(cherry picked from commit 17e3561)
hahnjo added a commit to hahnjo/root that referenced this issue Feb 8, 2024
lzma_code must only see the buffers without the header, so the sizes
have to be adjusted accordingly.

Fixes root-project#14508

(cherry picked from commit 17e3561)
hahnjo added a commit to hahnjo/root that referenced this issue Feb 8, 2024
lzma_code must only see the buffers without the header, so the sizes
have to be adjusted accordingly.

Fixes root-project#14508

(cherry picked from commit 17e3561)
hahnjo added a commit that referenced this issue Feb 8, 2024
lzma_code must only see the buffers without the header, so the sizes
have to be adjusted accordingly.

Fixes #14508

(cherry picked from commit 17e3561)
hahnjo added a commit that referenced this issue Feb 8, 2024
lzma_code must only see the buffers without the header, so the sizes
have to be adjusted accordingly.

Fixes #14508

(cherry picked from commit 17e3561)
hahnjo added a commit that referenced this issue Feb 8, 2024
lzma_code must only see the buffers without the header, so the sizes
have to be adjusted accordingly.

Fixes #14508

(cherry picked from commit 17e3561)
@hahnjo hahnjo added this to Issues in Fixed in 6.26/16 via automation Feb 8, 2024
@hahnjo hahnjo added this to Issues in Fixed in 6.30.06 via automation Feb 8, 2024
@hahnjo hahnjo added this to Issues in Fixed in 6.28/14 via automation Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug experiment Affects an experiment / reported by its software & computimng experts in:RNTuple
Projects
Development

Successfully merging a pull request may close this issue.

3 participants