<!DOCTYPE html>
<html data-lt-installed="true">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body style="padding-bottom: 1px;">
<p>Hi, Sergey,<br>
</p>
<div class="moz-cite-prefix">On 16.05.2024 13:14, Sergey Kaplun
wrote:<br>
</div>
<blockquote type="cite" cite="mid:ZkXcdiGz0NUUyFkG@root">
<pre class="moz-quote-pre" wrap="">Hi, folks!
Some more thoughts below.
On 15.05.24, Sergey Kaplun wrote:
<snipped>
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">+ 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
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">
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.
Thoughts?</pre>
</blockquote>
<p>I agree with arguments provided by Maxim - it's UB, the standard
states it clearly,<br>
</p>
<p>and it should be fixed. I propose to do the following:</p>
<p>- suppress the check (add it to UBSAN_IGNORE_OPTIONS) with
appropriate comment</p>
<p>(something like "we know it is bad, but it is unfixed in
upstream, we will wait a fix").</p>
<p>Probably we should suppress it per file like you did with other
checks.<br>
</p>
<p>- send a fix to upstream or submit an issue to the upstream (I'll
not insist, but it would be desirable)<br>
</p>
<blockquote type="cite" cite="mid:ZkXcdiGz0NUUyFkG@root">
<pre class="moz-quote-pre" wrap="">
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">+ # 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
+ )
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">
</pre>
</blockquote>
</body>
<lt-container></lt-container>
</html>