qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug 1894029] [NEW] qemu-i386 malloc error


From: Tony.LI
Subject: [Bug 1894029] [NEW] qemu-i386 malloc error
Date: Thu, 03 Sep 2020 04:12:10 -0000

Public bug reported:

Hi!I use qemu-i386-static on 64 bit machines.And memory request succeeded, but 
the pointer is wrong.
This is my test program:

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

int main(int argc, char **argv)
{
        void *pa=0,*pb=0,*pc=0,*pd=0;
        pa = malloc(sizeof(uint32_t));
        pb = malloc(sizeof(uint32_t));
        pc = malloc(4);
        pd = malloc(4);
        printf("pa: 0x%x\n",pa);
        printf("pb: 0x%x\n",pb);
        printf("pc: 0x%x\n",pc);
        printf("pd: 0x%x\n",pd);
        printf("uint32_t:%d\n",sizeof(uint32_t));
        free(pa);
        free(pb);
        free(pc);
        free(pd);
        return 0;
}

And it is wrong:

pa: 0x400051a0
pb: 0x400051b0
pc: 0x400051c0
pd: 0x400051d0
uint32_t:4

Why did I apply for 4 bytes of space, but the pointer only increased by 2 
bytes??
Is it a BUG??

** Affects: qemu
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1894029

Title:
  qemu-i386 malloc error

Status in QEMU:
  New

Bug description:
  Hi!I use qemu-i386-static on 64 bit machines.And memory request succeeded, 
but the pointer is wrong.
  This is my test program:

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

  int main(int argc, char **argv)
  {
          void *pa=0,*pb=0,*pc=0,*pd=0;
          pa = malloc(sizeof(uint32_t));
          pb = malloc(sizeof(uint32_t));
          pc = malloc(4);
          pd = malloc(4);
          printf("pa: 0x%x\n",pa);
          printf("pb: 0x%x\n",pb);
          printf("pc: 0x%x\n",pc);
          printf("pd: 0x%x\n",pd);
          printf("uint32_t:%d\n",sizeof(uint32_t));
          free(pa);
          free(pb);
          free(pc);
          free(pd);
          return 0;
  }

  And it is wrong:

  pa: 0x400051a0
  pb: 0x400051b0
  pc: 0x400051c0
  pd: 0x400051d0
  uint32_t:4

  Why did I apply for 4 bytes of space, but the pointer only increased by 2 
bytes??
  Is it a BUG??

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]