Memory safe in D

Steven Schveighoffer schveiguy at gmail.com
Tue Mar 12 13:57:41 UTC 2024


On Tuesday, 12 March 2024 at 03:28:54 UTC, Walter Bright wrote:
> On 3/11/2024 12:43 PM, Steven Schveighoffer wrote:
>> The explanation is that D is expecting the memory hardware to 
>> fault when you dereference null. We know that this is not the 
>> case for all situations
>
> In particular, when a constant is added to the null reference 
> that is large enough to skip over the protected pages in the 
> memory space.

I may have mentioned this before, but the way to fix this is in 
`@safe` code, before each reference with a constant offset that 
you know to be greater than one page, validate the root pointer 
is not null.

FWIW, I was actually talking about environments where the null 
page does not segfault, like in a kernel.

-Steve


More information about the Digitalmars-d mailing list