bugfix: fix memory corruption bug, add asan check in debug mode.

This commit is contained in:
tianlei.richard 2024-06-15 17:38:35 +08:00
parent 104370fb40
commit f0901e3c0a
2 changed files with 9 additions and 5 deletions

View File

@ -6,11 +6,15 @@ if(NOT CMAKE_BUILD_TYPE)
endif()
set(CMAKE_CXX_FLAGS "-Wall -Wextra")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS_DEBUG "-gdwarf-4 -g")
if (${CMAKE_BUILD_TYPE} STREQUAL Release)
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
else()
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CXX_FLAGS_DEBUG "-O1 -fsanitize=address -fno-omit-frame-pointer")
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS_DEBUG "-gdwarf-4 -g ${CXX_FLAGS_DEBUG}")
else()
set(CMAKE_CXX_FLAGS_DEBUG "-g ${CXX_FLAGS_DEBUG}")
endif()
endif()
file(GLOB_RECURSE CPP_FILES ${CMAKE_CURRENT_SOURCE_DIR} *.cc)

View File

@ -55,7 +55,7 @@ void Rasterizer::rasterize(const int mesh_idx,
const int y_max = std::min(std::max(0, aabb.y + aabb.height), height_);
for (int i = y_min; i < y_max; ++i) {
for (int j = x_min; j <= x_max; ++j) {
for (int j = x_min; j < x_max; ++j) {
auto &property = shading_points_[i][j];
const auto &[is_inside, z_screen] =
inside(Point2d{j + 0.5, i + 0.5}, t);