Glibc error using std::set in PyROOT

Here is a minimal example showing the error I get:

test.C

#include "TString.h"
#include <set>

std::set<TString> getSet(TString s)
{
   std::set<TString> n_set;
   for(int i = 0; i < s.Length(); i++)
   { 
      n_set.insert(s(i,1));
   } 
   return n_set;
}

std::vector<TString> getVector(TString s)
{

   std::set<TString> n_set = getSet(s);

   return std::vector<TString>(n_set.begin(), n_set.end());
}

and the python script

tmp.py

ROOT.gInterpreter.ProcessLine('#include "test.C"')
s = ROOT.TString("peterhansen")
myset = ROOT.getSet(s)
print [x for x in myset]
print "Done"

If I change ROOT.getSet(s) to ROOT.getVector(s) I get no errors.

The error looks like this

$python tmp.py
['a', 'e', 'h', 'n', 'p', 'r', 's', 't']
Done
*** glibc detected *** python: free(): invalid next size (fast): 0x0000000004b25360 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x75f3e)[0x7fc48db0df3e]
/lib64/libc.so.6(+0x78dd0)[0x7fc48db10dd0]
/cvmfs/cms.cern.ch/slc6_amd64_gcc530/lcg/root/6.06.00-ikhhed5/lib/libPyROOT.so(_ZN6PyROOT17op_dealloc_nofreeEPNS_11ObjectProxyE+0x
af)[0x7fc48d9fc6bf]
/cvmfs/cms.cern.ch/slc6_amd64_gcc530/lcg/root/6.06.00-ikhhed5/lib/libPyROOT.so(+0x59869)[0x7fc48d9fc869]
/cvmfs/cms.cern.ch/slc6_amd64_gcc530/cms/cmssw-patch/CMSSW_8_0_24_patch1/external/slc6_amd64_gcc530/lib/libpython2.7.so.1.0(+0xb98
02)[0x7fc48e78d802]
/cvmfs/cms.cern.ch/slc6_amd64_gcc530/cms/cmssw-patch/CMSSW_8_0_24_patch1/external/slc6_amd64_gcc530/lib/libpython2.7.so.1.0(+0x997
b7)[0x7fc48e76d7b7]
/cvmfs/cms.cern.ch/slc6_amd64_gcc530/cms/cmssw-patch/CMSSW_8_0_24_patch1/external/slc6_amd64_gcc530/lib/libpython2.7.so.1.0(PyDict
_SetItem+0x67)[0x7fc48e76f147]
/cvmfs/cms.cern.ch/slc6_amd64_gcc530/cms/cmssw-patch/CMSSW_8_0_24_patch1/external/slc6_amd64_gcc530/lib/libpython2.7.so.1.0(_PyMod
ule_Clear+0x144)[0x7fc48e773324]
/cvmfs/cms.cern.ch/slc6_amd64_gcc530/cms/cmssw-patch/CMSSW_8_0_24_patch1/external/slc6_amd64_gcc530/lib/libpython2.7.so.1.0(PyImpo
rt_Cleanup+0x423)[0x7fc48e7f4263]
/cvmfs/cms.cern.ch/slc6_amd64_gcc530/cms/cmssw-patch/CMSSW_8_0_24_patch1/external/slc6_amd64_gcc530/lib/libpython2.7.so.1.0(Py_Fin
alize+0xfe)[0x7fc48e805bfe]
/cvmfs/cms.cern.ch/slc6_amd64_gcc530/cms/cmssw-patch/CMSSW_8_0_24_patch1/external/slc6_amd64_gcc530/lib/libpython2.7.so.1.0(Py_Mai
n+0x5bf)[0x7fc48e81c01f]
/lib64/libc.so.6(__libc_start_main+0xfd)[0x7fc48dab6d1d]
python[0x4006b1]

I have changed the method by which I import the C code into PyROOT a few times (LoadMacro, LoadText) and I am always getting the same type of error.

Here it seems to get to the end of the program before throwing the error and looking at the trace leads me to believe the error is when deallocating the set. Clearing the set before the end, does not help.

Any ideas?
Version Info
ROOT 6.06/01
Scientific Linux CERN 6

Sorry for the delay in the reply. I only could reproduce this problem with version 6.06/02. Any newer version 6.08/XX works nicely as expected.
Cheers,

Pere

Thanks. I’m guessing it’s an incompatibility with the standard version of glibc. Good to know it’s fixed.