Rebuild_Ptr initialization problem
HeadReaper-hc opened this issue · 4 comments
Hi,
Nice work!
I found you didn't initialize the variable of "Rebuild_Ptr" in your code. When I run your demo, everything seems ok, but when
I use your code into my own project with ROS it always leads to problem crash, I solved this problem after I set the initial value of "Rebuild_Ptr" to nullptr. I can't sure is this a bug or I just somehow make my program right. So Can you help me to see if this problem will cause the program to crash?
Best wish.
Hi,
Nice work!
I found you didn't initialize the variable of "Rebuild_Ptr" in your code. When I run your demo, everything seems ok, but when
I use your code into my own project with ROS it always leads to problem crash, I solved this problem after I set the initial value of "Rebuild_Ptr" to nullptr. I can't sure is this a bug or I just somehow make my program right. So Can you help me to see if this problem will cause the program to crash?
Best wish.
Thanks a lot for your advice.
It was my mistakes to miss intializing the "Rebuild_Ptr". It will be initialized in a latest version to be updated later, which fixed some bugs of the current public version.
As I am not sure whether the crash is caused by other reasons, would you please send me some screenshots or the error msgs when your ROS node died?
The error code is shown below, although I don't think it's very informative.
Optimizer Object is created!
Estimator Object is created!
Optimizer Object is created!
LoopCloser Object is created!
**Multi thread started**
Mapper Object is created!
Sensors Grabber is created...
OV²SLAM is ready to process incoming images!
[ov2slam_node-2] process has died [pid 29464, exit code -11, cmd /home/hc/work/ros_ws/devel/lib/ov2slam/ov2slam_node /home/hc/work/ros_ws/src/ov2slam-main/parameters_files/accurate/aqualoc/harbor_mono.yaml __name:=ov2slam_node __log:=/home/hc/.ros/log/e3515b1a-c430-11eb-a35e-4c3488ce980c/ov2slam_node-2.log].
log file: /home/hc/.ros/log/e3515b1a-c430-11eb-a35e-4c3488ce980c/ov2slam_node-2*.log
Actually I only add **_KD_TREE* temp = new KD_TREE_**
in my code, so I think the problem is occured in the construction of KD_TREE, then I further found the problem may happen in the following code:
void KD_TREE::multi_thread_rebuild(){
bool terminated = false;
KD_TREE_NODE * father_ptr, ** new_node_ptr;
pthread_mutex_lock(&termination_flag_mutex_lock);
terminated = termination_flag;
pthread_mutex_unlock(&termination_flag_mutex_lock);
// Not sure whether we need a flag to notice this thread to finish and stop
while (!terminated){
pthread_mutex_lock(&rebuild_ptr_mutex_lock);
pthread_mutex_lock(&working_flag_mutex);
**_if (Rebuild_Ptr != nullptr ){_**
/* Traverse and copy */
if (Rebuild_Logger.size()>0){
printf("\n\n\n\n\n\n\n\n\n\n\n ERROR!!! \n\n\n\n\n\n\n\n\n");
}
.............................................
But I still don't understand why this not happen in your demo, Perhaps this is an accidental question.
@HeadReaper-hc
Well, I think you are right. That is the problem about initialization.
As fas as I know, different compiling platforms and enviroments may have different initialization policies when handling the non-initialized variables; thus I doubt my demo worked because the "Rebuild_Ptr" has been suitably initialized in accident. I will do a careful double check on the variable initialization before publishing the next version.
Many thanks for your advice!
Thanks for your reply.