Hello,
when running cccc on x86_64 archi with a filename that has no extension, it crashes. The core give the following info:
(gdb) bt
(...)
#7 0x00007f4e0b809b93 in std::string::substr(unsigned long, unsigned long) const () from /usr/lib/libstdc++.so.6
#8 0x000000000043ec41 in CCCC_Options::getFileLanguage (filename=...) at cccc_opt.cc:229
#9 0x00000000004374b0 in Main::ParseFiles (this=0xb40ca0) at ccccmain.cc:354
#10 0x000000000043856f in main (argc=2, argv=0x7fff215ed878) at ccccmain.cc:725
(gdb) frame 8
#8 0x000000000043ec41 in CCCC_Options::getFileLanguage (filename=...) at cccc_opt.cc:229
229 extension=filename.substr(extpos);
(gdb) list
226 unsigned int extpos=filename.rfind(".");
227 if(extpos!=string::npos)
228 {
229 extension=filename.substr(extpos);
(gdb) p extpos
$1 = 4294967295
(gdb) p filename
$2 = (const std::string &) @0x7fff215ed6d0: {static npos = 18446744073709551615,
_M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0xb42468 "basic/CVS"}}
Obviously the problem come from the usage of unsigned int for extpos when the good type is size_t.
So simple patch would be in cccc_opt.cc:226:
<unsigned int extpos=filename.rfind(".");
>size_t extpos=filename.rfind(".");
Regards,
Colin
Is it possible that this bug related to the one I have been seeing on Ubuntu recently? Full details of that are on lunchpad under bug #1504454.
Apport gave the stack trace for the problem as:
Ubuntu gives the version I am using as cccc 1:3.1.4-6
Yes, that's the same bug. I'm applying this patch for my next Debian upload.