我是Ubuntu的新手,我遇到了一些内存泄漏问题,似乎它们不是来自我的代码。他们从哪来的?我知道它们来自我的代码中的某个地方,但它们与前面所有的错误形式不同。以前的错误会告诉我的代码中的漏洞在哪里,在哪个文件中,哪一行。但这次没有。如果你知道请告诉我!
我在网上搜索过,似乎是从网上泄露出来的。但我不知道它是什么以及如何使用它。你能帮我弄清楚并解决它吗?
谢谢!
以下是错误:
=================================================================
==6138==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 1683970 byte(s) in 101 object(s) allocated from:
#0 0x7f4e1b674808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
#1 0x7f4e0c7c8e74 (/lib/x86_64-linux-gnu/libnvidia-glcore.so.470.103.01+0xddbe74)
Direct leak of 276667 byte(s) in 62 object(s) allocated from:
#0 0x7f4e1b674a06 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:153
#1 0x7f4e0c7c92db (/lib/x86_64-linux-gnu/libnvidia-glcore.so.470.103.01+0xddc2db)
Direct leak of 896 byte(s) in 1 object(s) allocated from:
#0 0x7f4e1b674c3e in __interceptor_realloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:163
#1 0x7f4e0c7c8582 (/lib/x86_64-linux-gnu/libnvidia-glcore.so.470.103.01+0xddb582)
Indirect leak of 590161 byte(s) in 1281 object(s) allocated from:
#0 0x7f4e1b674808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
#1 0x7f4e0c7c8e74 (/lib/x86_64-linux-gnu/libnvidia-glcore.so.470.103.01+0xddbe74)
Indirect leak of 436144 byte(s) in 647 object(s) allocated from:
#0 0x7f4e1b674a06 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:153
#1 0x7f4e0c7c92db (/lib/x86_64-linux-gnu/libnvidia-glcore.so.470.103.01+0xddc2db)
Indirect leak of 1040 byte(s) in 7 object(s) allocated from:
#0 0x7f4e1b674c3e in __interceptor_realloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:163
#1 0x7f4e0c7c8582 (/lib/x86_64-linux-gnu/libnvidia-glcore.so.470.103.01+0xddb582)
SUMMARY: AddressSanitizer: 2988878 byte(s) leaked in 2099 allocation(s).
make: *** [/home/***/ics2021/nemu/scripts/native.mk:29: run] Error 1我的源代码如下:
#include <common.h>
#include <device/map.h>
#define SCREEN_W (MUXDEF(CONFIG_VGA_SIZE_800x600, 800, 400))
#define SCREEN_H (MUXDEF(CONFIG_VGA_SIZE_800x600, 600, 300))
uint8_t* new_space(int size) {
uint8_t *p = p_space;
// page aligned;
size = (size + (PAGE_SIZE - 1)) & ~PAGE_MASK;
p_space += size;
assert(p_space - io_space < IO_SPACE_MAX);
return p;
}
static uint32_t screen_width() {
return MUXDEF(CONFIG_TARGET_AM, io_read(AM_GPU_CONFIG).width, SCREEN_W);
}
static uint32_t screen_height() {
return MUXDEF(CONFIG_TARGET_AM, io_read(AM_GPU_CONFIG).height, SCREEN_H);
}
static uint32_t screen_size() {
return screen_width() * screen_height() * sizeof(uint32_t);
}
static void *vmem = NULL;
static uint32_t *vgactl_port_base = NULL;
#ifdef CONFIG_VGA_SHOW_SCREEN
#ifndef CONFIG_TARGET_AM
#include <SDL2/SDL.h>
static SDL_Renderer *renderer = NULL;
static SDL_Texture *texture = NULL;
static void init_screen() {
SDL_Window *window = NULL;
char title[128];
sprintf(title, "%s-NEMU", str(__GUEST_ISA__));
SDL_Init(SDL_INIT_VIDEO);
SDL_CreateWindowAndRenderer(
SCREEN_W * (MUXDEF(CONFIG_VGA_SIZE_400x300, 2, 1)),
SCREEN_H * (MUXDEF(CONFIG_VGA_SIZE_400x300, 2, 1)),
0, &window, &renderer);
SDL_SetWindowTitle(window, title);
texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_STATIC, SCREEN_W, SCREEN_H);
}
static inline void update_screen() {
SDL_UpdateTexture(texture, NULL, vmem, SCREEN_W * sizeof(uint32_t));
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, texture, NULL, NULL);
SDL_RenderPresent(renderer);
}
#else
static void init_screen() {}
static inline void update_screen() {
io_write(AM_GPU_FBDRAW, 0, 0, vmem, screen_width(), screen_height(), true);
}
#endif
#endif
void vga_update_screen() {
// TODO: call `update_screen()` when the sync register is non-zero,
// then zero out the sync register
}
void init_vga() {
vgactl_port_base = (uint32_t *)new_space(8);
vgactl_port_base[0] = (screen_width() << 16) | screen_height();
#ifdef CONFIG_HAS_PORT_IO
add_pio_map ("vgactl", CONFIG_VGA_CTL_PORT, vgactl_port_base, 8, NULL);
#else
add_mmio_map("vgactl", CONFIG_VGA_CTL_MMIO, vgactl_port_base, 8, NULL);
#endif
vmem = new_space(screen_size());
add_mmio_map("vmem", CONFIG_FB_ADDR, vmem, screen_size(), NULL);
IFDEF(CONFIG_VGA_SHOW_SCREEN, init_screen());
IFDEF(CONFIG_VGA_SHOW_SCREEN, memset(vmem, 0, screen_size()));
} https://stackoverflow.com/questions/71912839
复制相似问题