I am using Valgrind to detect memory leaks/errors in 开发者_如何学Gomy library, and it's the first time I've ever used it. It seems to be suggesting that there's some invalid reads in std::string
.
Here is the beginning of the error message
==16214== Invalid read of size 1
==16214== at 0x402701D: strlen (mc_replace_strmem.c:282)
==16214== by 0x40E53AA: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.14)
==16214== by 0x42FD03E: LHAPDF::Fortran_PDF_Base::initAlphasPDF() (Fortran_PDF_Base.C:290)
The rest is just more backtrace. The line which is my code is a constructor of a struct which takes two std::string
s as arguments.
I don't believe std::string
can be doing anything wrong, so what could the possible problem be?
Edit - struct constructor:
AlphaS_Info() {}
AlphaS_Info(bool fixed, Order order, std::string method, std::string symbol,
double alfasQ, int alfasQParm, double Q0, double mc, double mb, double mt) :
m_fixed(fixed), m_order(order), m_method(method), m_symbol(symbol),
m_mc(mc), m_mb(mb), m_mt(mt), m_alfasQ(alfasQ), m_Q0(Q0), m_alfasQParm(alfasQParm) {}
Call to constructor:
p_info->p_asinfo = new LHAPDFTOOLS::AlphaS_Info(fixed, evoOrder, method, symbol, alfasQ, alfasQParm, Q0, cmass, bmass, tmass);
Probably you passed an invalid string into your constructor, for example by using a pointer/reference to a string that already got deleted.
精彩评论