I can reproduce the issue with cmake and see the debugger indicating the
illegal instruction occurs in cmake when trying to memset() an 8 aligned
buffer.

The following also does a memset() on an 8 aligned buffer but does not
crash:

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>

#define OFFSET 0x8

int main(void) {
        printf("Starting test\n");

        size_t alignment = 128;
        size_t size = 1024;
        char *ptr = NULL;
        char *new_ptr;

        ptr = aligned_alloc(alignment, size);
        if (ptr == NULL) {
                fprintf(stderr, "Memory allocation failed\n");
                return EXIT_FAILURE;
        }

        new_ptr = ptr + OFFSET;
        memset(new_ptr, 0xff, size - OFFSET);
        free(ptr);
        return EXIT_SUCCESS;
}

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2133188

Title:
  Illegal instruction in memset under qemu-user for riscv64

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/2133188/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to