While using boost::format, my program sometimes encounters a segfault in locale_facets.h:938. In the function narrow. I am developing on AlmaLinux9.
Here is the line where I call format:
log.d(boost::format("some logging here %s %s") % _classMemberStr % localStr);
Here is the standard library function where the segfault happens. The segfault is on the line where __t
is declared and assigned:
char narrow(char_type __c, char __dfault) const
{
if (_M_narrow[static_cast<unsigned char>(__c)])
return _M_narrow[static_cast<unsigned char>(__c)];
const char __t = do_narrow(__c, __dfault);
if (__t != __dfault)
_M_narrow[static_cast<unsigned char>(__c)] = __t;
return __t;
}
It is in a method that gets called fairly often, so it is odd it only happens sometimes.
I have run the program in GDB, which is how I found to location of the segfault. Both strings were valid at the time of error, and the narrow function only took 2 arguments, which were characters, both of which had a value.