"An unexpected error has occurred" when attempting to close modules.

Hello,

When I open a module the close it then sort the listview than open another module the close I'm getting the following error. Is there a way of rewriting the memoryCleaner() function to prevent this. I have several modules within my database that have 4-12k links and if I load them all then a attempt to delete, Revert, Change links I get memory errors. So on I'm attempting to mange memory issues by closing all opened module between functions and only refresh link information for the selected items within then listview. Is my logic incorrect or is it just my memoryCleaner() that has the issues? Any help would be appreciated. Thank you. see attachment for the full dxl script.

-R-E- DXL: <Line:62> An unexpected error has occurred: doors.exe caused an EXCEPTION_ACCESS_VIOLATION in module doors.exe at 001B:009E89E4
 
Backtrace:
    <Line:1142> 
-R-F- DXL: <Line:62> internal error, please submit a bug report
Backtrace:
        <Line:1142>

 

 

void memoryCleaner() {
    Module mxopen       = null
        
        mxopen = null
        ///* DEBUG
        /*
        for mxopen in LoadedModule do {
                string NameFull = key(LoadedModule)
                print fullName(mxopen) " - " NameFull "\n"
        }
        */
        ///*/
        for mxopen in LoadedModule do {
                if(null mxopen) continue
                GlobStatusMod = fullName(mxopen)
                Item GlobItmStatus = item GlobStatusMod
                if((open module GlobStatusMod) || (baseline(mxopen))) {
                        if (fullName(mxopen) == fullName(m)"") continue
                        if (!null mxopen) {
 
                                ///* DEBUG infoBox("Saving... "fullName(mxopen))
                                if(!isRead(mxopen)) {
                                        noError()                       
                                                save(mxopen)///* DEBUG {Saving without prompting...}
                                        err = lastError()
                                                                                                                
                                        if (!null err) {
                                                errorBox(err)
                                                continue
                                        }
                                }
                                
                                noError()
                                        close(mxopen)
                                        ///* DEBUG {print "Closing... " fullName(mxopen) "\n"}
                                err = lastError()
                                                                                                        
                                if (!null err) {
                                        string NameFull = key(LoadedModule)
                                        errorBox(err "\n" NameFull)
                                        continue
                                }
                        }
                }
        }
        setempty(LoadedModule)
        if(!isRead(m)) {
                save(m)
        }
        downgrade(m)
}



-Jim



 

 


SystemAdmin - Mon Mar 25 10:02:02 EDT 2013

Re: "An unexpected error has occurred" when attempting to close modules.
llandale - Mon Mar 25 13:26:22 EDT 2013

First off, "LoadedModule" is a Skip with a string key, so use "createString" at line 18.

Second, I've never seen "setempty" for Skips before! My intuition suggests it needs to be tested, and in any case will NOT work if you put structures in the skip (DATA is 'Skip' or 'Buffer' or whatever).

I see line #62 is where you "GlobStatusMod = fullName(mxopen)", exception violations there mean that "mxopen" is non-null but corrupted or otherwise invalid.

At line #1377 I see you "put" into LoadedModule a string name and a Module handle "xMod". "xMod" can still have the value it had in the PREVIOUS loop since the logic above it does not guarantee it gets set. Thus, your clean up will close it, then loop around and try to use the now-corrupted Handle. Also, "xMod" here can be null. I'm pretty sure this mistake is elsewhere in the code.

I think if you reverse your skip list, KEY is the 'Module' and DATA is the 'string' name, you may have better luck.
  • for NameFull in LoadedModule do{
    • mxopen = (Module key LoadedModule)

However, consider this change:
  1. When program starts, put all "Module" handles of currently open modules in a Skip skpOriginals
  2. periodically in the code, loop through all currently open modules, and if each is not in the skpOriginals list then save and close it.
  3. It may happen that inside the code you decide to keep a particular module open; in which case you add it to skpOriginals.

This has the distinct advantage that you do NOT have to keep track of every module you open. The code I have to do this needs updating; such as making sure the Original modules are indeed still open; and looping twice through currently open modules, since a "close" may not work if some other module is keeping it open.

-Louie

Re: "An unexpected error has occurred" when attempting to close modules.
SystemAdmin - Tue Mar 26 11:52:09 EDT 2013

Hello,

setempty(Skip List) - seems to work am I overlooking something?

Thank you.
 

//***********************
void    fSkipDelSkip(Skip &skpIn)
{     // Delete the Skip list, first deleting all the 'Skip' list DATA elements.
        // Be sure the Skip's DATA is type 'Skip'.
 
        if (null skpIn) return
 
        Skip    skpData
 
        for skpData in skpIn do
        {  delete(skpData)
        }
        delete(skpIn)
}     // end fSkipDelSkip()
 
Skip ListofList = create ()
Skip List1 = create ()
Skip List2 = create ()
Skip List3 = create ()
Skip List4 = create ()
Skip List5 = create ()
 
put(List1, 0, "List1")
put(List2, 0, "List2")
put(List3, 0, "List3")
put(List4, 0, "List4")
put(List5, 0, "List5")
 
 
put(ListofList, 0, List1)
put(ListofList, 1, List2)
put(ListofList, 2, List3)
put(ListofList, 3, List4)
put(ListofList, 4, List5)
 
string temp = null
Skip skp
for skp in ListofList do {
        string temp = null
        for temp in skp do {
                print temp "\n"
        }
}
 
 
print "'After setempty(ListofList)'\n"
setempty(ListofList)
temp = null
for skp in ListofList do {
        string temp = null
        for temp in skp do {
                print temp "\n"
        }
}
 
print "'After List1 print'\n"
temp = null
for temp in List1 do {
        print temp "\n"
}
 
 
 
fSkipDelSkip(ListofList)
 
delete skp
 
//results
List1
List2
List3
List4
List5
'After setempty(ListofList)'
'After List1 print'
List1

 


-Jim