Closed vt-alt closed 10 months ago
I see. There should be a <cstdint>
, but I don't see it.
I'll commit an update.
Thanks! (BTW, I'd suggest you to add fedora:rawhide
(or alt:sisyphus
) container build to GA CI, as it have fresher versions of compilers, etc. which have more checks.)
Build error is not fixed. You added #include <cstdint>
to the line 221
but error is earlier on line 188
.
Btw (if I move include above) there is also crash:
+ cd ugrep-indexer-0.9.3
+ bin/ugrep-indexer -I -v
free(): double free detected in tcache 2
backtrace in gdb:
(gdb) bt
#0 0x00007ffff7a0967c in ?? () from /lib64/libc.so.6
#1 0x00007ffff79ba982 in raise () from /lib64/libc.so.6
#2 0x00007ffff79a34ef in abort () from /lib64/libc.so.6
#3 0x00007ffff79a439d in ?? () from /lib64/libc.so.6
#4 0x00007ffff7a130c7 in ?? () from /lib64/libc.so.6
#5 0x00007ffff7a15401 in ?? () from /lib64/libc.so.6
#6 0x00007ffff7a17a9f in free () from /lib64/libc.so.6
#7 0x00007ffff79f2b23 in fclose () from /lib64/libc.so.6
#8 0x000055555555ceac in Stream::close (this=0x7ffffffde230) at /usr/src/RPM/BUILD/ugrep-indexer-0.9.3/src/ugrep-indexer.cpp:353
#9 Stream::~Stream (this=<optimized out>, this=<optimized out>) at /usr/src/RPM/BUILD/ugrep-indexer-0.9.3/src/ugrep-indexer.cpp:342
#10 0x00005555555647a3 in indexer (pathname=<optimized out>) at /usr/src/RPM/BUILD/ugrep-indexer-0.9.3/src/ugrep-indexer.cpp:1818
#11 0x0000555555558286 in main (argc=<optimized out>, argv=<optimized out>) at /usr/src/RPM/BUILD/ugrep-indexer-0.9.3/src/ugrep-indexer.cpp:1887
The two problems should be fixed now. I've made a change so that the fclose()
is followed by a NULL
assignment, which should take care of the issue. That's how I normally approach the open-close pairings.
Thank you, now it works!
ps. Another thought, you may add -fanalyzer
to new gcc (13) to get more static analysis. Current output (only warning:
lines, but there also some explanations):
/usr/include/c++/13/bits/basic_string.h:1596:24: warning: leak of 'opendir (MEM[(const struct basic_string *)pathname_63(D)]._M_dataplus._M_p)' [CWE-401] [-Wanalyzer-malloc-leak]
/usr/include/c++/13/bits/basic_string.h:1060:16: warning: leak of 'opendir (MEM[(const struct basic_string *)pathname_63(D)]._M_dataplus._M_p)' [CWE-401] [-Wanalyzer-malloc-leak]
/usr/include/c++/13/bits/basic_string.h:1060:16: warning: leak of 'opendir (MEM[(const struct basic_string *)pathname_63(D)]._M_dataplus._M_p)' [CWE-401] [-Wanalyzer-malloc-leak]
ugrep-indexer.cpp:296:5: warning: use of uninitialized value '__first_4' [CWE-457] [-Wanalyzer-use-of-uninitialized-value]
ugrep-indexer.cpp:275:5: warning: use of uninitialized value 'this_7(D)' [CWE-457] [-Wanalyzer-use-of-uninitialized-value]
ugrep-indexer.cpp:275:5: warning: use of uninitialized value 'this_7(D)' [CWE-457] [-Wanalyzer-use-of-uninitialized-value]
ugrep-indexer.cpp:275:5: warning: use of uninitialized value 'this_7(D)' [CWE-457] [-Wanalyzer-use-of-uninitialized-value]
ugrep-indexer.cpp:275:5: warning: use of uninitialized value 'this_7(D)' [CWE-457] [-Wanalyzer-use-of-uninitialized-value]
I didn't check if these aren't false positives. So this is of course not a bug report.
I've used analysis before, but in this case warnings seem off to me (false positives). The opendir()
is always followed by a closedir()
. There is no intervening return
or exception. I always mentally form a model of the code in my mind to avoid these potential issues. Note that the opendir()
call keeps an internal static state, which is likely the source of this warning.
When building 0.9.2 on ALT Linux there is build error:
0.9.1 was building ok.