Skip to content
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

the Btree insert core dump #1

Open
hettonw opened this issue Dec 7, 2022 · 9 comments
Open

the Btree insert core dump #1

hettonw opened this issue Dec 7, 2022 · 9 comments

Comments

@hettonw
Copy link

hettonw commented Dec 7, 2022

the example tester, run with coredump,btree.cpp:79 (*RootNodePos)->PushDown,RootNodePos's null

@fjalcaraz
Copy link
Owner

I don't understand, how did you run the tester? what test file (.r) did you run with the tester and what input file (.i) did you use?
Did you try to use btree.cpp in another project? If it is your case, remember that you have to initialize the root node to null

@hettonw
Copy link
Author

hettonw commented Dec 8, 2022

just run the tester with the rule file,.like, tester ../examples/app_a.r, i don't input the object file(app_a.i), then progrom coredump.in the function::InsertList(), numkeys is 0, and Root's null, "(*RootNodePos)->PushDown" will coredump.
then i add follow at the function begin:
if(!Root) {
Root = new BTNode(Item, NULL, NULL);
*RootNodePos = Root;
BTItemPos = (void **)(*RootNodePos)->keyPointer(0);
NumItems++;
return BTItemPos;
}
then,it run normally,
but, "tester ../examples/app_a.r"
here is the result:
"Compiler Warning, Line 23 : Assuming equality on var "x"
Offset=0, n=0
Engine Fatal Error : load_code: Unknown code (0x408)"

@fjalcaraz
Copy link
Owner

I've seen a poor control on the input file format in the tester application that produces coredumps and it is been already fixed. But, what is important is that Engine Fatal error you get that I cannot reproduce. Did you get that output when using ../examples/app_a.r as it is in the repo? Can you send me the output of ./tester -p ../examples/app_a.r?
Thanks a lot

@hettonw
Copy link
Author

hettonw commented Dec 8, 2022

I didn't notice whether the latest version was used,but ,the rule file of app_a.r is the same as the repo。
this is the output:

load rule file from:../examples/app_a.r
Compiler Warning, Line 23 : Assuming equality on var "x"
Offset=0, n=0
Engine Fatal Error : load_code: Unknown code (0x408)

Because the function of InsertListbtree will cause a fragment,i have no idea. so, i add some initialization codes at the begining of 'InsertListbtree '.
did u fix it?
can i pull the repo now?

@fjalcaraz
Copy link
Owner

fjalcaraz commented Dec 8, 2022

It is not clear your fix is needed:

  • first because the Engine Fatal Error : load_code: Unknown code (0x408) indicates that something has not been compiled right by the engine and this may be the cause of the error. This error does not happen to me so this seems to be a c++ compiling issue.
  • In case Root is null, PushDown is executed with this = null and in this case it returns MoveUp what has a value of true:
 715    if (this == NULL)   // stopping case
 716    {  // cannot insert into empty tree
 717       MoveUp = true;
 718       NewItem = CurrentItem;
 719       NewRight = NULL;
 720    }

so in insertList a new root node will be created:

  79    MoveUp = (*RootNodePos)->PushDown(Item, NewItem, NewRight, BTItemPos, &Found, Func, List);
  80 
  81    if (MoveUp)   // create a new root node
  82    {
  83       *RootNodePos = new BTNode(NewItem, *RootNodePos, NewRight);
  84       if (Item == NewItem)
  85          BTItemPos = (void **)(*RootNodePos)->keyPointer(0);
  86    }


@fjalcaraz
Copy link
Owner

fjalcaraz commented Dec 8, 2022

Engine Fatal Error : load_code: Unknown code (0x408) is generated in load.cpp when loading engine bytecode, what substitutes function codes by pointers to the functions that implement them. According to hdrs/codes.h 0x408 corresponds to POPS (load the value of an object attribute into another object/attribute):

 76 #define PUSHS 0x404
 77 #define POPS 0x408
 78 
 79 #define PUSHO 0x410

In load.cpp:

 577     case POPS | TYPE_STR:
 578       *pcode++ = (ULong)&Node::popsa_call;
 579       pcode++; // The attribute
 580       break;
 581     case POPS | TYPE_NUM:
 582     case POPS | TYPE_FLO:
 583       *pcode++ = (ULong)&Node::pops_call;
 584       pcode++; // The attribute
 585       break;

The byte code POPS appears with a TYPE modifier that indicates the type of the attribute. In engine.h the basic types are defined:

#define TYPE_STR 0
#define TYPE_NUM 1
#define TYPE_FLO 2
#define TYPE_SAME 3

As TYPE_STR is 0 POPS | TYPE_STR is 0x408, so it had to enter in the case at line 577!!.

I don't understand how a valid code is not recognized in the load.cpp switch and goes to the default entry generating that error. This seems that the compiling of the code on your side was not correct, or some code has been modified. Please review everything and try to find something that might explain this or try a git pull again

@hettonw
Copy link
Author

hettonw commented Dec 9, 2022

thinks a lot, i'll try it. i need time to read all the code, it's wonderfull project.
if there have some documents to descirbe the relationship between the btree and rete net is much better to learn it.

@fjalcaraz
Copy link
Owner

Thanks for your opinion.
I have used the BTrees to implement the memories of the inter-nodes where every object that arrive to a node by a given side (left or right) will check the node conditions with all the objects arrived by the other side, making couples (known as a compound) that will go down to the node's children. After this process he will be stored waiting for the objects to come in the future by the other side. This process is linear, very inefficient when the number of objects are huge, so in order to accelerate it the nodes are ordered in the memories by the conditions to be tested so it is extremely fast.
By example, if the condition is A.x == B.y (A and B are objects, A will come by left and B by right, x and y are attributes of them and the node must find the objects with same value in these attributes), the left memory will have ordered the A objects by the different values of their x attribute and the right memory will have the B objects ordered by the different values of the y attribute.

@hettonw
Copy link
Author

hettonw commented Dec 15, 2022

hi,there some strange errors confused me,

715 if (this == NULL) // stopping case
716 { // cannot insert into empty tree
717 MoveUp = true;
718 NewItem = CurrentItem;
719 NewRight = NULL;
720 }

in my env, in my first run, the value of ptr 'this' is 0.but, "this==NULL" is not true! i don't understand why?
and in the function of load_code(), the pcode is 0x200, but, it jump to the case "case TLE | TYPE_STR:"
is there some wrong with my compiler?
can u show my your compiler env?
that makes me crazy =,=!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants