Skip to content

tests: add an ASan job running the whole test suite. - #2526

Open
u5surf wants to merge 1 commit into
openresty:masterfrom
u5surf:ci-asan-job
Open

u5surf wants to merge 1 commit into
openresty:masterfrom
u5surf:ci-asan-job

Conversation

@u5surf

@u5surf u5surf commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Adds an AddressSanitizer job that runs the whole test suite. Following @zhuizhuhaomeng's note that we could run all the test cases, this covers everything rather than a socket subset.

The key part is building LuaJIT with LUAJIT_USE_SYSMALLOC: without it, LuaJIT's allocator never returns memory to the C allocator, so ASan cannot see use-after-free on Lua objects at all.

What the job does

  • Builds nginx with NGX_BUILD_ASAN=1, which ngx-build already supports, and LuaJIT with LUAJIT_USE_SYSMALLOC.
  • Preloads the ASan runtime ahead of mockeagain. ASan refuses to start behind another library, and some test files (t/065-tcp-socket-timeout.t, t/131-duplex-req-socket.t) put mockeagain in LD_PRELOAD themselves.
  • Allows a longer TEST_NGINX_TIMEOUT than the other jobs, since ASan slows every request down.
  • Dumps asan-logs/ on failure. An ASan abort otherwise surfaces only as a connection error from the test harness, which is hard to read.

It finds real defects

Before #2525 landed, this job reported a heap-use-after-free in t/067-req-socket.t TEST 20 — the existing regression test from #2504 — on unmodified master:

==nginx==ERROR: AddressSanitizer: heap-use-after-free
WRITE of size 8
    #0 ngx_http_lua_socket_tcp_finalize  src/ngx_http_lua_socket_tcp.c:4592

That was #2517. With the fix merged, the job is clean.

I hereby granted the copyright of the changes in this pull request
to the authors of this lua-nginx-module project.

@u5surf u5surf changed the title ci: add an ASan job for the socket tests. tests: add an ASan job for the socket tests. Sep 16, 2026
@zhuizhuhaomeng

Copy link
Copy Markdown
Contributor

We clould run all the test cases.

@u5surf
u5surf force-pushed the ci-asan-job branch 6 times, most recently from 198738a to 8232eda Compare September 17, 2026 01:48
@u5surf u5surf changed the title tests: add an ASan job for the socket tests. tests: add an ASan job running the whole test suite. Sep 17, 2026
@u5surf

u5surf commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

@zhuizhuhaomeng Done — the job now runs the whole suite.

  • 231 files, 25,054 tests, no ASan reports.
  • t/146-malloc-trim.t is the one file left out: ASan replaces the allocator, so malloc_trim() returns 0 there.
  • The ASan runtime is preloaded ahead of mockeagain, so the files that preload it themselves run too.
  • TEST_NGINX_TIMEOUT is higher for this job than for the others.
  • The job takes about 25 minutes, against 17–19 for the other jobs.

The remaining red job is t/189-http2-subreq-error-wakeup.t, the flake #2523 addresses; it is unrelated to this change.

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