Skip to content

undefined behavior: runtime error: applying zero offset to null pointer #609

@jktjkt

Description

@jktjkt

With 1343e4c, some versions of ASAN report the following error from the test suite:

CzechLight/dependencies/libnetconf2/src/session.c:1259:24: runtime error: applying zero offset to null pointer
    #0 0x52806a in nc_str_append CzechLight/dependencies/libnetconf2/src/session.c:1259:24
    #1 0x522df3 in _nc_server_get_cpblts_version CzechLight/dependencies/libnetconf2/src/session.c:1448:9
    #2 0x525016 in nc_send_hello_io CzechLight/dependencies/libnetconf2/src/session.c:1632:18
    #3 0x52425f in nc_handshake_io CzechLight/dependencies/libnetconf2/src/session.c:1822:12
    #4 0x5569a3 in nc_accept_inout CzechLight/dependencies/libnetconf2/src/session_server.c:1537:15
    #5 0x62f5fe in server_thread CzechLight/dependencies/libnetconf2/tests/test_thread_messages.c:81:5
    #6 0x7f4130cd5946 in start_thread /usr/src/debug/glibc-2.37-18.fc38.x86_64/nptl/pthread_create.c:444:8
    #7 0x7f4130d5b96f in __GI___clone3 ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior CzechLight/dependencies/libnetconf2/src/session.c:1259:24 in

...and indeed, on a quick glance, it looks like a real problem because the code is indeed adding some offset to a NULL pointer. This used to work OK with 39f341a.

Metadata

Metadata

Assignees

No one assigned

    Labels

    is:bugBug description.status:completedFrom the developer perspective, the issue was solved (bug fixed, question answered,...)

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions