3107: Log close error to console r=Jupeyy a=def-



3155: Add memcheck/asan/ubsan to readme r=Jupeyy a=def-

To be linked from https://github.com/ddnet/ddnet/pull/3133

Co-authored-by: def <dennis@felsin9.de>
This commit is contained in:
bors[bot] 2020-10-26 02:42:03 +00:00 committed by GitHub
commit b17fb2827c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View file

@ -111,6 +111,25 @@ sudo cp *.a /usr/lib
To run the tests you must target `run_tests` with make: To run the tests you must target `run_tests` with make:
`make run_tests` `make run_tests`
Using AddressSanitizer + UndefinedBehaviourSanitizer or Valgrind's Memcheck
---------------------------------------------------------------------------
ASan+UBSan and Memcheck are useful to find code problems more easily. Please use them to test your changes if you can.
For ASan+UBSan compile with:
```bash
CC=clang CXX=clang++ CXXFLAGS="-fsanitize=address,undefined -fsanitize-recover=address,undefined -fno-omit-frame-pointer" CFLAGS="-fsanitize=address,undefined -fsanitize-recover=address,undefined -fno-omit-frame-pointer" cmake -DCMAKE_BUILD_TYPE=Debug .
make
```
and run with:
```bash
UBSAN_OPTIONS=log_path=./SAN:print_stacktrace=1:halt_on_errors=0 ASAN_OPTIONS=log_path=./SAN:print_stacktrace=1:check_initialization_order=1:detect_leaks=1:halt_on_errors=0 ./DDNet
```
Check the SAN.\* files afterwards. This finds more problems than memcheck, runs faster, but requires a modern GCC/Clang compiler.
For valgrind's memcheck compile a normal Debug build and run with: `valgrind --tool=memcheck ./DDNet`
Expect a large slow down.
Building on Windows with Visual Studio Building on Windows with Visual Studio
-------------------------------------- --------------------------------------

View file

@ -287,6 +287,7 @@ int CGetFile::OnCompletion(int State)
{ {
if(m_File && io_close(m_File) != 0) if(m_File && io_close(m_File) != 0)
{ {
dbg_msg("http", "i/o error, cannot close file: %s", m_aDest);
State = HTTP_ERROR; State = HTTP_ERROR;
} }