[OT] OT: Null checks.
Timon Gehr
timon.gehr at gmx.ch
Sun May 4 20:28:45 UTC 2025
On 5/4/25 19:34, Walter Bright wrote:
>
>
>> while still not acknowledging that segfaults are useless and
>> unworkable in practically relevant cases.
>
> Worst case, you can write a signal handler for any of the signals that
> can be generated (not just null pointer signals), and have the handler
> write all it can to a file that can be emailed to you.
>
> You can also hook atexit() as maybe your program is exiting that way.
I just remembered like half a year ago I have also seen a crash once in
```
private void _enforceNoOverlap(const char[] action,
uintptr_t ptr1, uintptr_t ptr2, const size_t bytes)
{
const d = ptr1 > ptr2 ? ptr1 - ptr2 : ptr2 - ptr1;
if (d >= bytes)
return;
const overlappedBytes = bytes - d;
UnsignedStringBuf tmpBuff = void;
string msg = "Overlapping arrays in ";
msg ~= action;
msg ~= ": ";
msg ~= overlappedBytes.unsignedToTempString(tmpBuff);
msg ~= " byte(s) overlap of ";
msg ~= bytes.unsignedToTempString(tmpBuff);
assert(0, msg);
}
```
Unfortunately I had accidentally detached my debugger instead of getting
the backtrace at the time. It is possible that this is what is happening
on the user's machine, but I don't know. And I also have no idea where
this overlap might occur.
This just gives an invalid instruction even in dubs "release-debug"
builds by default unless using a custom druntime build. I just don't
think this should ever happen to anyone, even if there is some
workaround, by default people will run into this at least once and
perhaps they will not be as lucky as me and see it with a debugger attached.
More information about the Digitalmars-d
mailing list