Re: dosemu & newer kernels

Henrik Storner (storner@osiris.ping.dk)
Fri, 19 Apr 1996 21:02:44 +0200


In linux.kernel you write:

>As of 1.3.89 (or so) my old, trusty, non-emumodule dosemu-0.60.4 stopped working
>:-(. Strace suggests that this is the culprit:

>-- mmap(0, 1048576, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|0x20,
>4294967295, 0) = 0
>brk(0x813d000) = 0x813d000
>shmget(IPC_PRIVATE, 65520, 0x1ed|0644) = 6
>shmget(IPC_PRIVATE, 65520, 0x1ed|0644) = 7
>shmat(7, 0x1, SHM_REMAP|SHM_RND) = 0
>shmat(7, 0x100000, SHM_REMAP) = 0x100000
>shmat(6, 0x812a228, SHM_REMAP) = -1 EINVAL (Invalid argument)
> ^^^^^^^^^^^^^^^^---- Here be dragons..

No, the problem is in dosemu. This looks just like the problem I found
when upgrading to libc 5.2.something - the one with the new malloc-
implementation. The bug is that dosemu attempts to do a shared memory
mapping on a malloc'ed memory area - it should use valloc instead, since
shared memory must begin on a page boundary.

The following patch fixes it (apply from the dosemu top-level source directory):

--- dosemu/dosio.c.orig Mon Jan 22 08:18:54 1996
+++ dosemu/dosio.c Mon Jan 22 08:19:08 1996
@@ -368,7 +368,7 @@
void HMA_init(void)
{
/* initially, no HMA */
- HMAkeepalive = malloc(HMASIZE); /* This is used only so that shmdt stays going */
+ HMAkeepalive = valloc(HMASIZE); /* This is used only so that shmdt stays going */
sharedmem.hmastate = 0;

if ((shm_hma_id = shmget(IPC_PRIVATE, HMASIZE, 0755)) < 0) {