Skip to content

Avoid GCC ubsan contexpr bug and add asan CI#2288

Merged
stephenberry merged 6 commits intomainfrom
gcc-fix
Jan 31, 2026
Merged

Avoid GCC ubsan contexpr bug and add asan CI#2288
stephenberry merged 6 commits intomainfrom
gcc-fix

Conversation

@stephenberry
Copy link
Copy Markdown
Owner

@stephenberry stephenberry commented Jan 31, 2026

PR: Add ASan CI and Fix Memory Leaks

Summary

This PR adds AddressSanitizer CI testing and fixes several memory leaks detected by ASan.

Changes

New ASan CI Workflow

  • Added .github/workflows/sanitizers.yml with GCC 15 and ASan enabled
  • Runs on ubuntu-24.04 with detect_leaks=1 to catch memory leaks in CI

GCC+UBSan Constexpr Fix (Issue #2287)

  • File: include/glaze/core/reflect.hpp
  • Moved constexpr auto& HashInfo = hash_info<keys_t> inside the nested lambda
  • Workaround for GCC Bug 71962 where UBSan breaks constexpr evaluation of references captured from outer scope

Memory Leak Fixes

glaze_asio.hpp

  • Added missing delete ptr in custom deleter for thread pool shared_ptr

http_server.hpp (streaming_utils namespace)

  • Fixed circular reference in send_periodic_data() - self-capturing lambda kept streaming connections alive indefinitely
  • Fixed circular reference in stream_collection() - same issue
  • Both now use enable_shared_from_this pattern to properly break the reference cycle
  • stream_collection() now copies the container to prevent dangling iterator issues

http_client_test.cpp

  • Fixed circular reference in /slow-stream test handler using enable_shared_from_this pattern

Testing

All networking tests pass with ASan enabled:

  • http_client_test: 22 passed
  • http_server_api_tests: 49 passed
  • http_server_post_test: 3 passed

@packit-as-a-service
Copy link
Copy Markdown

@stephenberry stephenberry changed the title Avoid GCC ubsan contexpr bug Avoid GCC ubsan contexpr bug and add asan CI Jan 31, 2026
@packit-as-a-service
Copy link
Copy Markdown

One of the tests failed for 46ba491. @admin check logs None, packit dashboard https://dashboard.packit.dev/jobs/copr/3207777 and external service dashboard https://copr.fedorainfracloud.org/coprs/build/10083150/

@stephenberry stephenberry merged commit cef905c into main Jan 31, 2026
42 of 43 checks passed
@stephenberry stephenberry deleted the gcc-fix branch January 31, 2026 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

reading variant with custom types fails to compile if ubsan is enabled

1 participant