Doors Access violation vene purging object

Hi,

i get a Doors Access Violation  (not all the times) when i run this code:

    for o in m do {
        softDelete o    
    }
  
    purgeObjects_(m)

It crash on the purge instruction. Once crash and the next time i relaunch it doesn't crash!


bungle_77 - Tue Sep 30 10:36:51 EDT 2014

Re: Doors Access violation vene purging object
llandale - Tue Sep 30 10:48:03 EDT 2014

The exception violation window is useless.  However the dxl output pane should tell you which line of code caused the exception.

[1] You want to avoid changing the existence of "something"s in any of the doors "for something in elsething do" loops.  If you have a line of people and start from the beginning, figuring to go to the "next" person; but then rearrange the people or add people, you may not get to everybody or may bet to some folks twice.  Instead, stage the "somethings" in a Skip list:

  • int Sequencer = 0
  • Skip skpSomething = create()
  • for something in elsething do
  • {  put(skpSomething, Sequencer++, something)
  • }
  • for something in skpSomething do
  • {  now deal with something
  • }
  • delete(skpSomething)

[2] In the above case I'm guessing that when you "softDelete o" you are also soft deleting all its children; when you get back to the top of the loop the object is now deleted, the next object is also deleted, and the loop gets confused since it finds non-deleted objects.  You can put the objects in the skip, then plow through the skip, adding:

  • if (!isDeleted(o)) then softDelete(o)

[3] I think you also need to "flushDeletions" after the loop, and probably after the purge.

-Louie

Re: Doors Access violation vene purging object
bungle_77 - Tue Sep 30 11:04:12 EDT 2014

llandale - Tue Sep 30 10:48:03 EDT 2014

The exception violation window is useless.  However the dxl output pane should tell you which line of code caused the exception.

[1] You want to avoid changing the existence of "something"s in any of the doors "for something in elsething do" loops.  If you have a line of people and start from the beginning, figuring to go to the "next" person; but then rearrange the people or add people, you may not get to everybody or may bet to some folks twice.  Instead, stage the "somethings" in a Skip list:

  • int Sequencer = 0
  • Skip skpSomething = create()
  • for something in elsething do
  • {  put(skpSomething, Sequencer++, something)
  • }
  • for something in skpSomething do
  • {  now deal with something
  • }
  • delete(skpSomething)

[2] In the above case I'm guessing that when you "softDelete o" you are also soft deleting all its children; when you get back to the top of the loop the object is now deleted, the next object is also deleted, and the loop gets confused since it finds non-deleted objects.  You can put the objects in the skip, then plow through the skip, adding:

  • if (!isDeleted(o)) then softDelete(o)

[3] I think you also need to "flushDeletions" after the loop, and probably after the purge.

-Louie

i changed my code according to your suggestion to

    Skip skObjectToDelete=create
    int i_seq=0
    for o in m do {
        put (skObjectToDelete,i_seq++,o)
    
    }
    for o in skObjectToDelete do {    
        if (!isDeleted(o)) then softDelete(o)
    }
    flushDeletions
    purgeObjects_(m)
    flushDeletions

 

but i get still the same error on the purgeObjects_ instruction

Anyway it succeed to purge and if i run again the script it doesn't crash because there are no objects to delete

Re: Doors Access violation vene purging object
llandale - Tue Sep 30 11:18:45 EDT 2014

bungle_77 - Tue Sep 30 11:04:12 EDT 2014

i changed my code according to your suggestion to

    Skip skObjectToDelete=create
    int i_seq=0
    for o in m do {
        put (skObjectToDelete,i_seq++,o)
    
    }
    for o in skObjectToDelete do {    
        if (!isDeleted(o)) then softDelete(o)
    }
    flushDeletions
    purgeObjects_(m)
    flushDeletions

 

but i get still the same error on the purgeObjects_ instruction

Anyway it succeed to purge and if i run again the script it doesn't crash because there are no objects to delete

Don't know.  It is working for me.

  • You are declaring "Object o" and "Module m = current" somewhere yes?
  • It is possible there are already deleted objects to which you don't have "D" access?
  • Module is open Edit yes,  Not "shared"?
  • Is it possible some of the deleted objects still have incoming links? 

If the 1st pass aborts then probably some of the objects were purged.  I'd take a close look at the object at the top that didn't purge.

-Louie

Re: Doors Access violation vene purging object
bungle_77 - Tue Sep 30 11:40:51 EDT 2014

llandale - Tue Sep 30 11:18:45 EDT 2014

Don't know.  It is working for me.

  • You are declaring "Object o" and "Module m = current" somewhere yes?
  • It is possible there are already deleted objects to which you don't have "D" access?
  • Module is open Edit yes,  Not "shared"?
  • Is it possible some of the deleted objects still have incoming links? 

If the 1st pass aborts then probably some of the objects were purged.  I'd take a close look at the object at the top that didn't purge.

-Louie

The script is part of a bigger script. I have right onb all the object, i declare all the vairable correctly, i open in edit mode and the object has no incoming link but outcoming links.

I changed the code like this and it's working

    Skip skObjectToDelete=create
    int i_seq=0
    current = m
    for o in m do {
        put (skObjectToDelete,i_seq++,o)
    
    }

    for o in skObjectToDelete do {    
        if (! null o) then hardDelete(o)
    }
    delete skObjectToDelete
    flushDeletions

 

My module should not have children objects and i don't know if i can have some problem if there are objects with children.

Re: Doors Access violation vene purging object
llandale - Tue Sep 30 13:39:32 EDT 2014

bungle_77 - Tue Sep 30 11:40:51 EDT 2014

The script is part of a bigger script. I have right onb all the object, i declare all the vairable correctly, i open in edit mode and the object has no incoming link but outcoming links.

I changed the code like this and it's working

    Skip skObjectToDelete=create
    int i_seq=0
    current = m
    for o in m do {
        put (skObjectToDelete,i_seq++,o)
    
    }

    for o in skObjectToDelete do {    
        if (! null o) then hardDelete(o)
    }
    delete skObjectToDelete
    flushDeletions

 

My module should not have children objects and i don't know if i can have some problem if there are objects with children.

Is sorting and filtering on?

hardDelete() in the past only worked for undeleted objects.  So you had to make sure it was not deleted.  For soft deleted objects you would undelete them first.

When you delete an object you also delete all its children; so restrictions on them apply also (no incoming links).

I note you cannot insert objects when sorting and filtering is on since you really cannot tell where the new objects would end up in the hierarchy.  Perhaps the same is true for deleting.

-Louie

Re: Doors Access violation vene purging object
bungle_77 - Wed Oct 01 04:12:45 EDT 2014

llandale - Tue Sep 30 13:39:32 EDT 2014

Is sorting and filtering on?

hardDelete() in the past only worked for undeleted objects.  So you had to make sure it was not deleted.  For soft deleted objects you would undelete them first.

When you delete an object you also delete all its children; so restrictions on them apply also (no incoming links).

I note you cannot insert objects when sorting and filtering is on since you really cannot tell where the new objects would end up in the hierarchy.  Perhaps the same is true for deleting.

-Louie

There is no sorting and no filter.

But if i put all the objects in the skip list, if i delete a father object, the children objects in the skip list will be automatically deleted? will i find a null object?

Re: Doors Access violation vene purging object
llandale - Thu Oct 02 11:52:26 EDT 2014

bungle_77 - Wed Oct 01 04:12:45 EDT 2014

There is no sorting and no filter.

But if i put all the objects in the skip list, if i delete a father object, the children objects in the skip list will be automatically deleted? will i find a null object?

When you were "softDeleting" then the "Object" still exists and the handle in the Skip list is still valid; but for some they are now deleted.

When hardDeleting, yes you have a problem.  Yes, the Handle in the Skip List effectevly becomes corrupt.  Turns out I ran into that too, here is my rather sloppy algorithm for dealing with it.  You should be able to identify the parts you need.

 DidOne = true
 PassNum = 0
 OutMess = create()
 while (DidOne)
 {  DidOne = false
    PassNum ++
 //  OutMess += "...Doing Pass #" PassNum "\n"
    for oCurr in in_skpObjsToPurge do
    {  if (find(skpFailedObjects, oCurr))
          continue // Purge failed, don't try again
  //   OutMess +=  "!! Purging " oCurr."Absolute Number" "   " number(oCurr) "\n"
   // Object must be undeleted before it can be purged
   // via the HardDelete command.
       if (!leaf(oCurr)) continue // non-leaves cannot be purged via fHardDelete().
       ErrMess1 = fUnDelete(oCurr)
//            print identifier(oCurr) " Un  : '" ErrMess1 "'\n"
       if (null ErrMess1)
       {  ErrMess1 = fHardDelete(oCurr) // try to purge object
//             print identifier(oCurr) " Hard: '" ErrMess1 "'\n"
          if (!null ErrMess1)
          {  if (fIsSubStr(ErrMess1, "object has descendants", false))
             { ErrMess1 = "" // This error is expected.  Ignore it.
             }
             ErrMess2 = fSoftDelete(oCurr) // SoftDelete it, keep it in list for next pass.
//                print identifier(oCurr) " Soft: '" ErrMess2 "'\n"
   // ignore SoftDelete error
          } // end HardDelete failed
          else
          {   // No error purging.
             DidOne = true
             flushDeletions()
             delete(in_skpObjsToPurge, oCurr) // object purged, remove from list
          } // end if HardDelete is OK
       } // end if fUnDelete is OK

       if (!null ErrMess1)
       {  DidOne = true // keep loop alive
          in_CountFail++
          OutMess += fConCat("+++ Problem purging object '", identifier(oCurr),
                            "', do it manually:\n    ", fSysErr_Format(ErrMess1), "\n")
          put(skpFailedObjects, oCurr, oCurr) // Don't try to purge it again
       }
    }  // end for all objects in Purge Skip List
 }   // end DidOne While loop
 flushDeletions()

 

Re: Doors Access violation vene purging object
bungle_77 - Fri Oct 03 05:54:01 EDT 2014

llandale - Thu Oct 02 11:52:26 EDT 2014

When you were "softDeleting" then the "Object" still exists and the handle in the Skip list is still valid; but for some they are now deleted.

When hardDeleting, yes you have a problem.  Yes, the Handle in the Skip List effectevly becomes corrupt.  Turns out I ran into that too, here is my rather sloppy algorithm for dealing with it.  You should be able to identify the parts you need.

 DidOne = true
 PassNum = 0
 OutMess = create()
 while (DidOne)
 {  DidOne = false
    PassNum ++
 //  OutMess += "...Doing Pass #" PassNum "\n"
    for oCurr in in_skpObjsToPurge do
    {  if (find(skpFailedObjects, oCurr))
          continue // Purge failed, don't try again
  //   OutMess +=  "!! Purging " oCurr."Absolute Number" "   " number(oCurr) "\n"
   // Object must be undeleted before it can be purged
   // via the HardDelete command.
       if (!leaf(oCurr)) continue // non-leaves cannot be purged via fHardDelete().
       ErrMess1 = fUnDelete(oCurr)
//            print identifier(oCurr) " Un  : '" ErrMess1 "'\n"
       if (null ErrMess1)
       {  ErrMess1 = fHardDelete(oCurr) // try to purge object
//             print identifier(oCurr) " Hard: '" ErrMess1 "'\n"
          if (!null ErrMess1)
          {  if (fIsSubStr(ErrMess1, "object has descendants", false))
             { ErrMess1 = "" // This error is expected.  Ignore it.
             }
             ErrMess2 = fSoftDelete(oCurr) // SoftDelete it, keep it in list for next pass.
//                print identifier(oCurr) " Soft: '" ErrMess2 "'\n"
   // ignore SoftDelete error
          } // end HardDelete failed
          else
          {   // No error purging.
             DidOne = true
             flushDeletions()
             delete(in_skpObjsToPurge, oCurr) // object purged, remove from list
          } // end if HardDelete is OK
       } // end if fUnDelete is OK

       if (!null ErrMess1)
       {  DidOne = true // keep loop alive
          in_CountFail++
          OutMess += fConCat("+++ Problem purging object '", identifier(oCurr),
                            "', do it manually:\n    ", fSysErr_Format(ErrMess1), "\n")
          put(skpFailedObjects, oCurr, oCurr) // Don't try to purge it again
       }
    }  // end for all objects in Purge Skip List
 }   // end DidOne While loop
 flushDeletions()

 

what kind of library should i include tu have functions like fHardDelete, fConCat?

Whi do you use sometimes "in_skpObjsToPurge" and sometimes "skpObjsToPurge" what's the defferences?

 

Thanks a lot for the support

Re: Doors Access violation vene purging object
bungle_77 - Fri Oct 03 07:13:19 EDT 2014

bungle_77 - Fri Oct 03 05:54:01 EDT 2014

what kind of library should i include tu have functions like fHardDelete, fConCat?

Whi do you use sometimes "in_skpObjsToPurge" and sometimes "skpObjsToPurge" what's the defferences?

 

Thanks a lot for the support

I am getting fool, i have a module with many objects all at the same level!!! This objects have an outcoming link.

Every two time i try to delete them Doors  crash!

Now i wrote also this code similar to your i hope

    for o in m do {
        
        if (!isDeleted(o)) then undelete(o)
        put (skObjectToDelete,i_seq++,o)
    
    }
    string res
    bool DidOne=true
    while (DidOne) {
        DidOne = false
        for o in skObjectToDelete do {    
             if (find(skObjectToDelete, o))
              continue
            //if (!leaf(o)) continue
            noError()
            if (! null o) then hardDelete(o)
            res= lastError()
            if (res=="") {
                flushDeletions()
                delete(skObjectToDelete, o)
                DidOne = true
            } else {
                print "Error " o."Object Text" " " res "\n"    
            }
        }
    }
    flushDeletions

i put "//" becouse always crashed on that instruction and i think it's useless becouse i have no child requirement.

The code always crash on flushDeletion and it return no error

Re: Doors Access violation vene purging object
llandale - Fri Oct 03 15:54:30 EDT 2014

bungle_77 - Fri Oct 03 05:54:01 EDT 2014

what kind of library should i include tu have functions like fHardDelete, fConCat?

Whi do you use sometimes "in_skpObjsToPurge" and sometimes "skpObjsToPurge" what's the defferences?

 

Thanks a lot for the support

fConCat just concatenates efficiently, you can just get rid of the function and concatenate normally.  replace "fHardDelete" with "hardDelete"; I just wrote that to do extra error checking.

As for your last code:

  • You don't need to "find" the object in the Skip, the loop is doing that.
  • Deleting the object from the Skip may mess up the loop; but youwant to "break" after it in order to restart the loop.  I think that is a bug in my code also.
  • Deleting the object from the loop MUST be done with the Skip's "Key", in this case the integer i_seq.  Put the first of the following at the top of the loop and the 2nd as your delete:
    • i_seq = (int key skObjectToDelete)
  • I think this will be a lot more effecient if you process the objects in reverse order; bottom to top.  Change your original "put" to this:
    • put (skObjectToDelete,i_seq--,o)    // last put has the lowest number
  • You are getting the crash because you are removing an "Object" from the skip; whose address doesn't match anything in the skip and so nothing gets removed.  next time through the loop the "Object" handle of that object now points into Never-Never land.
  • I see in my program that calls the above, I did this, so I was deleting the "Object" key.
    • put(skp, o, o)

-Louie