Clarify pptr checked and unchecked access modes#320
Clarify pptr checked and unchecked access modes#320netkeep80 merged 9 commits intonetkeep80:mainfrom
Conversation
Adding .gitkeep for PR creation (default mode). This file will be removed when the task is complete. Issue: netkeep80#312
resolve() на явные checked/unchecked/verified access modes
Solution summaryImplemented issue 312 and updated PR 320: #320 What changed:
Verification:
The branch is Useful next steps:
This summary was automatically extracted from the AI working session output. |
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
📊 Context and tokens usage:
Total: (792.3K + 90.2M cached) input tokens, 51.4K output tokens, $50.241380 cost 🤖 Models used:
📎 Log file uploaded as Repository (2 chunks) (108271KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
🔄 Auto-restart triggered (iteration 1)Reason: CI failures detected Starting new session to address the issues. Auto-restart-until-mergeable mode is active. Will continue until PR becomes mergeable. |
🔄 Auto-restart-until-mergeable Log (iteration 1)This log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
🤖 Models used:
📎 Log file uploaded as Repository (2 chunks) (115164KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
✅ Ready to mergeThis pull request is now ready to be merged:
Monitored by hive-mind with --auto-restart-until-mergeable flag |
netkeep80
left a comment
There was a problem hiding this comment.
Идея split на resolve_checked() / resolve_unchecked() по issue #312 правильная, и сам semantic seam нужен. Но в текущем виде здесь есть блокирующая ошибка именно в той части, которую PR заявляет как fix для SmallAddressTraits.
Проблема такая:
make_pptr_from_raw()теперь для non-aligned layout делаетceil(byte_off / granule); это выглядит как попытка корректно представить user pointer, который не лежит на границе гранулы;- но
resolve_unchecked()по-прежнему возвращаетbase + p.offset() * granule_size, то есть адрес гранульной границы, а не реальный user pointer; resolve_checked()используетraw_user_ptr_from_pptr(p)только для валидации блока, но в конце всё равно возвращаетraw, полученный изresolve_unchecked().
То есть для non-aligned случая (sizeof(Block) % granule_size != 0) checked/unchecked resolve-path остаётся смещённым и возвращает не тот адрес, который сам же raw_user_ptr_from_pptr() считает каноническим user pointer. Это ломает заявленный контракт fix-а для SmallAddressTraits и делает публичный resolve_checked() / resolve_unchecked() внутренне несогласованными. fileciteturn56file0
Проще говоря: сейчас PR валидирует один адрес, а возвращает другой. Для DefaultAddressTraits тесты это не ловят, но для small/non-aligned path это именно семантическая ошибка. fileciteturn56file0
Что нужно поправить:
- Сделать так, чтобы canonical source of truth для
pptr -> user pointerбыл один.
В non-aligned случаеresolve_unchecked()иresolve_checked()должны возвращать тот же адрес, который вычисляетraw_user_ptr_from_pptr(). - После этого добавить прямой regression test именно на
SmallAddressTraits/ non-aligned block-header path, а не только на default config. Сейчас issue #312 требует тесты на различие access modes, а PR дополнительно заявляет SmallAddressTraits fix, но отдельной focused regression на этот путь я в diff не вижу. fileciteturn57file0turn56file0
Пока это не исправлено, я бы PR не мёржил.
|
🤖 AI Work Session Started Starting automated work session at 2026-04-19T18:44:31.213Z The PR has been converted to draft mode while work is in progress. This comment marks the beginning of an AI work session. Please wait for the session to finish, and provide your feedback. |
8ccbaf8 to
0ba03a3
Compare
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
📊 Context and tokens usage:
Total: (102.5K + 6.2M cached) input tokens, 10.3K output tokens, $3.850374 cost 🤖 Models used:
📎 Log file uploaded as Gist (17299KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
🔄 Auto-restart triggered (iteration 1)Reason: CI failures detected Starting new session to address the issues. Auto-restart-until-mergeable mode is active. Will continue until PR becomes mergeable. |
🔄 Auto-restart-until-mergeable Log (iteration 1)This log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
🤖 Models used:
📎 Log file uploaded as Repository (49242KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
✅ Ready to mergeThis pull request is now ready to be merged:
Monitored by hive-mind with --auto-restart-until-mergeable flag |
netkeep80
left a comment
There was a problem hiding this comment.
Перепроверил обновлённую версию. Предыдущий блокер про несогласованный checked/unchecked path для SmallAddressTraits вы действительно закрыли: resolve_unchecked() теперь идёт через тот же canonical path, и focused regression на small/non-aligned case появился.
Но у меня здесь остаётся новый блокер: публичная canonical pptr-семантика всё ещё не проведена через все фабрики pptr.
Сейчас allocate_typed() / allocate_typed(count) уже возвращают pptr через block_idx + kBlockHdrGranules, то есть через новую canonical public pointer model. Но create_typed() и create_typed_unlocked() по-прежнему возвращают make_pptr_from_raw(raw), а intern_symbol_unlocked() тоже продолжает строить pptr<pstringview> через make_pptr_from_raw(raw).
Это критично, потому что в текущей версии make_pptr_from_raw() использует byte_off / granule_size, тогда как public resolve-path теперь читает pptr -> user pointer через raw_user_ptr_from_pptr() как base + offset * granule_size. Для non-aligned header path эти две модели уже не эквивалентны.
Иными словами:
allocate_typed()уже живёт в новой canonical модели;create_typed()и symbol interning всё ещё возвращают pptr из старой raw-payload модели;- в non-aligned конфигурации такой pptr при
resolve_checked()/resolve_unchecked()может указывать не на canonical public user pointer, а смещаться внутрь header/padding region.
Это делает PR внутренне непоследовательным: часть API уже переведена на новый contract, а часть фабрик pptr — ещё нет. Для issue #312 это блокирующий seam bug. fileciteturn61file0turn63file0turn68file0
Что нужно поправить:
- Либо
make_pptr_from_raw()должен стать действительно canonical constructor для новой public pptr model; - либо
create_typed(),create_typed_unlocked()иintern_symbol_unlocked()должны перестать использовать его в текущем виде и строить pptr тем же способом, что иallocate_typed(); - после этого нужен regression test не только на
allocate_typed, но и минимум на один путь, который идёт черезcreate_typed()в small/non-aligned конфигурации.
Пока это не исправлено, я бы PR не мёржил.
|
🤖 AI Work Session Started Starting automated work session at 2026-04-19T19:34:43.370Z The PR has been converted to draft mode while work is in progress. This comment marks the beginning of an AI work session. Please wait for the session to finish, and provide your feedback. |
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
📊 Context and tokens usage:
Total: (274.3K + 27.6M cached) input tokens, 34.1K output tokens, $15.953496 cost 🤖 Models used:
📎 Log file uploaded as Repository (39341KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
✅ Ready to mergeThis pull request is now ready to be merged:
Monitored by hive-mind with --auto-restart-until-mergeable flag |
Summary
Fixes #312.
This PR makes
pptr<T> -> T*access semantics explicit:resolve_checked()for public live-block access.resolve_unchecked()for deliberate internal/raw offset access.resolve()as a compatibility alias for the checked public path.pptr::resolve(),operator*, andoperator->through checked access.SmallAddressTraitsso checked and unchecked typed pptr resolution use the same canonical granule-aligned user pointer.Review And CI Follow-Up
Addressed review
4136392610, sanitizer CI follow-up, and review4136442981:resolve_unchecked()delegates to the canonicalraw_user_ptr_from_pptr()conversion.resolve_checked()validates the same pointer that it returns.make_pptr_from_raw()is now the canonical constructor for public pptrs: it finds the owning block and returnsblock_idx + kBlockHdrGranules.allocate_typed(),allocate_typed(count),reallocate_typed(),create_typed(), andcreate_typed_unlocked()now use that canonical factory path.create_typed()constructs at the canonical public user pointer anddestroy_typed()destroys at that same public pointer before freeing the physical block payload.intern_symbol_unlocked()writes pstringview contents at the canonical public pointer and stores the canonical pptr.pstringviewinterning now uses the same canonical public pptr model for variable-size stringview blocks.kBlockHdrGranules, notsizeof(Block), so metadata access agrees with canonical public offsets for non-aligned headers.SmallEmbeddedStaticConfigregressions for bothcreate_typed()and interned symbol/domain lookup in the small/non-aligned configuration.Tests
cmake -S . -B buildcmake --build build --target test_issue312_access_modesctest --test-dir build -R test_issue312_access_modes --output-on-failurecmake --build build --target test_forest_registry test_issue241_bootstrap test_issue151_pstringview test_issue146_sh_small_embedded_static test_issue146_index_sizesctest --test-dir build -R "test_forest_registry|test_issue241_bootstrap|test_issue151_pstringview|test_issue146_sh_small_embedded_static|test_issue146_index_sizes" --output-on-failure./scripts/generate-single-headers.sh --strip-commentsfind . \( -name '*.cpp' -o -name '*.h' \) ! -path './third_party/*' ! -path './include/pmm_*.h' ! -path './single_include/*' ! -path './build/*' -print0 | xargs -0 clang-format --dry-run --Werrorcmake --build buildctest --test-dir build --output-on-failure— 87/87 passed./scripts/check-file-size.shGITHUB_BASE_REF=main ./scripts/check-changelog-fragment.sh./scripts/check-docs-consistency.sh./scripts/check-repo-guard-rollout.sh./scripts/generate-single-headers.sh --strip-comments --output-dir /tmp/pmm-generatedplus diff checks against committed single headerscmake -S . -B build-asan -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-fsanitize=address,undefined -fno-sanitize-recover=all -fno-omit-frame-pointer"cmake --build build-asan --target test_issue312_access_modes test_issue146_index_sizes test_issue151_pstringviewctest --test-dir build-asan -R "test_issue312_access_modes|test_issue146_index_sizes|test_issue151_pstringview" --output-on-failure