soundiness / soundiness.github.io

10 stars 3 forks source link

Adding relative pointers to the list of C/C++ unsound behaviors #8

Open adriaanjacobs opened 1 year ago

adriaanjacobs commented 1 year ago

Relative pointers, although common, are a problematic construct in C/C++, as they blur the line between pointer assignment and pointer arithmetic. Points-to analyses need to handle these very differently: assignment involves adding new objects to the points-to set, whereas pointers are assumed to remain pointed to the same object after arithmetic (barring field-sensitive analysis).

Relative pointers present themselves as arithmetic in source code, yet have the semantics of assignment. At the same time, it is impossible (to my knowledge) to comprehensively identify relative pointers statically, in part due to the incompleteness of points-to analysis. Thus, to remain useful, a points-to analysis must necessarily assume that arithmetic is not relative pointer assignment, and unsoundly model its behavior.

Would it be okay to add this construct to the list of unsound behaviors? I'd be happy to make a pull request.

msridhar commented 1 year ago

I'm not an expert on C/C++ relative pointers (maybe @yanniss knows more?) but I'm fine with adding this construct to the list. A PR would be welcome!