tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: NULL pointer arithmetic issues



On 08.03.2020 18:11, Joerg Sonnenberger wrote:
> On Sun, Mar 08, 2020 at 03:30:02PM +0100, Kamil Rytarowski wrote:
>> NULL+x is now miscompiled by Clang/LLVM after this commit:
>>
>> https://reviews.llvm.org/rL369789
>>
>> This broke various programs like:
>>
>> "Performing base + offset pointer arithmetic is only allowed when base
>> itself is not nullptr. In other words, the compiler is assumed to allow
>> that base + offset is always non-null, which an upcoming compiler
>> release will do in this case. The result is that CommandStream.cpp,
>> which calls this in a loop until the result is nullptr, will never
>> terminate (until it runs junk data and crashes)."
> 
> As you said, using a non-zero offset. Noone here argued that using
> non-zero offsets is or should be valid since that would obviously create
> a pointer outside the zero-sized object.
> 
> Joerg
> 

We catch NULL + x at least here:

Undefined Behavior in t_subr_prf.c:179:9, pointer expression with base 0
overflowed to 0x14
Undefined Behavior in t_subr_prf.c:179:9, pointer expression with base 0
overflowed to 0xa

Attachment: signature.asc
Description: OpenPGP digital signature



Home | Main Index | Thread Index | Old Index