delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/02/17/12:42:47

Message-Id: <200002171707.SAA16280@cerbere.u-strasbg.fr>
X-Sender: muller AT ics DOT u-strasbg DOT fr
X-Mailer: QUALCOMM Windows Eudora Pro Version 4.0.2
Date: Thu, 17 Feb 2000 17:53:09 +0100
To: djgpp-workers AT delorie DOT com
From: Pierre Muller <muller AT cerbere DOT u-strasbg DOT fr>
Subject: Bug in crt0.S
Mime-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com

--=====================_11884876==_
Content-Type: text/plain; charset="us-ascii"


   Hello,

  I  wrote the Run Time Library of the Free Pascal port  to DJGPP  system.
As such, I changed crt0.S to allow starting a program without any use of the
C library.

   Due to internal problems, I disabled the multiblock feature in the
startup code.
Thus our RTL uses Unixy sbrk with selector base changes.

   Recently, we got more and more problems with our IDE
(a freeware equivalent of the Borland editor BP) under Windows.
These crashes allways appeared in the VMOUSE VXD and completely crashed the
computer!

  These errors were even more frequent on Win98 and Win 2000 !!
After quite long and hard debugging, I finally realized that
there is a major bug in the startup code:
  
   when the function 0x503 of DPMI is called,
only the cs and ds selector are updated in the 16 byte sbrk16.asm code.
The djgpp_ds_alias selector (that is used for the RMCB
to avoid problems with fake exceptions like Crtl-C) is updated 
later in the 32 bit code... but its updated after the
interrupts are reenabled !!!
  If the mouse callback is called in the interval between the 0x503
function call and the update
of the alias selector base address => you get the crash!!

  I include here a diff to version 2.03 of crt0.S file that also fixes the
problem for the C library!
Could someone please test this with RHIDE
because the recent problem about linking could be due to that fact
if (and I don't know if this is true) the linker is called internally !


PS: I first sent this mail by error  to the wrong djgpp-announce mailing list
but apparently it was rejected anyhow !




  
--=====================_11884876==_
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: attachment; filename="crt0.dif"

*** crt0ori.S	Wed Aug 11 02:24:38 1999
--- crt0.S	Thu Feb 17 10:05:44 2000
***************
*** 2,7 ****
--- 2,9 ----
  /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
  /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
  /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
+ /* Modified to fix the problem of sbrk16 if a RMCB is active
+    like a mouse callback by Pierre Muller */
  /*****************************************************************************\
   * Interface to 32-bit executable (from stub.asm)
   *
***************
*** 38,43 ****
--- 40,53 ----
  #include "sbrk16.ah"
  sbrk16_last_byte:
  
+ /* new data used to store the interrupt state before calling
+    sbrk16 code
+    This is necessary because the interrupt must stay
+    disabled until ___djgpp_ds_alias base address
+    is changed PM */
+ sbrk16_interrupt_state:
+    .long 0x902
+    
  sbrk16_api_ofs:
  	.long	0
  sbrk16_api_seg:
***************
*** 453,465 ****
  
  	movw	$0x0900, %ax					/* disable interrupts */
  	int	$0x31
! 	pushl	%eax
  
  	lcall	sbrk16_api_ofs
  	setc	%dl						/* Save carry */
  
! 	popl	%eax					/* restore interrupts */
! 	int	$0x31
  
  	test	%dl,%dl
  	popl	%edx
--- 463,480 ----
  
  	movw	$0x0900, %ax					/* disable interrupts */
  	int	$0x31
! 	/* pushl	%eax restoring is postponed
!       we need to store the result into data PM */
!    movl  %eax,sbrk16_interrupt_state
  
  	lcall	sbrk16_api_ofs
  	setc	%dl						/* Save carry */
  
!    /* This must be postponed to
!       after ___djgpp_ds_alias base is changed also
!       otherwise you get crashs in RMCB PM */
! 	/* popl	%eax					 restore interrupts
! 	int	$0x31                */
  
  	test	%dl,%dl
  	popl	%edx
***************
*** 552,557 ****
--- 567,576 ----
  	movw	___djgpp_base_address+2, %cx
  	int	$0x31
  
+    /* Now we can reenable interrupts  PM */
+    movl  %eax,sbrk16_interrupt_state
+    int   $0x31
+    
  	movl	___djgpp_selector_limit, %edx
  12:	incl	%edx						/* Size not limit */
  	testb	$0x60, __crt0_startup_flags	/* include/crt0.h */

--=====================_11884876==_
Content-Type: text/plain; charset="us-ascii"



Pierre Muller
Institut Charles Sadron
6,rue Boussingault
F 67083 STRASBOURG CEDEX (France)
mailto:muller AT ics DOT u-strasbg DOT fr
Phone : (33)-3-88-41-40-07  Fax : (33)-3-88-41-40-99
--=====================_11884876==_--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019