On Sat, Sep 25, 2021 at 08:07:20PM -0600, Jerry James wrote:
On Sat, Sep 25, 2021 at 5:10 PM Alexander Ploumistos
<alex.ploumistos(a)gmail.com> wrote:
> I built the latest avogadro2 and avogadro2-libs from the srpm in your
> copr for F34 and I hit some graphical glitches again. On Wayland,
> Avogadro2 for X11 has a transparent canvas, whereas the other one (I
> guess Wayland) doesn't, but as soon as I add a fourth atom to the
> drawing, it crashes:
>
> /usr/include/c++/11/bits/stl_vector.h:1045: std::vector<_Tp,
> _Alloc>::reference std::vector<_Tp,
> _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp =
> Eigen::Matrix<double, 3, 1>; _Alloc =
> std::allocator<Eigen::Matrix<double, 3, 1> >; std::vector<_Tp,
> _Alloc>::reference = Eigen::Matrix<double, 3, 1>&; std::vector<_Tp,
> _Alloc>::size_type = long unsigned int]: Assertion '__n <
> this->size()' failed.
> Aborted (core dumped)
I don't know if this is the same as the inchi-related abort, but that
one is caused by this code, on lines 178-180 of molecule_smiles.cpp,
in Molecule::ToInChI():
std::string s = ostream.str();
s[s.length() - 1] = '\0'; // Abort happens here
return ( QString( s.c_str() ) );
The abort happens because s is the empty string, so s.length() == 0,
and assigning to s[-1] just isn't a good idea. I'm pretty sure that
line isn't needed anyway. Isn't s.c_str() guaranteed to provide a
null-terminated C string?
Yes, this is guaranteed:
Returns a pointer to an array that contains a null-terminated
sequence of characters (i.e., a C-string) representing the current
value of the string object.
Zbyszek