Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions cpp/travel/core/travel/aos.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,25 @@ namespace travel {

class AOSNode {
public:
uint start;
uint end;
int label;

AOSNode() : label(-1) {}
// start/end were declared without in-class initializers; combined
// with the uninit `int label` in `Point`, this leaked stack
// garbage into the per-channel node lists in horizontalUpdate
// and made cluster filtering decisions in labelPointcloud
// run-to-run nondeterministic. Zero-init makes the algorithm
// produce the same partition every time the input is the same.
uint start = 0;
uint end = 0;
int label;

AOSNode() : label(-1) {}
};

class Point {
public:
float x,y,z;
uint idx;
float x{0.0f}, y{0.0f}, z{0.0f};
uint idx{0};
bool valid = false;
int label;
int label{0};
};

template <typename T>
Expand Down
23 changes: 16 additions & 7 deletions cpp/travel/core/travel/tgs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,22 @@ namespace travel {
empty_trigrid_node_.check_life = 10;
empty_trigrid_node_.depth = -1;

empty_trigrid_node_.normal;
empty_trigrid_node_.mean_pt;
empty_trigrid_node_.d = 0;

empty_trigrid_node_.singular_values;
empty_trigrid_node_.eigen_vectors;
empty_trigrid_node_.weight = 0;
// The four lines below were no-op expression statements — almost
// certainly intended as zero-initializations but missing the
// assignment. Eigen types do not zero-init by default for
// performance, so without these the empty_trigrid_node_ ships
// four uninitialized members; copies of it then seed every
// node in trigrid_field_ with stack garbage. The algorithm
// overwrites these in the common path, but a few edge cases
// (small empty cells, boundary nodes) end up reading them,
// which surfaces as run-to-run nondeterminism downstream.
empty_trigrid_node_.normal = Eigen::Vector3f::Zero();
empty_trigrid_node_.mean_pt = Eigen::Vector3f::Zero();
empty_trigrid_node_.d = 0;

empty_trigrid_node_.singular_values = Eigen::Vector3f::Zero();
empty_trigrid_node_.eigen_vectors = Eigen::Matrix3f::Zero();
empty_trigrid_node_.weight = 0;

empty_trigrid_node_.th_dist_d = 0;
empty_trigrid_node_.th_outlier_d = 0;
Expand Down
Loading