Strange error while running riscv spike pk

Hi,

I have build spike simulator along with pk. Sometimes when i run a program compiled with riscv32-unknown-elf i get this error

spike: …/fesvr/elfloader.cc:28: std::map<std::__cxx11::basic_string, long unsigned int> load_elf(const char*, memif_t*, reg_t*): Assertion `buf != MAP_FAILED’ failed.

What is this error pointing out ? my object file generated from riscv-unknown-elf-gcc is correct which shows

test_program.o: ELF 32-bit LSB executable, UCB RISC-V, version 1 (SYSV), statically linked, with debug_info, not stripped

What can be the problem here ?

This means an mmap system call failed. Though unfortunately the simulator tells you the syscall failed but doesn’t give you errno, so you can’t tell why it failed. I’d suspect an out-of-memory error as the first choice, maybe you need more simulated memory if you are trying to mmap something large. You might want to modify the simulator to print errno, or run it under the debugger so you can view errno when the syscall fails to get a better idea of what is going wrong.