Hi All
Hope all is well with you. I think I might be doing something wrong and I'm
a bit stuck. I would be grateful for any help.
First off, I'm compiling with icc on Redhat 8.2 with no optimisation.
Second off, the following reproduces my problem. Most of the time, it runs
fine, with no issues. Maybe 1 in every 20 runs, for the same input, it
crashes with the following error: "free(), invalid pointer. Aborted. Core
dumped."
So, ..
I have a JL array. The index of the JL array is either 1,2 or 3. The 1,2 or
3 maps to one of 3 Word_t casted J1 Arrays. The 3 J1 Arrays contain Word_t
casted versions of an indeterminate number of J1 Arrays that in turn contain
either 1, 2 or 3 Words. In other words, I'm trying to map to all the J1
Arrays that contain a certain number (either 1, 2 or 3) of items in my
program.
So here's the guts of the code that I'm running to reproduce the problem.
This is all it does. Just reads stuff in, stores it, then deletes it.
Laid out, this is the code .
Pseudo Code:::::::::::::
//Declare and set the top JLArray
Pvoid_t storage = (Pvoid_t)NULL;
//Declare the J1Array
Pvoid_t J1Array;
//This is the main loop to store stuff - this NEVER crashes. The loop that
works perfectly most times, but crashes sometimes, is below.
Pseudo Outer Loop To Store Stuff{
//Initialise
J1Array = (Pvoid_t)NULL;
Pseudo Inner Loop To Get the Words for individual J1 Arrays{
//Get a Word from a file or something
Get a Word from a file or something;
//Set the Word in the J1Array
J1S(Rc_int, J1Array, Word);
}End Inner Pseudo Loop
//Count how many items in the J1Array and store total in counter - either 1,
2 or 3
J1C(counter, J1Array, 0, -1);
//get the mapping for the J1 Array that stores the J1 Arrays with counter
items
JLG(PSet, storage, counter);
//if there are no J1 Arrays with counter items yet
If (PSet == (PWord_t)NULL){
JLI(PSet, storage, counter);
*PSet = 0;
}
J1S(Rc_int, (Pvoid_t)*Pset, (Word_t)J1Array);
}End Outer Pseudo Loop
PWord_t Pset;
Word_t counter;
//This is the main loop to delete stuff. This is the loop that works most of
the time, but crashes sometimes.
//Keep deleting stuff from storage until there is nothing left, starting
with the J1Array's with 1 item, then 2 items, then 3 items.
//It's inefficient, I know, but I don't mind. It is a big outer loop in the
proper program, and occurs infrequently.
While (storage != (Pvoid_t)NULL){
//initialise counter
counter = 1;
//Get the mapping (PSet) to the first Word_t casted version of the J1 Array
and store the number of items in counter
JLF(PSet, storage, counter);
//initialise the Word_t casted version of the J1Array, which stores the J1
Arrays, which in turn store the counter items
J1Array_Word = 0;
//Get the first Word_t casted version of the J1Array in *PSet
J1F(Rc_int, (Pvoid_t)*PSet, J1Array_Word);
//Unset the same Word_t casted version of the J1Array
J1U(Rc_int, (Pvoid_t)*PSet, J1Array_Word);
//if there are no more
If (*PSet == 0){
JLD(Rc_int, storage, counter);
}
//free the memory for each J1 Array storing counter items
J1FA(bytes, (Pvoid_t)J1Array_Word);
}
_______________________________________________
Judy-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/judy-devel