[Tarantool-patches] [PATCH luajit 1/2] build: introduce LUAJIT_USE_UBSAN option
Sergey Kaplun
skaplun at tarantool.org
Mon May 27 10:22:08 MSK 2024
Hi, Maxim!
Thanks for the review!
On 26.05.24, Maxim Kokryashkin wrote:
> Hi, Sergey!
> See my thoughts below.
>
> On Thu, May 16, 2024 at 01:14:14PM UTC, Sergey Kaplun wrote:
> > Hi, folks!
> > Some more thoughts below.
> >
> > On 15.05.24, Sergey Kaplun wrote:
> >
> > <snipped>
> >
> > > + string(JOIN "," UBSAN_IGNORE_OPTIONS
> > > + # Misaligned pseudo-pointers are used to determine internal
> > > + # variable names inside the `for` cycle.
> > > + alignment
> > > + # Not interested in float cast overflow errors.
> > > + float-cast-overflow
> > > + # NULL checking is disabled because this is not a UB and
> > > + # raises lots of false-positive fails.
> > > + null
> >
> > Maybe it is worth to add also "nonnull-attribute" to the ignore options:
> >
> > ```
> > LSAN_OPTIONS="abort_on_error=1" src/luajit -e 'error("bad usage", 3)'
> > /home/burii/builds_workspace/luajit/gh-8473-ubsan/src/lj_buf.h:75:25: runtime error: null pointer passed as argument 1, which is declared to never be null
> > /usr/include/string.h:44:28: note: nonnull attribute specified here
> > ```
> >
> > Here, `memcpy()` gets the NULL pointer as the first argument and the
> > `len` == 0. So there are no problems here. Also, the nullability
> > violation is not a UB, as mentioned in the documentation.
>
> It is UB, though: https://en.cppreference.com/w/cpp/string/byte/memcpy
> Even with the zero len it may still cause issues, so I don't think we
> should disable this check.
But there are no such words in the `memcpy` man page. The only one
mentioned UB is about overlapping memory chunks. Also, I suppose that
the first point applies only to the case, when the bytes are actually
copied (i.e., when size is not zero).
>
> > Thoughts?
> >
> > > + # Not interested in checking arithmetic with NULL.
> > > + pointer-overflow
> > > + # Shifts of negative numbers are widely used in parsing ULEB,
> > > + # cdata arithmetic, vmevent hash calculation, etc.
> > > + shift-base
> > > + )
> >
> > --
> > Best regards,
> > Sergey Kaplun
--
Best regards,
Sergey Kaplun
More information about the Tarantool-patches
mailing list