Sujet : Re: Memory protection between compilation units?
De : mateusz (at) *nospam* x.invalid (Mateusz Viste)
Groupes : comp.lang.cDate : 13. Jun 2025, 07:59:27
Autres entêtes
Organisation : ...
Message-ID : <20250613085927.7b7cb344@mateusz>
References : 1 2
User-Agent : Claws Mail 4.2.0 (GTK 3.24.43; x86_64-suse-linux-gnu)
On Thu, 12 Jun 2025 06:05 Tim Rentsch wrote:
The code in question shows several classic error patterns. In no
particular order:
* buffer overflow
* off-by-one error
I'd consider that one item, since one leads to another.
* bitwise operator with signed operand
My mistake. Real code is acting on something else than an int, I wasn't
paying enough attention when writing the illustrative example.
* using & to effect what is really a modulo operation
You think of it as modulo, I think of it as "bits trimming".
Essentially same operation, but different viewpoints I guess.
I acknowledge that this response isn't exactly an answer to the
original question. It does illustrate though a kind of thinking
that can be useful when trying to track down hard-to-find bugs.
Thank you for your insightful remarks. I completely agree - the best
way to debug a program is to avoid the need for debugging in the first
place. :-) But working with a large, 15-year-old codebase that has
seen contributions from dozens of programmers makes things a bit
non-ideal sometimes.
Mateusz