Solved

Very old program: Runtime Error R6009

Posted on 1997-09-04
20
1,904 Views
Last Modified: 2011-09-20
I am using a very old C Program - it might be written with Microsoft C 5.0 or 6.0. (I have no Source code) On one PC I get the Error: Runtime Error R6009 - Not enough space in environment
It is NOT the conventional DOS Memory that is too small
What does that Error mean?
PLEASE DO NOT ANSWER THIS QUESTION, IF YOU DON'T KNOW WHAT IT IS. I HAD A LOT OF HINTS WHAT IT COULD BE, THAT DOES NOT HELP ME. You'll get the 400 Points only, if you really can solve the problem.
0
Comment
Question by:Ulrich060397
  • 9
  • 3
  • 2
  • +5
20 Comments
 

Author Comment

by:Ulrich060397
ID: 1254039
Edited text of question
0
 

Author Comment

by:Ulrich060397
ID: 1254040
Adjusted points to 400
0
 
LVL 4

Expert Comment

by:AVaulin
ID: 1254041
It's to complex to say anything without more details knowledge. For example is this problem appears only on one PC? Can you send this program in purpose to experiment with it?
0
 
LVL 3

Expert Comment

by:msmits
ID: 1254042
This is a guess, so I am not putting it in as an answer.

Environment space is allocated from the system memory by the command shell you are using to start the program from. By default you get 256 bytes to put your environment variables in.
To make this space larger you must supply the /E:nnnn option on the SHELL= line in your config.sys file for command.com. You can define upto 32k for the environment. See th help for 'command' for a full explanation of this option and some examples.

0
 
LVL 4

Expert Comment

by:emmons
ID: 1254043
You don't say what the OS is that you are using. You also say that this happens on one PC. Is that the only machine that you have tried?
If you are running on a DOS machine, command.com can be modified in the config.sys file as follows...

COMMAND [[drive:]path] [device] [/E:nnnnn] [/P] [/C string] [/MSG]


My dos machine contains the line...
SHELL=C:\COMMAND.COM C:\ /E:2000 /P

  [drive:]path    Specifies the directory containing COMMAND.COM file.
  device          Specifies the device to use for command input and output.
  /E:nnnnn        Sets the initial environment size to nnnnn bytes.
  /P              Makes the new command interpreter permanent (can't exit).
  /C string       Carries out the command specified by string, and then stops.
  /MSG            Specifies that all error messages be stored in memory. You
                  need to specify /P with this switch.
0
 
LVL 3

Expert Comment

by:msmits
ID: 1254044
emmons: thank you for using my comment as your answer :-(

0
 
LVL 4

Expert Comment

by:emmons
ID: 1254045
msmits: I apologize if my answer looks like theft. The response was not as a result of your comment, since your comment did not appear to me until after I submitted the answer. I suspect that there is a caching issue here somewhere, and I shall try to be more careful in my responses.
0
 

Expert Comment

by:jag
ID: 1254046
Hmmmm.... strange how the wording of emmons' 'answer' is identical to msmits' comment.
0
 

Author Comment

by:Ulrich060397
ID: 1254047
No need to discuss about the points at the moment!
The comment of msmits and the proposed answer of emmons sounds good but it still doesn't work.
The problem I have is only on one computer, on two others where it works is no "shell=" line in config.sys at all
But on the PC with the problem I had before
shell=c:\windows\command.com c:\windows /p
I tried
shell=c:\windows\command.com c:\windows /E:32768 /p
and I tried without this line - still the same problem!
All other lines in config.sys are identical

Some more information: The PC is running under Win95, the problem occurs in a Dos task as well, as when the computer is put to Dos mode from Win95.

I typed mem /D with the second (/E:32768) try, and got

...
                        512    (1K)               BUFFERS=30
   005D5                 80    (0K)  MSDOS        Systemprogramm
   005DA                 32    (0K)  WIN          Daten
   005DC                336    (0K)  WIN          Umgebung
   005F1              3'488    (3K)  WIN          Programm
   006CB                 48    (0K)  vmm32        Daten
   006CE                800    (1K)  vmm32        Programm
   00700                352    (0K)  COMMAND      Daten
   00716              5'728    (6K)  COMMAND      Programm
   0087C             33'824   (33K)  COMMAND      Umgebung
   010BE                368    (0K)  MEM          Umgebung
   010D5             90'400   (88K)  MEM          Programm
   026E7            496'000  (484K)  MSDOS        -- Frei --
...

Small German Lesson:
Umgebung ... Environmet
Frei     ... Free

So here I am - any other suggestions?

Thank's for your help so far!
0
 
LVL 10

Expert Comment

by:rbr
ID: 1254048
I`m not quite firm with the Runtime errors if MSC but as I see you tried to change the amount of enviroment space. Maybe this isn't the right way and the problem isn't the the low enviroment space. As I see from your mem /D command you have only 30 buffers for file handles. Have you tried to increase this number?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:Ulrich060397
ID: 1254049
Dear rbr!
Sorry, that one didn't help
I increased the Buffers to 100 and have still the same problem!
So the complete config.sys is now:
device=c:\windows\himem.sys
device=c:\windows\emm386.exe noems
FILES=129
BUFFERS=100
DOS=UMB
DOS=HIGH
device=c:\windows\COMMAND\display.sys con=(ega,,1)
Country=041,437,c:\windows\COMMAND\country.sys
0
 
LVL 5

Expert Comment

by:y96andha
ID: 1254050
What about your autoexec.bat? Try remarking out all SET statements that are not absolutely necessary and see if it helps. The /E:xxxx parameter only affects the primary command processor, so the environment size can still be the error.
0
 

Author Comment

by:Ulrich060397
ID: 1254051
Bingo!
I remarked out all SET statements and now it works!

THANKS A LOT TO y96andha

Please check in anything as your answer, and I would be happy to quote you!

Ulrich
0
 
LVL 5

Accepted Solution

by:
y96andha earned 200 total points
ID: 1254052
The environment is full with SET variables. Remove some of them and it will work.
0
 

Author Comment

by:Ulrich060397
ID: 1254053
Thank's a lot, once again!
0
 

Expert Comment

by:cdms
ID: 1254054
The real problem is that when an application is spawned, the env. is shrunk to the size of the current contents rounded to 16 bytes.  In removing some of the variables, what you have done os change the free space in the process copy of the env because it no longer uses as near to the next 16 byte boundary as it did previously.

You could have achieved the same result by ADDING small env viriables, like SET A=B until you get enough space (try B, BB, BBB, etc).

The best solution, however, is to specifically reserve space for the variable that your program is going to use.  It, for example, it sets the env. variable FOO, than put SET FOO=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
In the autoexec,bat.  This is then overwritten by your program, and you are _guaranteed_ to have enough space (assuming you left enough X's).

This is the only solution guaranteed to work in all situations.

Regards

Dave
0
 

Author Comment

by:Ulrich060397
ID: 1254055
The problem is, that I don't know, which variable is going to be used by the program, because I don't have the source code. I have no idea how I could find it out then.

Thank you anyway!

Ulrich
0
 
LVL 5

Expert Comment

by:y96andha
ID: 1254056
cdms: I'm not sure what you say is right. I always believed that the default size was something like 256 bytes, and whenever a new command processor is started, the largest of the default size and the current size of all strings is used as the new environment size, unless the /E:xxxx option is specified. Thus, removing SET variables until the total size is below 256 bytes makes space available every time.

The /E:xxxx specified in config.sys is only valid for the command processor used to process autoexec.bat, not for the one used when exiting to DOS or starting a DOS prompt from Win95.

Thus, you could try entering "command /e:2048" in the DOS prompt before you start the old program, and it might work. This should create a new command processor with more environment space. I tried it with NT, but here it makes no difference, the environment is always large enough for all variables.


0
 

Author Comment

by:Ulrich060397
ID: 1254057
I tried entering command /e:2048 before executing the program, but this one didn't help.
0
 

Author Comment

by:Ulrich060397
ID: 1254058
BUT: The problem is solved for me - thank you all!
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Problem with MFCApp 78 317
Read file descriptor 3 in C 14 102
Problem to show menu 5 82
xamarin c# deserialize Json containing nested object 2 66
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now