Skip to content

ubsan complains on rpcgen-generated code, gcc's one silent #92108

Open
@stsp

Description

@stsp

It appears, clang's ubsan complains on
an rpcgen-generated code, while gcc's
ubsan is silent.
The code roughly looks like this (reduced test-case):

#include <stddef.h>

struct svc_req;

static int
_a_1 (void *argp, void *result, struct svc_req *rqstp)
{
        return 0;
}

int main()
{
        int (*local)(char *, void *, struct svc_req *);
        local = (int (*) (char *, void *,  struct svc_req *))_a_1;
        return local(NULL, NULL, NULL);
}

Now do this:

$ gcc -Wall -fsanitize=undefined tst.c 
$ ./a.out
$ clang -Wall -fsanitize=undefined tst.c 
$ ./a.out
tst.c:15:9: runtime error: call to function _a_1 through pointer to incorrect function type 'int (*)(char *, void *, struct svc_req *)'
tst.c: note: _a_1 defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior tst.c:15:9

As can be seen, only clang complained.
I don't know if it is a real UB or a false-positive.
But as gcc keeps silence, I assume this is
a false-positive.
There is no way to "just fix" the code, as it
is generated by rpcgen.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions