[Fawkes Git] branch/bschaepers/amcl-segfault-fix: created (0.5.0-3082-ge321e6c)

Bjoern Schaepers bjoern.schaepers at rwth-aachen.de
Sat Aug 27 19:54:35 CEST 2016


Changes have been pushed for the project "Fawkes Robotics Software Framework".

Gitweb: http://git.fawkesrobotics.org/fawkes.git
Trac:   http://trac.fawkesrobotics.org

The branch, bschaepers/amcl-segfault-fix has been created
        at  e321e6c49f8a2d4e02955c1180af2b1349e2402d (commit)

http://git.fawkesrobotics.org/fawkes.git/bschaepers/amcl-segfault-fix

- *Log* ---------------------------------------------------------------
commit e321e6c49f8a2d4e02955c1180af2b1349e2402d
Author:     Bjoern Schaepers <bjoern.schaepers at rwth-aachen.de>
AuthorDate: Wed Aug 17 16:32:44 2016 +0200
Commit:     Bjoern Schaepers <bjoern.schaepers at rwth-aachen.de>
CommitDate: Sat Aug 27 19:53:56 2016 +0200

    amcl: Fix SegFault with gcc6.
    
    i and src_i are unsigned, so there difference is also unsigned. So abs()
    doesn't make sense and it leads to the overflow (or under-?) as seen below.
    
    Thread 11 "FawkesMainThrea" received signal SIGSEGV, Segmentation fault.
    [Switching to Thread 0x7fffe6ffd700 (LWP 25820)]
    enqueue (map=map at entry=0x7fffe020ae50, i=i at entry=19, j=j at entry=22, src_i=src_i at entry=20,
        src_j=src_j at entry=22,
        Q=std::priority_queue wrapping: std::vector of length 672, capacity 1024 = {...},
        cdm=0x7fffe0210170, marked=0x7fffe0365fa0 "")
        at fawkes-robotino/fawkes/src/plugins/amcl/map/map_cspace.cpp:110
    110	  double distance = cdm->distances_[di][dj];
    
    (gdb) p di
    $1 = 4294967295
    (gdb) p dj
    $2 = 0
    (gdb) p i
    $3 = 19
    (gdb) p j
    $4 = 22
    (gdb) p src_i
    $5 = 20
    (gdb) p src_j
    $6 = 22

http://git.fawkesrobotics.org/fawkes.git/commit/e321e6c
http://trac.fawkesrobotics.org/changeset/e321e6c

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


- *Summary* -----------------------------------------------------------


- *Diffs* -------------------------------------------------------------

- *commit* e321e6c49f8a2d4e02955c1180af2b1349e2402d - - - - - - - - - -
Author:  Bjoern Schaepers <bjoern.schaepers at rwth-aachen.de>
Date:    Wed Aug 17 16:32:44 2016 +0200
Subject: amcl: Fix SegFault with gcc6.

 src/plugins/amcl/map/map_cspace.cpp |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/amcl/map/map_cspace.cpp b/src/plugins/amcl/map/map_cspace.cpp
index fbf0c56..48211e8 100644
--- a/src/plugins/amcl/map/map_cspace.cpp
+++ b/src/plugins/amcl/map/map_cspace.cpp
@@ -96,6 +96,15 @@ get_distance_map(double scale, double max_dist)
   return cdm;
 }
 
+static unsigned int delta(const unsigned int x, const unsigned int y)
+{
+  if(x < y)
+  {
+	return y - x;
+  }
+  return x - y;
+}
+
 void enqueue(map_t* map, unsigned int i, unsigned int j, 
 	     unsigned int src_i, unsigned int src_j,
 	     std::priority_queue<CellData>& Q,
@@ -105,8 +114,8 @@ void enqueue(map_t* map, unsigned int i, unsigned int j,
   if(marked[MAP_INDEX(map, i, j)])
     return;
 
-  unsigned int di = abs(i - src_i);
-  unsigned int dj = abs(j - src_j);
+  unsigned int di = delta(i, src_i);
+  unsigned int dj = delta(j, src_j);
   double distance = cdm->distances_[di][dj];
 
   if(distance > cdm->cell_radius_)




-- 
Fawkes Robotics Framework                 http://www.fawkesrobotics.org


More information about the fawkes-commits mailing list