Re: dosemu & newer kernels

Steven N. Hirsch (hirsch@uvm-gen.emba.uvm.edu)
Fri, 19 Apr 1996 18:49:42 -0400


Henrik Storner wrote:
>
> 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) {

Henrik,

Many thanks sir! This took care of the problem; dosemu-0.60.4 is working again. I wish
the video handling on newer dosemu versions was fixed, but at least I can use Generic
CADD again :-). Much appreciated.

Any chance that the mmap changes in the kernel will get documented?

- Steve

-- 
___________________________________________________________
|Steven N. Hirsch	"Anything worth doing is worth     |
|University of Vermont	 overdoing.." - Hunter S. Thompson |
|Computer Science / EE                                     |
------------------------------------------------------------