[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Sticky Text Patches



Michael Hohmuth writes:

> itschere@techfak.uni-bielefeld.de writes:
>
> > > I've put up a fourth re-sync patch...
> > 
> >  Fine... Only a pity that it gives me nothing but memory violations... :-(
>
> I've successfully been using this version for a few days on a Mega
> ST..  Perhaps this is something 030 specific?
				  ^^^
				 
It is!  I had memory violations on my falcon, too. The problem is
that when do_vfork tries to restore the parent's memory it does
not have access to it anymore.

So I added some prot_temp()-calls in fork_restore(), and now it 
works fine. I've marked the lines below (Sorry, no diff, because I
don't know (yet) how to use it).

It is a working solution - but I don't know whether it's the best.


/*
 * fork_restore(p): restore process memory after a blocking fork
 */

void fork_restore(p, savemem)
PROC *p;
MEMREGION *savemem;
{
	MEMREGION *m;
	long txtsize = p->txtsize;
	char *saveplace;
	int i;
>>>	int cookie, cookie2; /* SH */

	if (!savemem) {
		for (i = 0; i < p->num_reg; i++) {
			m = p->mem[i];
			if (m && (m->mflags & M_FSAVED)) {
				savemem = m;
				break;
			}
		}
		if (!savemem)
			return;
	}
	saveplace = (char *)savemem->loc;

>>>	/* SH: need to have global access to restore parent's memory */
>>>	cookie = prot_temp(savemem->loc, savemem->len, -1);

	TRACE(("do_vfork: parent restoring memory"));
	for (i = 0; i < p->num_reg; i++) {
		m = p->mem[i];
		if (m && !(m->mflags & (M_FSAVED|M_SHTEXT))) {
			if (i != 1 || txtsize == 0) {
>>>			    cookie2 = prot_temp(m->loc, m->len, -1); /* SH */
			    quickmove((char *)m->loc, saveplace, m->len);
			    saveplace += m->len;
>>>			    (void) prot_temp(m->loc, m->len, cookie2); /* SH */
			}
			else {
>>>			    cookie2 = prot_temp(m->loc + txtsize, 
						m->len - txtsize, -1); /* SH */
			    quickmove((char *)m->loc+txtsize, saveplace,
				m->len - txtsize);
			    saveplace += m->len - txtsize;
>>>			    (void) prot_temp(m->loc + txtsize,
					     m->len - txtsize, cookie2); /* SH */
			}
		}
	}
>>>	/* SH: do we have to restore access rights? */
>>>	(void) prot_temp(savemem->loc, savemem->len, cookie);

	detach_region(p, savemem);
}


Ciao,
Stephan


P.S. This is the first time I mail to this list, so tell me if I did
     something wrong.


-- 
+------------------------------+-----------------------------+
|      Stephan Haslbeck	       |    Fachbereich Informatik   |
|       Agricolastr. 61	       |   Technische Universitaet   |
|      D-80686 Muenchen	       |      Muenchen, Bayern	     |
+------------------------------+-----------------------------+
|Motto: Es gibt keine Probleme,|
|        nur Loesungen.	       |
+------------------------------+