Giter Club home page Giter Club logo

Comments (3)

umarcor avatar umarcor commented on May 31, 2024 1

A little update just to let you know that a fix for the reported bug was already committed to master:

from mambo.

lgeek avatar lgeek commented on May 31, 2024

Last time I've tried to run MAMBO using qemu user mode emulation, I've ran into numerous qemu bugs. Use native hardware or system mode emulation. The assertion at elf_loader/elf_loader.c:127 should never fail when running natively. I'm curious to see what's causing it to fail in qemu, but I don't have a debug build available at the moment.

$ ./test/mmap_munmap 
mmap_munmap: mmap_munmap.c:33: main: Assertion `alloc == MAP_FAILED' failed.
qemu: uncaught target signal 6 (Aborted) - core dumped
Aborted (core dumped)

That's a qemu bug. Please report it to them. According to the mmap manual:

If len is zero, mmap() shall fail and no mapping shall be established.

from mambo.

umarcor avatar umarcor commented on May 31, 2024

Indeed, I stripped down mmap_munmap to:

#include <stdlib.h>
#include <assert.h>
#include <sys/mman.h>
#include <errno.h>
#include <stdio.h>

int main() {
  // Failing allocation
  void *alloc = mmap(NULL, 0, PROT_EXEC | PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
  
  printf("alloc: %d\n", alloc);
  printf("MAP_FAILED: %d\n", MAP_FAILED);
  printf("errno: %d\n", errno);
  
  assert(alloc == MAP_FAILED);

  return 0;
}

I cross compiled in x86_64:

aarch64-linux-gnu-gcc -static -std=gnu99 -lpthread test/mmap_qemu.c -o mmap_qemu

This is the output in x86_64:

$ ./mmap_qemu 
alloc: 0
MAP_FAILED: -1
errno: 0
mmap_qemu: test/mmap_qemu.c:15: main: Assertion `alloc == MAP_FAILED' failed.
qemu: uncaught target signal 6 (Aborted) - core dumped
Aborted (core dumped)

This is the output in a Jetson TX1:

$ ./mmap_qemu 
alloc: -1
MAP_FAILED: -1
errno: 22

So, as you said, qemu is not handling mmap properly. It is returning a success (0) when it should be returning a failure (-1, MAP_FAILED). I reported it to them: https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1783362

I'm closing this for now. Thanks!

from mambo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.