AprilRobotics / apriltag

AprilTag is a visual fiducial system popular for robotics research.
https://april.eecs.umich.edu/software/apriltag
Other
1.47k stars 522 forks source link

enable ASan for C++ #255

Closed christian-rauch closed 1 year ago

christian-rauch commented 1 year ago

When looking into https://github.com/AprilRobotics/apriltag/issues/253 I noticed that the AddressSanitizer is not enabled for C++ code. This is only relevant for the opencv_demo.

This PR uses the same ASAN flags for C and C++ code and for Debug as well as Release builds. While at it, I fixed some of the whitespace issues and added an additional configuration flag -c to select the camera to use.

Regarding the actual memory leaks, there are some leaks in libfontconfig.so. But overall, this seems to be constant. No matter how long I let the opencv_demo run without showing an actual tag, ASan will report SUMMARY: AddressSanitizer: 43736 byte(s) leaked in 812 allocation(s)..

However, ASan reported some division by zero errors which may be related to https://github.com/AprilRobotics/apriltag/pull/213:

apriltag_math.h:73:37: runtime error: division by zero
apriltag_math.h:76:23: runtime error: division by zero
apriltag_math.h:79:14: runtime error: division by zero
apriltag.c:847:24: runtime error: division by zero
apriltag.c:847:37: runtime error: division by zero
apriltag.c:848:26: runtime error: division by zero
apriltag.c:849:26: runtime error: division by zero
apriltag.c:850:26: runtime error: division by zero
apriltag_math.h:41:17: runtime error: division by zero
apriltag_math.h:44:17: runtime error: division by zero
apriltag_math.h:64:14: runtime error: division by zero
apriltag_math.h:50:31: runtime error: division by zero
apriltag_math.h:67:23: runtime error: division by zero
apriltag_math.h:70:14: runtime error: division by zero
apriltag_quad_thresh.c:912:26: runtime error: division by zero
apriltag_quad_thresh.c:912:44: runtime error: division by zero