Project

General

Profile

Support #22589

Mismatched free/delete in ~regmatch

Added by Kyle Knoepfel 9 days ago. Updated 7 days ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
Start date:
05/14/2019
Due date:
% Done:

0%

Estimated time:
Duration:

Description

The SciSoft team has a report from ArgoNeuT (issue #22583) where an odd ROOT bug is being triggered. After rerunning valgrind on the job, I am getting the following error for ifdhc 2.4.1 (lines truncated):

==25028== Memcheck, a memory error detector
==25028== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==25028== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info
==25028== Command: art -c standard_sim_mono_t962.fcl -n 100
==25028== Parent PID: 9123
==25028==
==25028== Mismatched free() / delete / delete []
==25028==    at 0x4A09BAA: operator delete(void*, unsigned long) (vg_replace_malloc.c:583)
==25028==    by 0x1BC04B46: regex::regmatch::~regmatch() (regwrap.cc:22)
==25028==    by 0x1BBE224D: ifdh_ns::ifdh::lookup_loc(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (ifdh_cp.cc:195)
==25028==    by 0x1BBEF055: ifdh_ns::ifdh::pick_proto_path(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits
==25028==    by 0x1BBF0BE3: ifdh_ns::ifdh::lss(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (ifdh_cp.cc:1734)
==25028==    by 0x1BBF6995: ifdh_ns::ifdh::findMatchingFiles(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (ifdh_cp.cc:2331)
==25028==    by 0x1B71BDF4: t962::TGMuon::OpenInputFile() (TGMuon_module.cc:318)
==25028==    by 0x1B71A844: t962::TGMuon::TGMuon(fhicl::ParameterSet const&) (TGMuon_module.cc:145)
==25028==    by 0x1B725A43: t962::TGMuon* art::detail::make_module<t962::TGMuon>(fhicl::ParameterSet const&, art::ProcessingFrame const&) (ModuleMacros.h:49)
==25028==    by 0x1B71D6F8: make_module (TGMuon_module.cc:413)
==25028==    by 0x5DEAD9C: art::PathManager::makeModule_[abi:cxx11](fhicl::ParameterSet const&, art::ModuleDescription const&, art::ScheduleID) const (PathManager.cc:597)
==25028==    by 0x5DEA496: art::PathManager::makeModules_(unsigned short) (PathManager.cc:509)
==25028==  Address 0xb93d990 is 0 bytes inside a block of size 16 alloc'd
==25028==    at 0x4A0AF24: operator new[](unsigned long) (vg_replace_malloc.c:421)
==25028==    by 0x1BC04A4E: regex::regmatch::regmatch(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) (regwrap.cc:10)
==25028==    by 0x1BC04D60: regex::regexp::operator()(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) (regwrap.cc:72)
==25028==    by 0x1BBE1D48: ifdh_ns::ifdh::lookup_loc(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (ifdh_cp.cc:164)
==25028==    by 0x1BBEF055: ifdh_ns::ifdh::pick_proto_path(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits
==25028==    by 0x1BBF0BE3: ifdh_ns::ifdh::lss(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (ifdh_cp.cc:1734)
==25028==    by 0x1BBF6995: ifdh_ns::ifdh::findMatchingFiles(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (ifdh_cp.cc:2331)
==25028==    by 0x1B71BDF4: t962::TGMuon::OpenInputFile() (TGMuon_module.cc:318)
==25028==    by 0x1B71A844: t962::TGMuon::TGMuon(fhicl::ParameterSet const&) (TGMuon_module.cc:145)
==25028==    by 0x1B725A43: t962::TGMuon* art::detail::make_module<t962::TGMuon>(fhicl::ParameterSet const&, art::ProcessingFrame const&) (ModuleMacros.h:49)
==25028==    by 0x1B71D6F8: make_module (TGMuon_module.cc:413)
==25028==    by 0x5DEAD9C: art::PathManager::makeModule_[abi:cxx11](fhicl::ParameterSet const&, art::ModuleDescription const&, art::ScheduleID) const (PathManager.cc:597)

The code in question is here:

https://cdcvs.fnal.gov/redmine/projects/argoneutcode/repository/revisions/develop/entry/TGMuon/TGMuon_module.cc

Do you detect any error with how ArgoNeuT is using ifdhc?

History

#1 Updated by Marc Mengel 9 days ago

Their usage is fine.

But upon examination, I find a bug in the regwrap code (which hasn't changed in forever...)

239de64

In the copy constructor, I'm copying n+2 regmatch_t items into an new regmatch_t[n] array. :-(
which if the number of matches happens to fill out to the malloc rounding, breaks things...

I'll regression test, and we'll get that cut for v2_4_3 soonest.

#2 Updated by Robert Illingworth 9 days ago

You also have the bug valgrind is complaining about: you're doing _data = new regmatch_t[n+2]; but delete _data;, not delete [] _data

#3 Updated by Marc Mengel 9 days ago

#4 Updated by Marc Mengel 9 days ago

  • Status changed from New to Closed

Okay, so this tests clean, I cut v2_4_3 in Git Flow.

#5 Updated by Marc Mengel 7 days ago

  • Target version set to v2_4_3


Also available in: Atom PDF