Can saveimage/compactimage lose objects?


#1

David, excuse me, could you comment on the lines :

while (firstfree < obj) {
    if (marked(obj)) {
      car(firstfree) = car(obj);
      cdr(firstfree) = cdr(obj);
      unmark(obj);
      movepointer(obj, firstfree);

According to my expectations, the expression

 mark(firstfree)

should be built there. Else object can be lost.
i use code:

  car(firstfree) = car(obj);
  cdr(firstfree) = cdr(obj);
  movepointer(obj, firstfree);
  mark(firstfree);  // There is mark the object which was moved
  unmark(obj);

Before i was lost objects. Now all right.
But maybe I don’t understand everything in uLisp codes, and I’m wrong.

I confess, i am a sinner: i was write an extension for creating C-type arrays in uLisp. During debugging, i had some difficulties with compactimage() and saveimage().

Now it works. Image contains binary arrays following of all workspace.
But we can talk about this separately if there is interest.


#2

Just to be clear, are you referring to code in the standard implementation of uLisp, or new code that you’re writing in a uLisp extension file?

I’m not aware of any problem with the standard versions of uLisp losing objects as a result of saveimage() or compactimage().


#3

David, i use ulisp standard code compactimage(), but i made adopt uLisp for 64bit processor. It can lead to like errors. My array system placed in extention in other file.
When i add mark(firstfree) it begins work without lost my arrays.

 car(firstfree) = car(obj);

This line must copy mark-bit from obj to firstfree. That is why additional mark(firstfree) is not necessary. Am i undestand correctly ?

If it so, i have to find an errors in my version.
David, I apologize, I probably bothered you for nothing. I wanted to make sure that I understood the ulisp code correctly.


#4

Hi Anatoly,

I don’t quite understand what you mean by:

My array system placed in extention in other file.

Are you using uLisp’s arrays, or have you written your own array system in a uLisp extension file? Are you saying that the arrays get lost/corrupted when you call compactimage()?

What platform version of uLisp are you using? What processor are you running it on?

Note that if you suspect a problem with compatcimage() you can test using saveimage() without calling compactimage() by setting the WORKSPACESIZE to a small enough value to fit the whole workspace in your persistent storage without compacting it.

Regards, David


#5

David, hello!
Thank you for your feedback. I am working with version 4.6 for ESP reworked for Linux x64.

David, it seems that the problem was in incorrect work with the pointer on Workspace. malloc() makes a different address for each session. I take this offset into account and adjust the pointer fields. I did something wrong there. It all seems to work without the need to put an additional mark(firstfree) now.

There is a file arrayis.cpp on my github. In it you can see the principles of organizing of my c-type arrays. I use the descriptor header, at the beginning of the array. There is all the information about the dimensions and type. I marked the commands (make-array*) (aref*) with a star.
I had to make inserts in the functions place, setf, incf, decf and some other. New objects type is ARRAY2. But a am afraid it will take some time for you to discover that. But If it is interesting and useful you can use this codes and ideas for future versions.

I think it is possible to include this array type in common aref and make-aray functions. May be i shall do it.

At least it allows to operate with bitmaps and design good API and sprite graphics.

Very convenient possibility is to use uLisp on arm-linux embedded boards. It allows to make good API and avoid time spending for cross-compilation and upload during debug a unit. (For usual avr and arm microcontrollers it is too)


#6

Thank you for the reply. An interesting application of uLisp - I’ll take a look at it. David