From fnaumann@mail.cs.uni-magdeburg.de Sun Jan 11 08:18:39 2004 Message-ID: <001001c3d812$9508aad0$0b0a63d9@blaszak> Reply-To: "Konrad Kokoszkiewicz" From: "Konrad Kokoszkiewicz" To: Subject: [MiNT] Problem Date: Sun, 11 Jan 2004 08:13:29 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2720.3000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2727.1300 X-Virus-Scanned: by amavisd-new X-MIME-Autoconverted: from 8bit to quoted-printable by antyk.obta.uw.edu.pl id i0B7EJZd084024 Delivered-To: mint@fishpool.com Delivered-To: mint@lists.fishpool.fi X-ecartis-version: Ecartis v1.0.0 Sender: mint-bounce@lists.fishpool.fi Errors-to: mint-bounce@lists.fishpool.fi X-original-sender: draco@obta.uw.edu.pl Precedence: bulk List-help: List-unsubscribe: List-ID: X-List-ID: Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by prinz.cs.uni-magdeburg.de id i0B7Ibn18575 Hi! I am having a problem with a GEM program and the memory protection. Perhaps someone could tell what's wrong. A GEM application starts a "thread" via Pexec(7)/Pexec(104). The child process must be a GEM application too, so I have used one of the latest GEMLib versions (with "MT support"). The function that starts the thread looks as follows (it's a variation of mintlib's tfork()): static long tfork(void *startup, char *proctitle) { BASEPAGE *new; long flags, pid; flags = (F_FASTLOAD | F_ALTLOAD | F_ALTALLOC); new = (BASEPAGE *)Pexec(7L, (void *)flags, "", 0L); if ((long)new < 0) new = (BASEPAGE *)Pexec(5L, 0L, "", 0L); if ((long)new <= 0) { if (!(long)new) return -ENOMEM; return (long)new; } Mshrink(new, 8192L); new->p_hitpa = (char *)((long)new + 8192L); new->p_tbase = startup; pid = Pexec(104, proctitle, (char *)new, 0L); Mfree((long)new->p_env); Mfree((long)new); return pid; } The actual child process code goes as follows: static short child_global[16]; static void child_proc(BASEPAGE *bp) { short apid; apid = mt_appl_init(child_global); if (apid >= 0) { if (setjmp(jbuf) == 0) { Psignal(SIGTERM, sterm); if (apid >= 0) { mt_menu_register(apid, " Child proc", child_global); /* ... * Here comes some GEM stuff the program has to do * ... */ } } mt_appl_exit(child_global); } Pterm(0); } The child_proc() starts normally, calls the mt_appl_init(), but never returns from there, because a bus error occurs then. The parent process uses the same code at the begin of the main() function, except that different array is used for global array, and it works. It may be that I am doing something wrong here, because I am not very familiar with GEMLib. However, some time ago I wrote the same program in assembler (I am now trying to recode it in C, that is) using my own, statically linked assembler library functionally similar to the GEMLib, and also with MT support. The program worked, but since a version of MiNT it stopped working with memory protection. The symptom is the same: bus error short after starting the child code. So it may be even a problem with the kernel, I don't know. Anyone? -- CVV Konrad M.Kokoszkiewicz, http://draco.atari.org ** Ea natura multitudinis est, aut seruit humiliter, aut superbe dominatur. ** Taka to już natura pospólstwa, albo służalczo się płaszczy, ** albo bezczelnie się panoszy. (T. Liuius XXIV, 25).