[PATCH] Make const ptr assign as function call in clang

余生与君 lovesykun at gmail.com
Sun Oct 10 01:58:44 UTC 2021


On Sun, Oct 10, 2021 at 4:34 AM Denys Vlasenko <vda.linux at googlemail.com> wrote:
>
> On Sat, Oct 9, 2021 at 8:20 PM LoveSy <lovesykun at gmail.com> wrote:
> >
> > From: YU Jincheng <shana at zju.edu.cn>
> >
> > - This can act as memory barrier in clang to avoid
> >   read before assign of a const ptr
> >
> > Signed-off-by: LoveSy <shana at zju.edu.cn>
>
> git tree commit hook requires something of the form "Name Surname"
> in the signed-off lines. Can you use a name of this format?

Sorry about this. I will update it.

> I propose the attached patch. Please test that it works on clang 9.

It works.

> I assume we will need to massage every SET_PTR_TO_GLOBALS(xzalloc(sz))
> to something like XZALLOC_PTR_TO_GLOBALS(sz) too?
> The bug may be occurring there as well, right?

You remind me about this. And I award that in some scenarios
SET_PTR_TO_GLOBALS receives a stack object. And it also breaks the
thing.

I personally prefer making `barrier` as a function since it also makes
ASSIGN_GLOBAL_PTR work as expected. Otherwise, future usage of
ASSIGN_GLOBAL_PTR will also bring back this issue.


More information about the busybox mailing list