From: Erik de Castro Lopo <nospam@mega-nerd.com>
To: ultralinux@vger.kernel.org
Subject: SMP Sparc64 : bug in clone?
Date: Mon, 29 Apr 2002 20:17:24 +0000 [thread overview]
Message-ID: <marc-linux-ultrasparc-102011145323055@msgid-missing> (raw)
In-Reply-To: <marc-linux-ultrasparc-101684978515837@msgid-missing>
Hi all,
I now have a piece of code (at the end of this email) which uses clone()
and seems to work. However, the behaviour between Sparc64 and x86 Linux
is different.
On x86 both :
pid = clone (child, stack, SIGCHLD, NULL);
and
pid = clone (child, stack, CLONE_VM | SIGCHLD, NULL);
work while on Sparc64, the former results in a stillborn child process.
Using strace I have found that the stillborn child received SIGSEGV as
soon as it was spawned.
My suspicion is that in the case where CLONE_VM is not part of the flags,
the child process is not granted r/w access to the stack supplied to it
and hence segfaults as soon as it tries to access the stack.
I've had a look at the glibc sources (where clone is implemented in
sysdeps/unix/sysv/linux/sparc/sparc64/clone.S) but being somewhat unfamiliar
with Sparc assembler I can't really figure out if it is right or wrong.
Anybody have any insight?
Cheers,
Erik
--
+-----------------------------------------------------------+
Erik de Castro Lopo nospam@mega-nerd.com (Yes it's valid)
+-----------------------------------------------------------+
The word "Windows" is a word out of an old dialect of the
Apaches. It means: "White man staring through glass-screen
onto an hourglass..."
------------------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sched.h>
#include <signal.h>
#include <sys/wait.h>
#define STACK_SIZE (1<<10)
/* On sparc64, stack needs to be 8 byte aligned. */
static double stack_bytes [STACK_SIZE+1];
int
child(void *arg)
{ printf ("child running\n") ;
sleep(2);
printf ("child about to exit\n") ;
exit (0);
} /* child */
int
main(int argc, char **argv)
{ int pid, status ;
void *stack ;
stack = &stack_bytes[STACK_SIZE];
printf ("stack = %p\n", stack);
printf("parent running\n");
/* On x86, CLONE_VM flag is not required. Why?? */
if((pid = clone (child, stack, CLONE_VM | SIGCHLD, NULL)) < 0)
{ perror("clone");
exit(1);
}
printf ("pid : %d\n", pid);
if((pid = waitpid(pid, &status, WUNTRACED)) < 0)
{ perror("Waiting for stop");
exit(1);
}
printf ("parent about to exit\n") ;
return 0 ;
} /* main */
------------------------------------------------------------------------------
next prev parent reply other threads:[~2002-04-29 20:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-03-23 2:15 SMP Sparc64 : bug in clone? Erik de Castro Lopo
2002-03-23 3:33 ` Erik de Castro Lopo
2002-03-25 7:53 ` Erik de Castro Lopo
2002-03-25 8:12 ` David S. Miller
2002-03-25 8:35 ` Erik de Castro Lopo
2002-03-25 8:36 ` David S. Miller
2002-04-29 20:14 ` David S. Miller
2002-04-29 20:17 ` Erik de Castro Lopo [this message]
2002-05-04 23:08 ` Erik de Castro Lopo
2002-05-06 14:25 ` Noah Beck
2002-05-06 21:36 ` Erik de Castro Lopo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=marc-linux-ultrasparc-102011145323055@msgid-missing \
--to=nospam@mega-nerd.com \
--cc=ultralinux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox