[klee-dev] Why can't we use ExecutionState object in vector or map templates in cpp

Frank Busse f.busse17 at imperial.ac.uk
Thu Apr 4 10:45:14 BST 2024


Hi,


On Thu, 4 Apr 2024 00:32:02 +0530
Adarsh Sudheer <adarshs2023 at gmail.com> wrote:

> Recently i tried to map the current the executionstate to it's left and
> right nodes using execution tree and all seemed fine until I encountered
> various segmentation errors. Firsty, in the ExecutionState class
> definition, i defined my new attribute as like this

I'm not sure what you are trying to achieve but keep in mind that only
leaf nodes in the execution tree carry a state.

> I tried to then insert the states like this
> 
> if(IS_OUR_NODE_VALID(p->left) && IS_OUR_NODE_VALID(p->right)){
> p->state->NextStates.push_back(p->left.getPointer()->state);
> p->state->NextStates.push_back(p->right.getPointer()->state);
> }
> else if(IS_OUR_NODE_VALID(p->left)){
> p->state->NextStates.push_back(p->left.getPointer()->state);
> p= p->left.getPointer();
> }
> else{
> p->state->NextStates.push_back(p->right.getPointer()->state);
> p= p->right.getPointer();
> }
> 
> 
> I was relieved when the build didn't raised any error but when i tried to
> get the intermediate results (not included) , I repeatedly get seg-fault.

The joys of C++. :)

>  #4 0x000055757d0c292e std::vector<klee::ExecutionState*,
> std::allocator<klee::ExecutionState*> >::push_back(klee::ExecutionState*
> const&) /usr/include/c++/11/bits/stl_vector.h:1189:20
>  #5 0x000055757d0c292e klee::RandomPathSearcher::selectState()

Seems that you modified the RandomPathSearcher. Can you show the rest of
the select() function?

> How can i include execution state as a template in maps and vectors

Putting pointers to ExecutionStates in a container is not an issue, we
do it all the time. It becomes an issue when states get terminated and
you still try to access them via their stale pointers.


Kind regards,

Frank



More information about the klee-dev mailing list