Repository navigation
Conversation
copy_vm_spec() copies the VM spec into the process pool for the server-scoped VM reslist, but copied the compiled bytecode of a <LuaHook...> block with apr_pstrdup(), truncating it at the first NUL byte of the Lua header while keeping the full length. The hook function was never defined and every request failed with "Unable to find entry function". Use apr_pmemdup() with the length. The package path arrays were copied with apr_array_copy(), which only copies the pointers, so with LuaPackagePath or LuaPackageCPath set in .htaccess the strings lived in a request pool and were dangling when the reslist constructed a further VM later. Deep-copy the strings. While adding a test for this, the <LuaHook...> block reader crashed at config time when built against Lua 5.5: lua_dump() now pushes a table on the stack while dumping, and the luaL_Buffer used by the writer assumes its own box is at the stack top. Accumulate the bytecode in an ap_varbuf instead, off the Lua stack. Add a test/modules/lua pytest suite with a test that fails on the bytecode copy before this change. Its conftest.py and env.py match the suite proposed in PR apache#1022 so the two merge cleanly in either order. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
covener
force-pushed
the
lua-copy-vm-spec
branch
from
November 14, 2026 12:48
3cf4912 to
262b2e2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
LuaScope server,copy_vm_spec()copies the VM spec into the process pool for the shared VM reslist. It usedapr_pstrdup()on the compiled bytecode of a<LuaHook...>block, which stops at the first NUL byte of the Lua header while the stored length is kept, so the hook function never got defined and every request failed with AH01478. The package path arrays were also only shallow-copied, leaving dangling strings whenLuaPackagePathorLuaPackageCPathcomes from.htaccess.Writing the test also turned up a config-time crash with Lua 5.5:
lua_dump()now pushes a table onto the stack while dumping, and theluaL_Bufferused by the writer assumes its own box is at the stack top. The bytecode is now collected in anap_varbufoff the Lua stack.Adds a
test/modules/luapytest suite; the new test fails on the bytecode copy before this change. The suite'sconftest.pyandenv.pyare identical to those in #1022 so the two merge cleanly in either order.🤖 Generated with Claude Code