[net.micro.pc] environment problem

jsmith@h-sc4.harvard.edu (joel smith) (08/22/86)

Hi,

	I have a problem and I hope that someone out there
	can help.

	I have a large program.  A very large program.  Its
	total address space is around 1.4 Meg.  Since on a PC
	you only have 640K of memory, I have used plink86 from
	from Phoenix Associates to overlay different code sections
	to reduce the memory requirements to about 450K.

	Here's the problem:  I have a bug.  When passing through
	one section of code, the program doesn't work properly.
	But when a few bytes (from as little as 2 to as many
	as 100; dependant on the configuration of the machine)
	are added to the environment, the code works.

	Note that I am not talking about extending the size of
	the environment, I am talking about adding bytes to the
	current environment (as in using the "set garbage=asdfja;sdf").

	Furthermore, just to see if the bug was related to a specific
	section of code (and thus indicating a real code bug),  I swapped
	two routines in the overlay map.  If the bug was really in the
	code, then it should be associated with one routine. Instead,
	the section of code which previously did not work now works
	fine and the section of code that was moved into its place
	no longer works.

	This indicates to me a write into memory at an absolute
	address.

	A little background into the executable structure of the
	program:

	It is a graphics program.  In order to have full capabilities
	on a variety of monitors, adapters, and printer/plotters,
	I am using the GSSCGI package.  This means that there is
	a driver present in the system for the monitor and another
	one for the GSS package itself (installed in the config.sys
	file).  In addition, there is a quit and remain resident
	program which checks some security parameters to prevent
	unauthorized running of the program.  Then the main program
	is loaded on top of the security program.

	So the structure of the system is:

		screen driver & GSSCGI driver
		security program
		main program

	Note that different monitors and adapters have different
	drivers.  Each has a slightly different size.  And this
	has an effect on the location of the bug.  Meaning on
	different configurations, the bug pops up in different
	places.  But adding to the size of the used environment
	always appears to correct the problem.  Note that on some
	configurations,  having too much used environment seems to
	be the problem.  That is, decreasing the amount of used
	environment corrects the problem on some configurations.

	Note that in all cases,  the amount of used environment
	never comes close to 160 bytes (the default max).

	How does DOS allocate the enviroment?  Why would changing
	the amount of used environment have any effect on programs?

	Thanx in advance for your help.


					Joel Smith
					jsmith@h-sc4.harvard.edu