Removing bugs from bug free functions
Moderators: hgm, Rebel, chrisw
-
- Posts: 12540
- Joined: Wed Mar 08, 2006 8:57 pm
- Location: Redmond, WA USA
Re: Removing bugs from bug free functions
Do you have a public repository?
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
-
- Posts: 362
- Joined: Thu Mar 16, 2006 7:39 pm
- Location: Portugal
- Full name: Alvaro Cardoso
Re: Removing bugs from bug free functions
Thanks Dann for the helping spirit, I dont have a public repository because I'm competing against two other programs, Triturator from Spain and Aurora Borealis from Russia.
It's OK, I've been making a match against Aurora Borealis from Russia, I think we have played more than 70 games from a total of 98 games at 30 minutes plus 20 seconds, and my engine has won I think more than 10 games with zero losses, I think 2 wins were from testing games with critical openings. My friend Herson from Costa Rica keeps all the records from the ongoing match not yet published.
http://damasclasicas.blogspot.com/
My engine didn't crash a single time during the match and never made a blunder so I guess we can't rule out the possibility of MVC compiler having bugs.
-
- Posts: 560
- Joined: Sun Nov 08, 2015 11:10 pm
Re: Removing bugs from bug free functions
Raise stack reserve size. Inlining this function causes stack overflow.
-
- Posts: 2487
- Joined: Tue Aug 30, 2016 8:19 pm
- Full name: Rasmus Althoff
Re: Removing bugs from bug free functions
Yes, that's typical for undefined behaviour. With optimisations enabled, the compiler is just more likely to make assumptions that no undefined behaviour exists and omit code parts or situations that would imply undefined behaviour. That can be e.g. signed integer wrap-around, or some shift operation that is at least as wide as the data type. Like, shifting a 64 bit integer by 64 bit or more. Adding or omitting any code may prevent such an optimisation in a specific case by sheer accident.
You could try raising the warning level, see https://docs.microsoft.com/en-us/cpp/bu ... ew=vs-2019 , and using the free static code checker CppCheck, see http://cppcheck.sourceforge.net/ .
Rasmus Althoff
https://www.ct800.net
https://www.ct800.net
-
- Posts: 12540
- Joined: Wed Mar 08, 2006 8:57 pm
- Location: Redmond, WA USA
Re: Removing bugs from bug free functions
I highly recommend CLANG not for compiling, which is just on par with gcc, but as a free Lint, because the error checking is so good.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
-
- Posts: 1784
- Joined: Wed Jul 03, 2019 4:42 pm
- Location: Netherlands
- Full name: Marcel Vanthoor
Re: Removing bugs from bug free functions
This is strange. "if (4 == 5) doSomething()" is the same as "if (false) doSomething()". You have an unreachable branch.Cardoso wrote: ↑Tue Jun 16, 2020 6:46 pm So I guess I'm going back to the faster way of fixing this with the code:Code: Select all
if (4 == 5) PrintGeneralText(" 4 == 5 ");
In Rust, the compiler will warn you about that, and proceed to strip it from the code. Having it in there or not would make no difference to the final program. I would expect that a C or C++ compiler does the same. In case of CLANG, it probably will, because CLANG and rustc both compile down to LLVM intermittent code, where the LLVM backend takes over for optimization. I don't know about GCC-compilers or MSVC.
-
- Posts: 2555
- Joined: Fri Nov 26, 2010 2:00 pm
- Location: Czech Republic
- Full name: Martin Sedlak
Re: Removing bugs from bug free functions
if you can use VS2019 and do a 32-bit build, you can try to enable ASAN (finally) to see if it detects any problems. 64-bit ASAN will come in the next version I think.
One can never rule out compiler bugs, but these are rare. Also don't forget that in debug mode everything is pre/post-filled with specific patterns (I'm talking Microsoft compiler here), like uninitialized memory has a specific filler, freed memory another and so on => this might explain the difference between debug and release build.
One can never rule out compiler bugs, but these are rare. Also don't forget that in debug mode everything is pre/post-filled with specific patterns (I'm talking Microsoft compiler here), like uninitialized memory has a specific filler, freed memory another and so on => this might explain the difference between debug and release build.
Martin Sedlak
-
- Posts: 300
- Joined: Mon Apr 30, 2018 11:51 pm
Re: Removing bugs from bug free functions
Or you can use Clang, which has 64-bit ASan (also on Windows).
-
- Posts: 362
- Joined: Thu Mar 16, 2006 7:39 pm
- Location: Portugal
- Full name: Alvaro Cardoso
Re: Removing bugs from bug free functions
Thank you all for your help, as soon as I get some free time I'll try again.
best regards,
Alvaro
best regards,
Alvaro
-
- Posts: 385
- Joined: Sat Feb 04, 2017 11:57 pm
- Location: USA
Re: Removing bugs from bug free functions
I agree with Bob. Put in assert() in every method to test the passed parameters. Square numbers, color, etc. assert()s will automatically commented out when you build for performance. assert() has saved my "ass" so many times! LOLbob wrote: ↑Tue Jun 16, 2020 6:26 am That isn't a bug-free function most likely. Typically when you can add code and hide the bug, look for uninitialized data that moves around on the stack depending on what extra code you insert...
In your case, function parameters can be wrong as well. IE you reference arrays using subscripts that might be invalid. I'd start by inserting code (or asserts) to verify that every argument is valid every time you call the thing.
i7-6700K @ 4.00Ghz 32Gb, Win 10 Home, EGTBs on PCI SSD
Benchmark: Stockfish15.1 NNUE x64 bmi2 (nps): 1277K
Benchmark: Stockfish15.1 NNUE x64 bmi2 (nps): 1277K