Skip to content

blink_copy undefined behavior #121

@ghost

Description

blink_copy uses memcpy which executes undefined behavior for overlapping memories [1] [2]. We do indeed have overlapping memories (in at least CCA). The tests pass on Windows, but that's not guaranteed to happen. The CCA test definitely fails on Linux. For now, I've added a commit (7e27886) to allow Linux to use memmove instead of memcpy. Historically, memmove has been slower than memcpy, and it probably still is, but both have a time complexity of O(N) so I would suggest using memmove for the Windows implementation as well. Alternatively the compiler could figure out when to use memmove instead of memcpy. And worst case scenario, we could just rely on undefined behavior in Windows.

[1] - https://msdn.microsoft.com/en-us/library/dswaw1wk.aspx
[2] - http://man7.org/linux/man-pages/man3/memcpy.3.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions