Re: debugging? (segmentation fault)

Rhialto <[email protected]>
Newsgroups gmane.comp.gnome.apps.pan.user
Message-ID <[email protected]>
On Sat 12 Feb 2022 at 23:25:55 -0800, David Chmelik wrote:
> > When a segfault occurs, execute the command "backtrace".
>     This is some further information seen when running it and the
> backtrace,  The only thing different last few years is I've been trying to
> read a few hundred newsgroups on Eternal-September (backup server AIOE) and
> Gmane.
> 
> IA__gtk_tree_view_column_set_fixed_width: assertion 'fixed_width > 0' failed
> IA__gdk_window_get_state: assertion 'GDK_IS_WINDOW (window)' failed
> 
> (gdb) backtrace
> #0  0x00007ffff6acf4bc in ____strtoll_l_internal () at /lib64/libc.so.6
> #1  0x00007ffff6acb710 in atoi () at /lib64/libc.so.6
> #2  0x0000000000730692 in pan::DataImpl::load_headers(pan::DataIO const&,
> pan::Quark const&) (this=0x7fffffffd340, data_io=..., group=...)
>     at headers.cc:573

Ok, I'm not familiar with this code and I also haven't tried it in a
debugger, but here is some analysis from just observing.

If in frame # atoi() crashes, it must have gotten a bad pointer (such as
NULL). It gets it from line 573 in headers.cc:

          if (gotline && !expired)
          {
            StringView tok;
            s.ltrim ();
            s.pop_token (tok);
            const int number (atoi (tok.str)); <<< here

s is also a StringView, and pop_token puts the next word from it in tok:

bool
StringView :: pop_token (StringView& token, char delimiter)
{
   const bool got_token (len != 0);
   const char * pch = strchr (delimiter);
   if (pch) {
     token.str = str;
     token.len = pch - str;
     len -= token.len+1;
     str += token.len+1;
   } else {
     token.str = str;
     token.len = len;
     str = 0;
     len = 0;
   }
   return got_token;
}

token.src can never be a NULL pointer unless (this.)str already is NULL.

It looks like s.ltrim() can leave the str pointer NULL, if the string is
empty after trimming whitespace:

void
StringView :: ltrim ()
{
  // strip leading whitespace
  if (!empty()) {
    ..blah..
    eat_chars (p-str);
  }
}

void
StringView :: eat_chars (size_t n)
{
  n = std::min (n, len);
  len -= n;
  str = len ? str+n : 0;	<<<< here: can set to NULL
}

For this case, it would probably to to check tok.empty() before doing
calling atoi (tok.str).

I'm not sure what input it's trying to parse there: input from an nntp
server, or data that Pan wrote to a file earlier. In any case, clearly
it needs more checks. There are several other cases a bit earlier in the
file where atoi(tok.str) is called without checking if the token is
valid or not...

-Olaf.
-- 
___ "Buying carbon credits is a bit like a serial killer paying someone else to
\X/  have kids to make his activity cost neutral." -The BOFH    falu.nl@rhialto

_______________________________________________
Pan-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/pan-users
signature.asc (application/pgp-signature, 488 B)
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEFVAhiiWjqgwBVdQAmYnGRWHD+9MFAmIJEdcACgkQmYnGRWHD
+9O1pgf/dH3b7sFWS2OT+sZQuymBOL4gH5QrMOmD2gBC0OCG1JgkuPhShyo956QE
kDBMFQi+5FMkbd9TRQNgwsCdmebpF7WV34nvWk/0/nyWSvI7Q5MnsOhwNfppJVd2
IXKwx1VoQnXMjdRxYBCX3lFuHqr2mMKjzSG+NEeI8ruQxo6ZeXdKChuYaMoiICUh
TTfkUlWOw3Xjv/ChEa7xyLduD2ry4srxUACK7ACuVsE8R290cr+fzYfG2yXVv6NO
bDe56KcH/K5vuwuN9qAUuWnZKbHsN2pH1JT6Ct0c9Bp9eK/FNhH0+uvScz9NFyiv
0TCYyVvkPVluZJRJXDSEEQlmnZCB9g==
=PdHG
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.