bigexec 10. Execing with 3850 8-letter words.


(Abdullah Emad) #1

When running bigexec test, all the 9 tests passes except for test 10 which hangs the kernel with the following assertion :

Assertion failed: (vaddr_t)tf > (vaddr_t)curthread->t_stack, at …/…/arch/mips/locore/trap.c:149

After debugging my sys_execv implementation I found out that copying in the argv from the userspace to the kernel space succeeds with no problem and the exception occurs when trying to copy the argv back to the new user address space. Moreover, I looked at the stack pointer and it has a value of 0x800000 which seems like a invalid pointer.

My approach is to copy all the argv into one big string created wth malloc with a size of ARG_MAX and each two arguments are separated by a null terminator. Then copy this whole string to the new stack pointer and then copy their addresses to the stack pointer.

Can you please give some hints on what might be going wrong here


(Haneesh Reddy Poddutoori) #2

At what point are you allocating memory to the buffer array, which is of size ARG_MAX. Are you doing that for each exec call? If so make sure to free that memory. I would rather have a global array initialized with that size and not malloc it, so that I can have fixed memory at execution time. Also, are you using the copy in and out utilites in copyinout.h, they do some validations when copying from and copying to userspace.


(Abdullah Emad) #3

The first thing I do some validations and sanity checks than I allocate the memory for the buffer array before creating the address space or loading the elf. I then copy argv to the allocated memory using copyin. Afterwards, I create the address space, load elf, define the stack etc… and then, using copyout, I copy the arguments from the allocated memory to the stack… here is where the assertion hangs the kernel and it only happens with test 10. It works just fine with all the other tests


(Haneesh Reddy Poddutoori) #4

I am guessing that you are running out of memory(NOT 100% SURE). As I already commented, try not to allocate memory for buffer on every exec call. Either do it once or I recommend have an array initialized with size ARG_MAX.


(Abdullah Emad) #5

I am sure I free the allocated memory once I copy it out but I will try initializing a global array. Thanks for your reply :slight_smile: