Deutsch   English   Français   Italiano  
<20250613085927.7b7cb344@mateusz>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: Mateusz Viste <mateusz@x.invalid>
Newsgroups: comp.lang.c
Subject: Re: Memory protection between compilation units?
Date: Fri, 13 Jun 2025 08:59:27 +0200
Organization: ...
Lines: 31
Message-ID: <20250613085927.7b7cb344@mateusz>
References: <20250611153239.6bc43323@mateusz>
	<86wm9hp0u2.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 13 Jun 2025 08:59:27 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="be0ae288ae1b46b70a4e7a2b5ac6f308";
	logging-data="3444324"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+oJCWwDgaEPnsiPwHz5xq3"
Cancel-Lock: sha1:2/Hi2PcL84w+Au5CQPQZXYO/4NA=
X-Newsreader: 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