Mail Archives: djgpp-workers/2001/08/17/08:58:17
--Message-Boundary-24862
Content-type: text/plain; charset=US-ASCII
Content-transfer-encoding: 7BIT
Content-description: Mail message body
On 17 Aug 2001, at 11:56, Eli Zaretskii wrote:
> > From: sandmann AT clio DOT rice DOT edu (Charles Sandmann)
> > Date: Thu, 16 Aug 2001 17:09:40 -0500 (CDT)
> >
> > Should we sit on the current selector cleanup patch or commit it also?
>
> I think it should be committed and we should ask people to build
> applications (such as Make, RHIDE, and Bash) with it and test it in a
> variety of environments.
>
> However, I'd like to see that patch changed so that plain DOS systems
> aren't affected at all. Why slow down systems which don't need that?
> We already have the _windows_major variable that can be used to easily
> test for whether we are on Windows, and _get_dos_version(1) can be
> used for NT/W2K/XP.
What about this? I added test for CWSDPMI v5 (corresponding DPMI
call doesn't work with earlier versions). Also added possibility to
enable or disable workaround from environment:
SET WORKAROUND_LDT_DESCRIPTORS_LEAK={y|n}
y is default for all cases except when CWSDPMI is begin used.
Perhaps we should think also about using some bit in
_crt0_startup_flags
Andris
--Message-Boundary-24862
Content-type: text/plain; charset=US-ASCII
Content-disposition: inline
Content-description: Attachment information.
The following section of this message contains a file attachment
prepared for transmission using the Internet MIME message format.
If you are using Pegasus Mail, or any another MIME-compliant system,
you should be able to save it or view it from within your mailer.
If you cannot, please ask your system administrator for assistance.
---- File information -----------
File: dosexec.c.diff4
Date: 17 Aug 2001, 15:57
Size: 3566 bytes.
Type: Text
--Message-Boundary-24862
Content-type: Application/Octet-stream; name="dosexec.c.diff4"; type=Text
Content-disposition: attachment; filename="dosexec.c.diff4"
*** djgpp/src/libc/dos/process/dosexec.c~1 Mon Jul 30 14:35:52 2001
--- djgpp/src/libc/dos/process/dosexec.c Fri Aug 17 15:57:00 2001
*************** size_t __cmdline_str_len = sizeof(__cmdl
*** 157,163 ****
if LFN is 2, there is a possiblity that the contents of the
transfer buffer will be overrun! */
static int
! direct_exec_tail(const char *program, const char *args,
char * const envp[], const char *proxy, int lfn,
const char *cmdline_var)
{
--- 157,163 ----
if LFN is 2, there is a possiblity that the contents of the
transfer buffer will be overrun! */
static int
! direct_exec_tail_1 (const char *program, const char *args,
char * const envp[], const char *proxy, int lfn,
const char *cmdline_var)
{
*************** direct_exec_tail(const char *program, co
*** 413,418 ****
--- 413,505 ----
return r.h.al; /* AL holds the child exit code */
}
+
+
+ static int direct_exec_tail (const char *program, const char *args,
+ char * const envp[], const char *proxy, int lfn,
+ const char *cmdline_var)
+ {
+ int i, ret;
+ int sel1=0, sel2=0;
+ char desc_map[8192];
+ static int workaround_descriptor_leaks = 1;
+ static int first_call = 1;
+ static int is_nt = 0;
+
+ if (first_call)
+ {
+ int flags;
+ char dpmi_vendor[128], *W;
+ is_nt = (_osmajor==5 && _osminor==0 && _get_dos_version(1)==0x0532) ? 1 : 0;
+
+ /* Disable descriptors leak workaround whenCWSDPMI v5 is begin */
+ /* used (don't work with earlier versions as corresponding DPMI */
+ /* call is supported beginning from v5) */
+
+ ret = __dpmi_get_capabilities (&flags,dpmi_vendor);
+ if (ret==0 && strcmp(dpmi_vendor+2,"CWSDPMI")==0)
+ workaround_descriptor_leaks = 0;
+
+ /* Added possibility to enable/disable LDT descriptors leak */
+ /* workaround from environment (I think nice for testing or when */
+ /* one have trouble) */
+
+ W = getenv("WORKAROUND_LDT_DESCRIPTORS_LEAK");
+ if (W)
+ {
+ if (*W=='y' || *W=='Y') workaround_descriptor_leaks = 1;
+ if (*W=='n' || *W=='N') workaround_descriptor_leaks = 0;
+ }
+
+ first_call = 0;
+ }
+
+ if (workaround_descriptor_leaks)
+ {
+ if (is_nt)
+ {
+ sel1 = __dpmi_allocate_ldt_descriptors (1);
+ }
+ else
+ {
+ char * map = desc_map;
+ for (i=_my_ds() % 7; i<0x00010000; i+=8)
+ { /* FIXME: Use __dpmi_get_selector_increment_value() instead of 8 ? */
+ *map++ = (__dpmi_get_descriptor_access_rights(i) & 0x80) ? 0 : 1;
+ }
+ }
+ }
+
+ ret = direct_exec_tail_1 ( program, args, envp, proxy, lfn, cmdline_var );
+
+ if (workaround_descriptor_leaks)
+ {
+ if (is_nt)
+ {
+ sel2 = __dpmi_allocate_ldt_descriptors (1);
+ if (sel1>_dos_ds && sel2>_dos_ds)
+ {
+ for (i=sel2; i>=sel1; i-=8)
+ __dpmi_free_ldt_descriptor (i);
+ }
+ }
+ else
+ {
+ char * map = desc_map;
+ for (i=_my_ds() % 7; i<0x00010000; i+=8)
+ {
+ if (*map++)
+ {
+ if (__dpmi_get_descriptor_access_rights(i) & 0x80)
+ __dpmi_free_ldt_descriptor (i);
+ }
+ }
+ }
+ }
+ return ret;
+ }
+
+
int
_dos_exec(const char *program, const char *args, char * const envp[],
const char *cmdline_var)
--Message-Boundary-24862--
- Raw text -