www.delorie.com/djgpp/bugs/show.cgi   search  
Bug 000286

When Created: 06/07/1999 15:00:04
Against DJGPP version: 2.01
By whom: avillaci@ceibo.fiec.espol.edu.ec
Abstract: Copies from HMA crash with SIGSEGV under EMM386
The function dosmemget() crashes when told to copy data from the HMA into the program address space. Consider the example below:

#include <stdio.h>
#include <stdlib.h>
#include <go32.h>
#include <dpmi.h>

int main(void)
{
     void * buffer;

     buffer = malloc(65520);
     if (buffer != NULL)
     {
          /* I canīt remember the exact order of parameters, but it should copy 65520 bytes from HMA into buffer allocated with malloc */
          dosmemget(0x100000, 65520, buffer); /* please check start address, I am calculating it as I write this */
          puts("Copying was successful!");
          free(buffer);
     }
     else puts("malloc failed.");
     return 0;
}

This short program is supposed to allocate 65520 bytes via malloc and copy the contents of the HMA into it. This program runs successfully under a Windows DOS box, but crashes when run under plain DOS with EMM386 and CWSDPMI. The stack dump points at _dj_movedata as the last function executed, and the DS and ES registers show selectors into the low 1MB area and the program data area.

It seems that this problem is caused by EMM386 not honoring a set selector limit message that is issued by CWSDPMI (probably when building _dos_ds). This problem, however, remains when I disable VCPI services with the NOVCPI parameter. I discovered this as I wrote a program that copied video ROM fonts into my data areas, as part of my graphics library. DISPLAY.SYS seems to locate replacement fonts into the HMA, so the code ends up trying to copy data from the HMA, with the described results. Apart from uninstalling either EMM386.EXE or DISPLAY.SYS, could anybody suggest a workaround to access the HMA? I worked this around by copying the fonts in real mode into a file, but other services may be mapped into the HMA, and DJGPP programs will crash on them.

Note added: 06/13/1999 06:00:35
By whom: eliz@is.elta.co.il
This is a known probles with EMM386, it also raises its ugly head when
_set_screen_lines function is called to set 40-line screen, and DISPLAY.SYS
is installed together with EMM386.  Last time we had this problems, a user
showed that a perfectly valid instruction issued by the library function
caused a GPF in EMM386.

There's nothing we can do about bugs in EMM386; users should complain to
Microsoft, or install substitutes instead of EMM.  So I'm closing this
bug report.

Closed on 06/13/1999 06:00:20: A bug in EMM386, not in DJGPP
By whom: eliz@is.elta.co.il



  webmaster     delorie software   privacy  
  Copyright Đ 2010   by DJ Delorie     Updated Jul 2010