Skip to content

[WIP] Fix CMake alias target error by ensuring proper find_package and target_link_libraries - #2

Merged
makr-code merged 4 commits into
mainfrom
copilot/fix-150588092-1085539157-070cfc4d-b403-4f38-975f-050676113fde
Nov 3, 2025
Merged

makr-code merged 4 commits into
mainfrom
copilot/fix-150588092-1085539157-070cfc4d-b403-4f38-975f-050676113fde

Conversation

Copilot AI commented Nov 3, 2025 •

Copy link
Copy Markdown
Contributor

Fix CMake configuration to prevent "ALIAS target is missing" errors

ref: 7e043e7

Changes implemented:

  • Add CMake helper function link_required to safely check and link targets
  • Add defensive check for Boost::system target after find_package
  • Update to use proper Boost system component configuration
  • Add defensive checks for opentelemetry-cpp targets
  • Add comments explaining the defensive target checks
  • Validate CMakeLists.txt syntax and structure
  • Address code review feedback
  • Fix link_required function to properly handle visibility specifiers

All changes are minimal and focused on adding defensive checks to prevent "ALIAS target is missing" errors. The helper function link_required is provided for future use by maintainers to extend similar checks to other targets. Current code uses explicit target checks before existing target_link_libraries calls to maintain minimal changes.

Original prompt

CI job https://github.com/makr-code/ThemisDB/actions/runs/19028521897/job/54336951006 failed during CMake configure with message: "Target "themis_core" links to: An ALIAS target is missing." Logs attached in job ref 7e043e7.

Make a small PR that fixes the root cause by updating CMakeLists.txt to ensure required packages are found and their imported/alias targets exist before linking. Specific changes to implement:

  1. Around line ~160-200 in CMakeLists.txt, replace any raw or missing link names (e.g. "system" or unprefixed names) with the proper imported targets from find_package. For Boost system component, add or ensure:

    find_package(Boost 1.89.0 REQUIRED COMPONENTS system)
    if(NOT TARGET Boost::system)
    message(FATAL_ERROR "Required CMake target 'Boost::system' not found. Ensure Boost was found and the 'system' component is available.")
    endif()
    target_link_libraries(themis_core PRIVATE Boost::system)

  2. Add a small CMake helper function to centralize safe linking of required targets (link_required) that checks TARGET before linking and emits a clear error message if missing. Use this helper to link any other external imported targets used by themis_core (e.g. Protobuf, opentelemetry-cpp) where appropriate.

  3. Ensure any manually created ALIAS targets are created after the original real target. Add comments and defensive checks.

Include the job ref in the PR description for traceability: ref: 7e043e7.

If specific unknown target names are present (the repository may link other imported targets), the patch should add the helper and update Boost linking; maintainers can extend for other targets as needed. Provide unit-tested CMake only (no behavior changes).

This pull request was created as a result of the following prompt from Copilot chat.

CI job https://github.com/makr-code/ThemisDB/actions/runs/19028521897/job/54336951006 failed during CMake configure with message: "Target "themis_core" links to: An ALIAS target is missing." Logs attached in job ref 7e043e7.

Make a small PR that fixes the root cause by updating CMakeLists.txt to ensure required packages are found and their imported/alias targets exist before linking. Specific changes to implement:

  1. Around line ~160-200 in CMakeLists.txt, replace any raw or missing link names (e.g. "system" or unprefixed names) with the proper imported targets from find_package. For Boost system component, add or ensure:

    find_package(Boost 1.89.0 REQUIRED COMPONENTS system)
    if(NOT TARGET Boost::system)
    message(FATAL_ERROR "Required CMake target 'Boost::system' not found. Ensure Boost was found and the 'system' component is available.")
    endif()
    target_link_libraries(themis_core PRIVATE Boost::system)

  2. Add a small CMake helper function to centralize safe linking of required targets (link_required) that checks TARGET before linking and emits a clear error message if missing. Use this helper to link any other external imported targets used by themis_core (e.g. Protobuf, opentelemetry-cpp) where appropriate.

  3. Ensure any manually created ALIAS targets are created after the original real target. Add comments and defensive checks.

Include the job ref in the PR description for traceability: ref: 7e043e7.

If specific unknown target names are present (the repository may link other imported targets), the patch should add the helper and update Boost linking; maintainers can extend for other targets as needed. Provide unit-tested CMake only (no behavior changes).


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits November 3, 2025 11:12
- Add link_required() helper function to safely check and link targets
- Add defensive check for Boost::system target after find_package
- Add defensive checks for opentelemetry-cpp targets before linking
- Add comments explaining ZSTD target selection logic
- Ensure clear error messages if required targets are missing

Co-authored-by: makr-code <[email protected]>
Clarify that the helper function is provided for future use and explain
why explicit target checks are used in current code (minimal changes)

Co-authored-by: makr-code <[email protected]>
Update function signature to accept visibility (PRIVATE/PUBLIC/INTERFACE)
as a required parameter and check all targets including additional ones

Co-authored-by: makr-code <[email protected]>
@makr-code
makr-code marked this pull request as ready for review November 3, 2025 11:19
@makr-code
makr-code merged commit a62793d into main Nov 3, 2025
Copilot AI requested a review from makr-code November 3, 2025 11:19
@makr-code
makr-code deleted the copilot/fix-150588092-1085539157-070cfc4d-b403-4f38-975f-050676113fde branch November 30, 2025 11:50
makr-code added a commit that referenced this pull request Dec 6, 2025
…-070cfc4d-b403-4f38-975f-050676113fde

[WIP] Fix CMake alias target error by ensuring proper find_package and target_link_libraries
Copilot AI added a commit that referenced this pull request Dec 22, 2025
Copilot AI added a commit that referenced this pull request Jan 5, 2026
Copilot AI added a commit that referenced this pull request Jan 5, 2026
Fixed memory leak where expired cache entries were removed from the
map but not from the vector index during query operations.

Added vector index cleanup when erasing expired entries in the query
path (line 119). This complements the existing cleanup in the eviction
path (line 237) and clearExpired() method (line 295).

Without this fix:
- Expired entries would leak in the vector index
- Stale entries could appear in ANN search results
- Memory usage would grow unbounded (O(n) leak)
- Index performance would degrade over time

Co-authored-by: makr-code <[email protected]>
Copilot AI added a commit that referenced this pull request Jan 5, 2026
Created detailed document addressing both minor observations from code review:

**Minor Observation #1: Iterator API Lifecycle**
Three progressive solutions provided:
- Solution 1A: Enhanced documentation (15 min, immediate)
- Solution 1B: SafeIterator RAII wrapper (2-3 hrs, recommended)
- Solution 1C: Shared pointer DB handle (4-6 hrs, comprehensive)

Recommended: Solution 1B (SafeIterator) for next API iteration
- RAII-based automatic lifecycle management
- Move semantics for safety
- Familiar iterator interface
- Complete prevention of use-after-free
- Clean migration path from old API

**Minor Observation #2: Cache Statistics Consistency**
Two solutions provided:
- Solution 2A: Snapshot-based statistics (1 hr, simple)
- Solution 2B: Lock-free atomic with sequence numbers (2-3 hrs, high-perf)

Recommended: Keep current behavior (already acceptable)
- Only implement 2A if monitoring teams request it
- Current eventual consistency is appropriate for stats

**Implementation Priority Matrix:**
- Immediate: 1A (documentation)
- Medium-term: 1B (SafeIterator)
- Long-term: Consider 1C only during major refactoring
- Optional: 2A if needed, skip 2B

**Document Contents:**
- Detailed code examples for each solution
- Implementation guidelines
- Testing recommendations
- Migration paths
- Effort estimates and risk assessment
- 17KB comprehensive reference

Status: Optional enhancements - current code is production-ready

Co-authored-by: makr-code <[email protected]>
Copilot AI added a commit that referenced this pull request Mar 11, 2026
@makr-code makr-code added this to the v1.0.2 milestone Mar 11, 2026
Copilot AI added a commit that referenced this pull request Apr 7, 2026
- TODO #1: Add idle-timeout background thread to TumblingWindow and
  SlidingWindow (idleTimeoutLoop). When no events arrive for
  idle_timeout duration the watermark is advanced to now minus
  max_out_of_orderness and expired windows are closed and emitted.
  Tracks last_event_us_ atomically; thread started only when
  idle_timeout > 0ms; stopped safely before state teardown.

- TODO #2: Store partition_key in TumblingWindow::InternalWindow and
  SlidingWindow::InternalWindow. Set on window creation from the
  creating record's partition_key. Propagate to WindowResult in
  computeResult(). Update SlidingWindow::ensureWindowsExist signature
  to accept const std::string& partition_key.

- TODO #3: Track Session::has_late_records (default false). Set to
  true whenever a late record (ev_us < wm with allow_late_data) is
  added to a session in ingest(). Pass to computeResult() in
  ingest(), flush(), and expiryLoop() so is_late_firing is correctly
  set on timer-driven and gap-triggered session closures.

- TODO #4: Add session_expiry_interval_ms to
  StreamingWindowPipeline::Config. Update session() factory to accept
  optional expiry_interval_ms parameter. Forward to
  SessionWindowConfig::session_expiry_check_interval_ms in build().

- TODO #5: Replace O(N) inner loop in SlidingWindow::ensureWindowsExist
  and HoppingWindow::ensureWindowsExist with
  unordered_set<int64_t> window_start_set_ for O(1) duplicate
  detection. Keep set in sync on window creation and pruning in
  closeExpiredWindows().

- TODO #7: SessionWindow::computeResult() now accepts bool late = false
  and sets r.is_late_firing = late. All call-sites in ingest(),
  flush(), and expiryLoop() pass s.has_late_records.

- TODO #8: RESOLVED (no code change needed) — closeExpiredWindows()
  duplicate results on shutdown.

Co-authored-by: Copilot <[email protected]>

Co-authored-by: makr-code <[email protected]>
Copilot AI added a commit that referenced this pull request Apr 15, 2026
…ics cases

- Remove BENCHMARK(BM_OLAP_Disabled) from bench_olap_analytics.cpp
  (function was undefined; 4 productive cases already present)
- Update PERFORMANCE_EXPECTATIONS.md:
  - Mark Maßnahme #2 as ERLEDIGT in §1.4 table
  - Add AN-GB/AN-WIN/AN-JOIN/AN-TOPN to §6.1 AN-mapping table
  - Add 4 new proxy benchmark entries to §6.1.1
  - Update §1.3 Analytics row to reflect stub removal
- Fix logic bug in perf_expectations_rootcause_audit.py:
  META_CAUSE_2 now correctly reports OK when real cases exist and
  disabled stub was removed (previously always FAIL when real cases found)

Agent-Logs-Url: https://github.com/makr-code/ThemisDB/sessions/013de0bd-e297-4322-b6b5-47a881db022a

Co-authored-by: makr-code <[email protected]>
makr-code added a commit that referenced this pull request Apr 15, 2026
…analytics benchmark cases (#4651)

* Initial plan

* perf: remove BM_OLAP_Disabled stub, register 4 productive OLAP analytics cases

- Remove BENCHMARK(BM_OLAP_Disabled) from bench_olap_analytics.cpp
  (function was undefined; 4 productive cases already present)
- Update PERFORMANCE_EXPECTATIONS.md:
  - Mark Maßnahme #2 as ERLEDIGT in §1.4 table
  - Add AN-GB/AN-WIN/AN-JOIN/AN-TOPN to §6.1 AN-mapping table
  - Add 4 new proxy benchmark entries to §6.1.1
  - Update §1.3 Analytics row to reflect stub removal
- Fix logic bug in perf_expectations_rootcause_audit.py:
  META_CAUSE_2 now correctly reports OK when real cases exist and
  disabled stub was removed (previously always FAIL when real cases found)

Agent-Logs-Url: https://github.com/makr-code/ThemisDB/sessions/013de0bd-e297-4322-b6b5-47a881db022a

Co-authored-by: makr-code <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: makr-code <[email protected]>
makr-code added a commit that referenced this pull request Apr 15, 2026
…OLAP cases now buildable (#4658)

* Initial plan

* feat(benchmarks): add CMake target for bench_olap_analytics (4 real OLAP cases, Maßnahme #2)

Agent-Logs-Url: https://github.com/makr-code/ThemisDB/sessions/245ed4ff-bea4-4ded-8384-920faf893d64

Co-authored-by: makr-code <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: makr-code <[email protected]>
Copilot AI added a commit that referenced this pull request May 26, 2026
…lora_training_service

- data_race #1: Replace TOCTOU (load+store) on is_training_ with
  compare_exchange_strong (atomic claim)
- data_race #2-3: Add metrics_mutex_ to protect current_metrics_,
  loss_history_, current_adapter_id_, training_callback_ in all
  read/write paths (getMetrics, registerCallback, training loop,
  saveCheckpoint, loadCheckpoint, GPU callback)
- data_race #4-5: Add config_mutex_ to setTrainingConfig,
  getTrainingConfig, setHyperparameters, getHyperparameters; training
  loop takes a local Config snapshot at entry so it never races with
  external callers
- data_race #6: Phi-3 detection mutates local_config snapshot only,
  never touches shared config_
- data_race #7 (GPU): trainWithQuantization GPU callback now writes
  current_metrics_ and reads training_callback_ under metrics_mutex_
- iterator_invalidation: loss_history_.push_back and saveCheckpoint
  vector copy both guarded by metrics_mutex_
- no_timeout #1: stopTraining spin-loop replaced with condition_variable
  wait_for (30 s); on timeout is_training_ force-cleared
- no_timeout #2: training thread stores is_training_=false under
  stop_mutex_ then notify_all for correct happens-before with waiter
- tests: add 4 focused concurrency tests (concurrent getMetrics,
  stop clears flag, concurrent registerCallback, concurrent train
  serialisation)
- docs: update src/llm/MODULE_GAPS.md with W1-L02 gap delta (10 findings
  resolved)

Agent-Logs-Url: https://github.com/makr-code/ThemisDB/sessions/12047fc4-4373-4486-9917-d40ec122bea2

Co-authored-by: makr-code <[email protected]>
Copilot AI added a commit that referenced this pull request Aug 15, 2026
Add comprehensive test suite for Phase 5 C++ safety fixes:

1. test_index_destructor_safety.cpp (338 lines, 10 tests)
   - VectorIndexManager destructor exception handling
   - GPUVectorIndex destructor exception safety
   - Noexcept verification (static_assert)
   - HNSW resource cleanup validation
   - Tests: destructor no-throw, exception during shutdown, stack unwinding,
     multiple calls, concurrent destruction, GPU variants

2. test_index_iterator_validity.cpp (411 lines, 10 tests)
   - Snapshot pattern validation for iterator safety
   - Partition removal stress tests (500+ partitions)
   - Concurrent add/remove patterns (TSan validation)
   - Data operations concurrent with partition removal
   - Tests: safe removal, stress, concurrent access, interleaved patterns,
     snapshot semantics, edge cases (empty, duplicates)

3. test_index_gpu_memory_safety.cpp (458 lines, 10 tests)
   - GPU resource allocation/deallocation pairing (RAII)
   - Memory leak detection across init/destroy cycles
   - Exception safety during GPU initialization
   - Large allocation handling near GPU memory limits
   - Tests: basic allocation, leak detection, exception cleanup, large allocations,
     concurrent management, explicit shutdown, idempotency, state validation

CMakeLists.txt Updates:
- Auto-discovery of test_index_*.cpp files preserved
- Conditional CUDA linkage for GPU tests when THEMIS_CUDA_ENABLED=ON
- Proper test registration via themis_register_module_focused_test()

Validation Coverage:
✓ 30 comprehensive tests (10 per test file)
✓ Exception safety (try/catch scenarios)
✓ RAII patterns (noexcept destructors)
✓ Memory safety (allocation/deallocation tracking)
✓ Concurrency (TSan-compatible multi-threaded tests)
✓ Edge cases (empty, large scale, duplicate operations)
✓ Timeout: 120s per test (reasonable for Phase 5 workloads)

Build Integration:
- Compile: cmake --build . -j 16 (automatically discovered)
- Run: ctest -R "test_index_(destructor|iterator|gpu)" --output-on-failure
- Sanitizers: Built-in support for ASan/TSan/UBSan
- No additional dependencies beyond existing test infrastructure

Fixes Phase 5 Blocker #6 (MEDIUM) by providing regression test coverage
for fixes #1-4:
  Fix #1: VectorIndexManager::~VectorIndexManager() noexcept (line 94)
  Fix #2: releaseHnswResources_() helper for safe cleanup (line 304)
  Fix #3: GPUVectorIndex::~GPUVectorIndex() noexcept (line 121)
  Fix #4: Iterator invalidation fix via snapshot pattern (line 107)

All tests are production-ready and CI/CD compatible.

Co-authored-by: makr-code <[email protected]>
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.

2 participants