Export 2D view: overlap removal uses edge pointers after the list has been reallocated

Đang mở Phù hợp với người mới
#1,774 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
74/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
cpp
Lĩnh vực
computer-graphics, desktop

Hướng nghiên cứu

Bắt đầu tại ExportLinesAndMesh, ở lượt loại bỏ phần chồng lấn được mô tả trong issue. Kiểm tra cách sel->AddEdge() có thể cấp phát lại danh sách cạnh và cách sei, sej, pAj và pBj được sử dụng sau đó; issue đề xuất lưu các giá trị trước khi gọi và lấy lại các con trỏ sau đó. Hoàn tất khi cả hai nhánh tách đều tránh sử dụng con trỏ đã bị vô hiệu hóa và các bản xuất 2D vẫn chính xác.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

System information
  • solvespace master 952c11c0, built on Arch Linux
  • Also present in every release since 7c60be82 (2016)
Description

The pass that removes overlapping line segments at the end of
ExportLinesAndMesh walks the edge list with raw SEdge * and calls
sel->AddEdge() when it splits a segment. List::Add may reallocate, and
sei, sej, pAj and pBj all point into that array, so the writes right
after the call can land in memory that has been moved:

// split segment
if(ta < 0.0 - eps && tb > 1.0 + eps) {
sel->AddEdge(sei->b, *pBj, sej->auxA, sej->auxB);
*pBj = sei->a; // pBj may dangle here
continue;

}
and a few lines further down:

if(ta > 0.0 + eps && tb < 1.0 - eps) {
sel->AddEdge(*pBj, sei->b, sei->auxA, sei->auxB);
sei->b = *pAj; // and sei, pAj here
i--;
break;
}

How visible it is

Hard to hit, because the collinearity test above it uses eps = 1e-6, so
splits are rare. It is not only theoretical: of 172 sketches of mine, three
export a different file once the pointers are refetched - by two vertices on
one and by 0.015 of total length on another. Those three are reading moved
memory today.

It becomes easy to hit as soon as splits are common. I widened that
collinearity tolerance in a fork while chasing a different problem, and the
first file that reached this code segfaulted.

Fix

Take the values before the call, then re-fetch the pointers after it. I can
send a PR if that is the shape you want; pAj/pBj need recomputing from the
refetched sej since they may be swapped.

Ngôn ngữ chính
C++
Star
4.2k
Fork
600
Merge trung bình
9 giờ 37 phút
Pull request đã merge (30 ngày)
9

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của solvespace/solvespace

Tất cả issue của solvespace/solvespace

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.