Invalid Page Fault

Posted by Talon on Fri 12 Jul 2002 09:11 PM — 6 posts, 20,868 views.

#0
Alright, I'm going insane here. I play a graphical MUCK, and use MUSHclient for my 'bots' on it. I have a sparring place, the bots regulate the battles, allow you to buy new weapons, armor, saying how much damage you hit for, etc. I recently upgraded all of them to change the way they store stats, making it so a user's stats are stored in a file, and through VBScript, each bot can access the stats, alter them, and so forth. Things work fine, until all of a sudden sometimes one of the bots crash, giving me an error like this:

MUSHCLIENT caused an invalid page fault in
module MUSHCLIENT.EXE at 0167:0046f1af.
Registers:
EAX=00fc0078 CS=0167 EIP=0046f1af EFLGS=00010212
EBX=000000c2 SS=016f ESP=0077ef44 EBP=0077ef64
ECX=2fa80000 DS=016f ESI=00000000 FS=504f
EDX=0201004b ES=016f EDI=0000000b GS=0000
Bytes at CS:EIP:
89 4a 04 8b 4d f8 8b 51 04 8b 49 08 89 4a 08 8b
Stack dump:
00000054 010d44e0 010069a8 00000000 00fc01bc 000000c2 010d44aa 00000032 0077ef8c 00468bd6 010c000c 00000002 010d44e0 0047bd45 010d44e0 0041cd07

What causes this kind of error? The only thing I can imagine is that two of the bots must be trying to access the same file at the same time, or something? The funny thing is the bot I made purely in C has no problem. Here's an example of reading, and writing, that the bots use.

set fileo=createobject("scripting.filesystemobject")
set filen=fileo.opentextfile("c:\windows\desktop\filecrap\stats\" & getvarname(mid(vars(1), 14)), 1, true)
if (filen.atendofstream><true) then holderblah=filen.readall
filen.close

vars(1) is the string containing the user's name, getvarname is a function that changes the name to be file-safe (i.e. it will change any special characters not allowed in filenames to _)

set fileo=createobject("scripting.filesystemobject")
...
holderblah=world.getvariable("space1stats")
set filen=fileo.opentextfile("c:\windows\desktop\filecrap\stats\" & getvarname(world.getvariable("space1")), 2, true)
filen.write holderblah
filen.close

space1stats was the MUSH variable the person's stats were stored in for the battle, space1 is the MUSH variable that has their name..

Any ideas..? Am I doing something wrong? Or is it just that you can't have 4 bots trying to use the same files at once?
Australia Forum Administrator #1
I would check that the createobject and opentextfile actually worked. I don't have the docs in front of me right now, but it would be something like:

if not IsNull (filen) then
' blah blah
end if


(You might need IsEmpty instead of IsNull, see what OpenTextFile returns in case of error).
#2
Well, I tried using IsNull, and IsEmpty, I couldn't find any documentation on what OpenTextFile returns so I tried both and neither of them worked. What really REALLY makes the whole mess stranger is that I created two blank bots, put in just the simplest of script, for writing and reading. I played with them, messing with the code and getting them to read and write at the same times as each other, I got a few script errors, like 'Permission Denied', which is actually good.. I got NO crashes on the simple bots. Any other suggestions? If it's not the bots reading/writing at the same time, and it's not a full hard drive (I tried moving all the stat files to my other hard drive, no luck..) what else could it be? I hate bugs like this!
Australia Forum Administrator #3
Strangely enough, I cannot see any reference myself to how the opentextfile method handles failure. This is very strange, surely you would expect that a file could not be opened, because it wasn't there, insufficient privileges, or was in use.

All the examples in the MSDN documentation assume that the call will work, an assumption I would not personally make.

All I can suggest for now is doing it a different way, eg. using plugins with their serialization, writing a COM object, using variables or something like that.
#4
My vbscript code giving error "File could not opened" when i am trying to upload any file

i'm using this code
<SCRIPT language="vbscript">
function ReadBinaryFile(FileName)
on error resume next
Const adTypeBinary = 1

Dim BinaryStream
Set BinaryStream = CreateObject("ADODB.Stream")

BinaryStream.Type = adTypeBinary

BinaryStream.Open

on error resume next
BinaryStream.LoadFromFile FileName
if Err.number<> 0 then
msgbox(Err.Description )
boolFileExists = false
ReadBinaryFile = ""
exit function
end if
alert(BinaryStream.ReadText)
ReadBinaryFile = BinaryStream.Read

exit function
Msgbox("File Dosen't Exist")
end function



plz.. help me...
Australia Forum Administrator #5
This is nothing to do with MUSHclient or invalid page faults is it?

By the looks you are working on a web page with imbedded VBscript. I suggest posting on a forum that deals with VBscript in web pages.