Skip to content

fix(build): make tap unit_tests wait for the tap library directory (intermittent 'libcurl.so: file too short') - #6024

Merged
renecannao merged 1 commit into
v3.0from
fix/tap-unit-tests-build-race
Aug 10, 2026
Merged

fix(build): make tap unit_tests wait for the tap library directory (intermittent 'libcurl.so: file too short')#6024
renecannao merged 1 commit into
v3.0from
fix/tap-unit-tests-build-race

Conversation

@renecannao

@renecannao renecannao commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

A one-line build-ordering fix for an intermittent CI failure that presents as a corrupt dependency.

Symptom

CI-unit-tests-asan-coverage fails in its build step (the tests never run, and the follow-on Require non-empty coverage/lcov.info failure is just the same root cause):

/usr/bin/ld: error: /opt/proxysql/test/tap/tap/libcurl.so: file too short
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:794: genai_fts_string_unit-t] Error 1

Observed on #6021, whose diff touches only PgSQLFFTO and one PG TAP test — nothing that could reach libcurl or a genai unit test. The same workflow passed on the immediately preceding commit of that same branch.

Cause

test/tap/Makefile fans all / debug out to tests tests_with_deps unit_tests. Of those four sibling targets, unit_tests was the only one lacking the tap test_deps prerequisites:

tests:           tap test_deps      #
tests_no_infra:  tap test_deps      #
tests_with_deps: tap test_deps      #
unit_tests:                         #

So under parallel make it ran concurrently with tap.

The unit tests link -lcurl with -L$(TAP_LDIR) — that is, test/tap/tap (tests/unit/Makefile:83,218) — and the tap recipe populates that directory by copying the vendored library into it:

libcurl$(SHLIB_EXT): $(DEPS_PATH)/curl/curl/lib/.libs/libcurl$(SHLIB_EXT)
        cp -a $(DEPS_PATH)/curl/curl/lib/.libs/libcurl$(SHLIB_EXT)* .

libcurl.so and libcurl.so.4 are 16-byte symlinks onto libcurl.so.4.8.0, ~700 KB of actual payload. A linker following that chain while cp is still writing the payload reads a truncated ELF — which is precisely what file too short means. It is a partial read, not a bad library.

The CI log catches the overlap in the act; these lines are consecutive:

cp -a /opt/proxysql/deps/curl/curl/lib/.libs/libcurl.so* .
-- Detecting C compiler ABI info                              <- another job's cmake, i.e. concurrent
/usr/bin/ld: error: /opt/proxysql/test/tap/tap/libcurl.so: file too short
...
make[2]: *** Waiting for unfinished jobs....

Fix

Give unit_tests the prerequisites its three siblings already have, which serialises it after tap.

Why it looks random

It needs a copy and a link to overlap, so it hits some runs and not others. Nothing about it is specific to ASAN or to genai — that job simply builds the unit tests under a slower toolchain, which widens the window. Any PR can draw the short straw.

Verification

  • make -C test/tap -n unit_tests now descends into ../deps and tap before tests/unit. Before the change it went straight to tests/unit:

    BEFORE:  cd tests/unit && ... make unit_tests
    AFTER:   cd ../deps && ... make
             cd tap && ... make
             cd tests/unit && ... make unit_tests
    
  • Deleted test/tap/tap/libcurl.so* and ran make -C test/tap unit_tests -j$(nproc): completes cleanly and restores the full symlink chain (libcurl.solibcurl.so.4libcurl.so.4.8.0).

Related

Surfaced while investigating the ASAN failure on #6021. That PR needs no change for this — a re-run of the job would likely have gone green on its own.

Summary by CodeRabbit

  • Bug Fixes
    • Improved unit-test build reliability by ensuring required test components and dependencies are prepared before linking.

CI-unit-tests-asan-coverage failed its BUILD step with:

    /usr/bin/ld: error: /opt/proxysql/test/tap/tap/libcurl.so: file too short
    collect2: error: ld returned 1 exit status
    make[2]: *** [Makefile:794: genai_fts_string_unit-t] Error 1

Not a corrupt dependency -- a build race. In test/tap/Makefile the `all` and
`debug` targets fan out to `tests tests_with_deps unit_tests`, and
`unit_tests` was the only one of the four sibling targets without the
`tap test_deps` prerequisites (tests, tests_no_infra and tests_with_deps all
declare them). Under parallel make it therefore ran CONCURRENTLY with `tap`.

The unit tests link -lcurl with -L$(TAP_LDIR), i.e. test/tap/tap, and the
`tap` recipe populates that directory by copying the vendored library in:

    libcurl$(SHLIB_EXT): $(DEPS_PATH)/curl/curl/lib/.libs/libcurl$(SHLIB_EXT)
            cp -a $(DEPS_PATH)/curl/curl/lib/.libs/libcurl$(SHLIB_EXT)* .

libcurl.so and libcurl.so.4 are symlinks onto libcurl.so.4.8.0, ~700 KB of
real payload. A unit test's linker following that chain while cp is still
writing the payload reads a truncated ELF, which is what "file too short"
reports. The CI log catches the overlap directly -- the cp line, unrelated
cmake output from another job, and the ld error are consecutive, followed by
`make[2]: *** Waiting for unfinished jobs....`.

Adding the prerequisites serialises the two, matching the siblings.

Intermittent by nature: it needs a copy and a link to overlap, so it hits
some runs and not others. The same workflow passed on the immediately
preceding commit of the same branch, which is why this reads as a random
infrastructure failure rather than a build-order bug. It is not specific to
ASAN or to genai -- that job just happens to build the unit tests under a
slower toolchain, widening the window.

Verified: `make -C test/tap -n unit_tests` now descends into ../deps and tap
before tests/unit (previously it went straight to tests/unit), and a parallel
`make -C test/tap unit_tests -j$(nproc)` with test/tap/tap/libcurl.so*
deleted beforehand completes cleanly and restores the symlink chain.
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b70cdc14-39f4-4ea4-9c20-aad7d7eed9f1

📥 Commits

Reviewing files that changed from the base of the PR and between 3b9dc8a and e7916a1.

📒 Files selected for processing (1)
  • test/tap/Makefile
📜 Recent review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: Gitar
🔇 Additional comments (1)
test/tap/Makefile (1)

32-50: LGTM!


📝 Walkthrough

Walkthrough

The unit_tests target now depends on tap and test_deps. The Makefile documents the required libcurl build order.

Changes

TAP build ordering

Layer / File(s) Summary
Unit test prerequisites
test/tap/Makefile
The unit_tests target now depends on tap and test_deps. The Makefile documents the libcurl build-order requirement.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • sysown/proxysql#5601: Updates TAP test build prerequisites so TAP binaries are produced before tests run.

Poem

A rabbit checks the build with care,
TAP and libcurl now prepare.
Unit tests wait in proper line,
No racing links, the order’s fine.
Hop, hop—clean tests shine!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the build race, affected unit_tests target, and libcurl.so error addressed by the changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/tap-unit-tests-build-race

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

@gitar-bot

gitar-bot Bot commented Aug 10, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

Adds missing tap test_deps prerequisites to the unit_tests make target to fix intermittent parallel build races causing truncated library link errors. No issues found.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 53.14%. Comparing base (3b9dc8a) to head (e7916a1).
⚠️ Report is 10 commits behind head on v3.0.

Additional details and impacted files
@@             Coverage Diff             @@
##             v3.0    #6024       +/-   ##
===========================================
+ Coverage   38.72%   53.14%   +14.42%     
===========================================
  Files         257      483      +226     
  Lines       98801   144166    +45365     
  Branches    26183    36446    +10263     
===========================================
+ Hits        38261    76622    +38361     
- Misses      50151    50531      +380     
- Partials    10389    17013     +6624     
Flag Coverage Δ
integration-tests 49.37% <ø> (+10.89%) ⬆️
unit-tests 14.36% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@renecannao
renecannao merged commit 53a129d into v3.0 Aug 10, 2026
64 of 65 checks passed
@renecannao
renecannao deleted the fix/tap-unit-tests-build-race branch August 16, 2026 10:38
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.

1 participant