PERFORCE change 102710 for review
Roman Divacky
rdivacky at FreeBSD.org
Sat Jul 29 09:33:42 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=102710
Change 102710 by rdivacky at rdivacky_witten on 2006/07/29 09:32:54
Fix the handling of td in linux_proc_init(). td points to parent proc/thread.
This fixes panic with realplay.
Also, dont leak emul_shared in a case of linux -> fbsd exec.
Affected files ...
.. //depot/projects/soc2006/rdivacky_linuxolator/compat/linux/linux_misc.c#6 edit
.. //depot/projects/soc2006/rdivacky_linuxolator/i386/linux/linux_machdep.c#26 edit
Differences ...
==== //depot/projects/soc2006/rdivacky_linuxolator/compat/linux/linux_misc.c#6 (text+ko) ====
@@ -1384,7 +1384,6 @@
if (pp->p_sysent == &elf_linux_sysvec) {
em = em_find(pp->p_pid, EMUL_LOCKED);
if (em == NULL) {
- printf("this happens!\n");
#ifdef DEBUG
printf(LMSG("emuldata not found.\n"));
#endif
==== //depot/projects/soc2006/rdivacky_linuxolator/i386/linux/linux_machdep.c#26 (text+ko) ====
@@ -74,6 +74,8 @@
void linux_proc_exec(void *, struct proc *, struct image_params *);
struct linux_emuldata *em_find(pid_t pid, int locked);
+extern struct sysentvec elf32_freebsd_sysvec; /* defined in i386/i386/elf_machdep.c */
+
struct l_descriptor {
l_uint entry_number;
l_ulong base_addr;
@@ -1157,21 +1159,23 @@
em->child_clear_tid = NULL;
em->child_set_tid = NULL;
- /* allocate the shared struct only in non-exec cases */
+ /* allocate the shared struct only in clone()/fork cases
+ * in the case of clone() td = calling proc and child = pid of
+ * the newly created proc
+ */
if (child != 0) {
em->shared = NULL;
if (flags & CLONE_VM) {
/* lookup the parent */
- p_em = em_find(td->td_proc->p_pptr->p_pid, EMUL_LOCKED);
+ p_em = em_find(td->td_proc->p_pid, EMUL_LOCKED);
if (p_em == NULL) {
#ifdef DEBUG
- printf(LMSG("parent emuldata not found for CLONE_VM.\n"));
#endif
+ printf(LMSG("parent emuldata not found for CLONE_VM.\n"));
+ panic("impossible to continue\n");
} else {
- em->shared = p_em->shared;
+ em->shared = p_em->shared;
em->shared->refs++;
-#ifdef DEBUG
-#endif
}
} else {
struct linux_emuldata_shared *s;
@@ -1179,7 +1183,7 @@
MALLOC(s, struct linux_emuldata_shared *, sizeof *s, M_LINUX, M_WAITOK | M_ZERO);
em->shared = s;
s->refs = 1;
- s->group_pid = td->td_proc->p_pid;
+ s->group_pid = child;
}
}
@@ -1252,7 +1256,6 @@
FREE(em, M_LINUX);
}
-extern struct sysentvec elf32_freebsd_sysvec; /* defined in i386/i386/elf_machdep.c */
/* This is used in a case of transition from FreeBSD binary execing to linux binary
* in this case we create linux emuldata proc entry with the pid of the currently running
* process.
@@ -1275,6 +1278,10 @@
#endif
return;
}
+
+ em->shared->refs--;
+ if (em->shared->refs == 0)
+ FREE(em->shared, M_LINUX);
EMUL_RUNLOCK(&emul_lock);
/* XXX: there is a race but I think we can ommit that
More information about the p4-projects
mailing list