fix: dereference typed pointers in VML models safely - #39
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a081bc9629
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| address := unsafe { voidptr(value) } | ||
| if isnil(value) || address in ancestors { |
There was a problem hiding this comment.
Distinguish pointee types when detecting cycles
When a pointer targets the first field of an ancestor struct, its address is normally identical to the struct's address, so this address-only check incorrectly treats the interior pointer as a cyclic back-edge. For example, if Counter has count int followed by count_ref &int and count_ref = &counter.count, converting &counter makes count_ref invalid instead of exposing the number; the analogous check in v_schema_from_tracked also rejects app.counter.count_ref during validation. Track the pointee type together with the address (or otherwise distinguish interior pointers from actual back-edges).
Useful? React with 👍 / 👎.
Fixes #25.
Changes
Automatically dereference typed pointers during VML model value and schema conversion, allowing expressions such as
app.counter.countwhencounteris&Counter. Preserve the existing conversion behavior for scalar, struct, and array values.Handle nil references without dereferencing them, and track ancestor addresses to avoid infinitely traversing cyclic object graphs while still permitting shared references. Schema conversion can inspect declared pointee types for nil references and empty pointer arrays. Include explicit handling for multiple pointer indirections supported by V 0.5.2.
Tests cover live values after actions, nested/shared/cyclic references, unused nil fields, nil-path diagnostics, empty and populated pointer arrays, invalid fields, scalar pointers, and multiple nil indirections.
Applications must still initialize references they intend to read (for example,
counter: &Counter{}). This change does not allocate objects for nil pointers, make cyclic back-edges readable, or add pointer-target two-way writes.Verification
Passed with V 0.5.2:
The regression fails against the original implementation and passes with this change. These commands also passed on Linux before branch publication: verification log. The shared run later stopped on an existing scrolling-test compilation failure for another issue.
Pointer regression tests also passed locally under AddressSanitizer (
-cc gcc -gc none, leak detection disabled). No temporary verification infrastructure is included in this PR.