Caught by tst-getpid1 test from uClibc's test-suite.

It looks like original implementation was not correct.
The code in question is supposed to recover PID of the new
thread. And by no means that could happen with clone() syscall
while getpid() does exactly this.

Signed-off-by: Alexey Brodkin <[email protected]>
Acked-by: Vineet Gupta <[email protected]>
Reported-by: Eugeniy Paltsev <[email protected]>
---
 libc/sysdeps/linux/arc/clone.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libc/sysdeps/linux/arc/clone.S b/libc/sysdeps/linux/arc/clone.S
index 3c1388e..dbb3fa7 100644
--- a/libc/sysdeps/linux/arc/clone.S
+++ b/libc/sysdeps/linux/arc/clone.S
@@ -72,7 +72,7 @@ ENTRY(clone)
        and_s   r2, r2, r12
        brne    r2, r12, .Lgo_thread
 
-       mov     r8, __NR_clone
+       mov     r8, __NR_getpid
        ARC_TRAP_INSN           ; r0 has PID
        THREAD_SELF r1          ; Get to struct pthread (just before TCB)
        st      r0, [r1, PTHREAD_PID]
-- 
2.7.4

_______________________________________________
devel mailing list
[email protected]
http://mailman.uclibc-ng.org/cgi-bin/mailman/listinfo/devel

Reply via email to