Re: [hatari-devel] Natfeats regression?

[ Thread Index | Date Index | More Archives ]


On 17.6.2022 16.20, Thorsten Otto wrote:
On Freitag, 17. Juni 2022 13:04:08 CEST Eero Tamminen wrote:
What do you think of the attached patch?

The first change looks ok, but the assertion seems to be wrong. assert() will
terminate the emulator (and only if compiled with DEBUG), not the faulty Atari

Basically, if i understand the code correctly, first a quick check for a valid
area is made (presumably because that is the common case, and faster than the
2nd loop; otherwise the first check would be superfluous).


If the first check
fails, it drops into checking whether at least part of the supplied area is
accessible. If that fails too, you should generate a bus-error instead of the

First check is for valid start address, and returning error if not.

Second check is for whether also following 4KB is within valid area, and if yes, returning len (or bus error, if string is not terminated within 4KB).

And when start address is valid, but start + 4KB is not, 3rd check is for whether string ends with valid area (=> len) or not (=> bus error).

End of function should never be reached, as above should cover all cases. That's why there's assert. Alternatively it could be e.g. exit(1), but IMHO assert is nicer.

And would some other exception than bus error be suitable for such issues?

buserror is correct, since that is what you also would get on real machines
when passing invalid addresses. After all, the purpose of these checks is just
to make sure that a faulty Atari program does not crash the emulator.

	- Eero

Mail converted by MHonArc 2.6.19+