Re: openbabel-3.1* in Rawhide

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 9/26/21 05:07, Jerry James wrote:
> On Sat, Sep 25, 2021 at 5:10 PM Alexander Ploumistos
> <alex.ploumistos@xxxxxxxxx> 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?

In addition to .c_str() providing a null-terminated C string, the above
code is wrong also in another sense: s.length() is the length of the
string EXCLUDING THE TERMINATOR so that code is in fact removing the
last letter of the string which can't be the purpose.

You can easily verify this behavior with

#include <iostream>
#include <string>

int main ()
{
  std::string str1(""), str2("c");
  std::cout << "str1.length()= " << str1.length() << ", str2.length()= "
<< str2.length() << std::endl;
  return 0;
}

which prints out

$ ./a.out
str1.length()= 0, str2.length()= 1
-- 
Susi Lehtola
Fedora Project Contributor
jussilehtola@xxxxxxxxxxxxxxxxx
_______________________________________________
devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Users]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]

  Powered by Linux