I've been expanding the test case program for contrib\hbbtree and I've
encountered a nasty runtime error.
This is the runtime error message - no other message / callstack / trace
back is shown:
This application has requested the Runtime to terminate it in an
unusual way.
Please contact the application's support team for more information.
I google'd for it, found a Microsoft knowledge base article (about a
problem with msvcrt.dll) and I installed the hotfix, but this did not
resolve the problem; given that the KB article is about a MSVC
environment I knew it was a long shot.
A self contained test program basically creates a new btree, inserts a
single record and closes the btree.
If the btree is file-based there is no runtime error but that is because
it is using an internal long variable not an HB_ITEM.
If the btree is memory-based, the runtime error occurs under one
circumstance:
- the data value inserted is a number, and
- there is _no_ print statement between the insert and the close; to
clarify:
create
insert
close
If the data value is a string the runtime error does not occur, or if
there _is_ a print statement; to clarify:
create
insert
print
close
By liberally filling my code with a simple logging method I've
discovered that the runtime error is from the release of the item.
The item history is (from the various parts of the code that create,
store, and delete item):
// parameter #3 must be a long for file-based and any for memory-based
hb_retl( hb_BTreeInsert( pBTree, hb_parc( 2 ), hb_paramError( 3 ) ) );
// the above parameter is pData; here is being assigned to the btree
item
pBTree->pThisKeyData->xData.pData = hb_itemNew( pData );
// when the btree is being closed, all items are released; this is
the source of the failure
hb_itemRelease( thisptr->xData.ppData[ n ] );
Because the problem goes away with the inclusion of a print statement or
the use of a string data I'd suspect that garbage collection has
occurred but I do not know how that affects this.
I thought my internal link list was faulty but my research says
otherwise; I thought I was trying to release an item twice but my
research says otherwise.
I hope someone can point me to a possible cause.
April
--
Until I was thirteen, I thought my name was shut up.
- Joe Namath
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour