box86 icon indicating copy to clipboard operation
box86 copied to clipboard

Some problems about system call clone.

Open Mr-HappyLI opened this issue 4 years ago • 5 comments

case 120: // clone { if(!R_ECX) { // allocate a new stack... stack_size = 10241024; //stack_base = malloc(stack_size); // why not 1M... (normal operation do copy on write, simpler to just copy) stack_base = mmap(NULL, stack_size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_GROWSDOWN, -1, 0); // copy value from old stack to new stack int size_to_copy = (uintptr_t)emu->init_stack + emu->size_stack - (R_ESP); memcpy(stack_base-size_to_copy, (void)R_ESP, size_to_copy); }

Hi,ptitSeb A segment error occurred when "memcpy" was run.

Mr-HappyLI avatar Aug 12 '21 08:08 Mr-HappyLI

yeah, the "clone" syscall is barely supported. I need to find a better way to emulate this one.

ptitSeb avatar Aug 12 '21 08:08 ptitSeb

Note that I have seen this syscall used in 2 cases:

  1. When a segfault occured in mono/unity3d and it's used to call "gdb"
  2. On program with a staticaly linked libc / libpthread: this is not supported by box86, except issues (like the clone syscall one, thta is used to create new thread by libpthread).

ptitSeb avatar Aug 12 '21 08:08 ptitSeb

What I don't understand is why data should be copied to memcpy ‘stack_base-size_to_copy’.At the same time, this memory did not find a place to malloc for it. Can you help me solve this doubt?Thanks!

It is probably wrong. I need to redo this part, it's an old one, rarely used...

OK, I know.Thank you!

Mr-HappyLI avatar Aug 12 '21 08:08 Mr-HappyLI

It is probably wrong. I need to redo this part, it's an old one, rarely used...

ptitSeb avatar Aug 12 '21 08:08 ptitSeb

Can this ticket be closed now?

ptitSeb avatar Jul 10 '22 17:07 ptitSeb