Skip to content

Restore 64bits pointers inRESTORE procedure. Solves #1545 #1550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 22 additions & 21 deletions src/saverestore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1611,17 +1611,15 @@ enum {
nextptr = my_ulong64;
if (!xdr_int32_t(xdrs, &UnknownLong)) break;
if (!xdr_int32_t(xdrs, &UnknownLong)) break;
} else
} else //the 2 pointers may point together to a l64 address, bug #1545
{
if (!xdr_uint32_t(xdrs, &ptrs0)) break;
nextptr = ptrs0;
if (!xdr_uint32_t(xdrs, &ptrs1)) break;
DULong64 tmp = ptrs1;
nextptr |= (tmp << 32);
if (!xdr_int32_t(xdrs, &UnknownLong)) break;
nextptr = ptrs0;
if (ptrs1 > 0)
{
DULong64 tmp = ptrs1;
nextptr &= (tmp << 32);
}
if (nextptr <=LONG) e->Throw("error in pointers, please report.");
}

//dispatch accordingly:
Expand Down Expand Up @@ -1796,14 +1794,11 @@ enum {
} else
{
if (!xdr_uint32_t(xdrs, &ptrs0)) break;
nextptr = ptrs0;
if (!xdr_uint32_t(xdrs, &ptrs1)) break;
DULong64 tmp = ptrs1;
nextptr |= (tmp << 32);
if (!xdr_int32_t(xdrs, &UnknownLong)) break;
nextptr = ptrs0;
if (ptrs1 > 0)
{
DULong64 tmp = ptrs1;
nextptr &= (tmp << 32);
}
}

//dispatch accordingly:
Expand Down Expand Up @@ -2233,10 +2228,10 @@ enum {


//will start at TIMESTAMP
uint64_t currentptr = LONG;
uint64_t nextptr = 0;
uint64_t nextptr = LONG;
uint64_t oldptr = 0;

fseek(save_fid, currentptr, SEEK_SET);
fseek(save_fid, nextptr, SEEK_SET);

const int MAX_DATE_STRING_LENGTH = 80;
time_t t=time(0);
Expand Down Expand Up @@ -2284,13 +2279,14 @@ enum {
if (verboselevel>0) Message("Saved common block: " + *itcommon);
}
//HEAP Variables: all terminal variables pointed by, OBJs or PTRs

oldptr=nextptr; //will test if number goes down: would be an error until the 64 bit xdr write is not fixed

if (heapIndexMapSave.size() > 0) { //there is some heap...
DPtrGDL* heapPtrList=e->Interpreter( )->GetAllHeap( );
for (SizeT i=0; i<heapPtrList->N_Elements(); ++i) nextptr=writeHeapVariable(e, xdrs, (*heapPtrList)[i], false);
for (SizeT i=0; i<heapPtrList->N_Elements(); ++i) { nextptr=writeHeapVariable(e, xdrs, (*heapPtrList)[i], false); if (nextptr <= oldptr) goto fail;oldptr=nextptr;}
GDLDelete(heapPtrList);
DObjGDL* heapObjPtrList=e->Interpreter( )->GetAllObjHeap( );
for (SizeT i=0; i<heapObjPtrList->N_Elements(); ++i) nextptr=writeHeapVariable(e, xdrs, (*heapObjPtrList)[i], true);
for (SizeT i=0; i<heapObjPtrList->N_Elements(); ++i) {nextptr=writeHeapVariable(e, xdrs, (*heapObjPtrList)[i], true); if (nextptr <=oldptr) goto fail;oldptr=nextptr;}
GDLDelete(heapObjPtrList);
}

Expand All @@ -2303,21 +2299,26 @@ enum {
// }
while (!systemVariableVector.empty())
{
nextptr = writeNormalVariable(xdrs, systemVariableVector.back().first, (systemVariableVector.back()).second, 0x2);
nextptr = writeNormalVariable(xdrs, systemVariableVector.back().first, (systemVariableVector.back()).second, 0x2); if (nextptr <=oldptr) goto fail;oldptr=nextptr;
if (verboselevel > 0) Message("SAVE: Saved system variable: " + (systemVariableVector.back()).first + ".");
systemVariableVector.pop_back();
}

while (!variableVector.empty())
{
nextptr=writeNormalVariable(xdrs, variableVector.back().first, (variableVector.back()).second);
nextptr=writeNormalVariable(xdrs, variableVector.back().first, (variableVector.back()).second); if (nextptr <=oldptr) goto fail;oldptr=nextptr;
if (verboselevel>0) Message("SAVE: Saved variable: " + (variableVector.back()).first+".");
variableVector.pop_back();
}

nextptr=writeEnd(xdrs);
xdr_destroy(xdrs);
fclose(save_fid);
return;
fail:
xdr_destroy(xdrs);
fclose(save_fid);
e->Throw("GDL cannot yet write such large SAVE files. Try with less values. File "+name+" is invalid, remove it.");
}

}
Expand Down