what causes illegal operations?

zision

Member
Jan 20, 2000
118
0
0
I've been studying for my DOS/Windows A+ test, and read that GPFs and Illegal Operations are caused by memory conflicts. which raised my curiousity, and I'd really like to know why this happens. Is it to be blamed on Windows, or individual applications? What exactly happens that causes these conflicts?

thanks.
 

AndyHui

Administrator Emeritus<br>Elite Member<br>AT FAQ M
Oct 9, 1999
13,141
17
81
Generally it's the result of sloppy memory programming by applications rather than Window's fault. People have a tendancy to blame Windows even if it is not at fault. The application should read and write to its own allocated space of memory, but sometimes it's not well behaved and overwrites portions of other applications in memory or parts of the OS, causing an error when that overwritten program goes looking for something that should be there.
 

easternerd

Member
Sep 15, 2000
146
0
0
hi there,
With an Os such as Windows 9X anything can cause An Illegal Operation ,It is mainly due to Memory mismanagement.
I shall explain it to u:
An Application X is running on a PC with 64 MB Ram
The Os Takes upto 20 Mb Ram
And other Applications take up some another 35 Mb
So there remains 9 Mb still
But Application X needs atleast 15 Mb to work efficiently
So it Asks the OS to send in some more Memory but it cannot
it replies i dont have any more memory
So this goes on as a cycle and LO! CRASH ! Illegal Operations !
and all that crap just popup
Win2K uses protected Memory Management ! Which gives a part of the memory to an APP and protects it ,So that when One APP crashes others still work!
Cool isnt it! ,Win 2K is really a master of Stability
 

AndyHui

Administrator Emeritus<br>Elite Member<br>AT FAQ M
Oct 9, 1999
13,141
17
81
easternerd: you have forgotten about virtual memory. If the system runs out of physical RAM as you have used in your example, less frequently accessed portions will be swapped to the hard drive.
 

chemwiz

Senior member
Mar 8, 2000
848
1
81
Plus Winblows (especially 98 original release) &quot;leaks&quot; memory, each time you open and close an app you lose some. That's why it runs so much nicer after a reboot. And yes, it is poor programming for an operating system to allow an application to write to memory that isn't allocated to it, so it is a Winblows problem. Doesn't happen much in Linux, and I have Unix machines I work on that run constantly, only being shut down for hardware replacement.
 

zision

Member
Jan 20, 2000
118
0
0
thanks for explaining that. I'm running win2k, and I have noticed a lot less crashes. although when something does crash, it can take a minute for it to close down which is a bit annoying. it could also be said adding more RAM, if you're in the 64 or 128MB range, could help causes less illegal operations, right?
 

paulip88

Senior member
Aug 15, 2000
908
0
0
If you have more RAM it might help slightly, but probably not much. Memory errors are often caused by the mishandling of virtual addresses, not physical addresses in RAM.

The reason why Win2K and WinNT do not experience as many problems with this is because both use the NT kernel which is better at memory managemnt. In other words, it is more strict in what it allows programs to do and usually stops memroy errors from crippling an entire system whereas Win9x just lets everything die.

The root of the problem isn't only windows though. Poor applications programming is the ultimate root of these errors. However, Windows 9x oftentimes fails to catch these errors before they take down the system.
 

StuckMojo

Golden Member
Oct 28, 1999
1,069
1
76

i dont know why im bothering to try to sort this out...but here goes:

everyone is on the right track...its bad programming practices, and is related to a process writing to memory its not supposed to. modern OSes try to use the concept of &quot;protected memory&quot; to keep from completely dieing when this happens. this means the kernel keeps track of what memory belongs to what app, and stops an app if it attempts to write to memory that doesnt belong to it (aka writing off the end of its stack). it actually does happen in unix and other OSes also, and is the technique used in most *nix security exploits.

the reason why it can cause 9x to crash more than NT, is that dos gives programs (more) direct access to hardware, in order to speed up things like graphics. it is much more difficult for the OS to keep hardware drivers from doing anything they want. a driver writing to memory willy nilly can really screw things up.

anyway, the point is that GPFs are not really bad things, its the OS trying to keep itself from getting screwed up by a program that is writing to memory it doesnt own. this can often happend from writing off the end of an array, or having a memory allocation fail, not checking the result, then trying to write to the resulting pointer (which will be null [= 0]).

of course, these things can happen if parts of the OS is poorly coded also....9x is kind of notorious for that :p, but more often its a poorly coded app or driver that is responsible.

(andy, dont slam me for this not being a completely correct explaination, im trying to explain it in a way that newbies can understand, and i dont have time to really do it right :p)