Introducing proper deallocation ways for CPPInstance - #58
Open
keremsahn wants to merge 15 commits into
Open
Conversation
…er-research#41) * [cpyrt] Improve error reporting for method calls without C++ object Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * [test] Add test for method calls on an instance without a C++ object Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Grigori Rybkine <Grigori.Rybkine@cern.ch> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
…esearch#40) * [cpyrt] Penalize void* arguments in overload priority as intended * [test] Add regression test for void* overload priority --------- Co-authored-by: Emery Conrad <emery.conrad@chicagotrading.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
…rch#42) Fixes the long-standing header duplication (previously `Cppyy.h` and `cpp_cppyy.h`) between cpyrt and interop, so that there is only a single source of definitions for the `cppjit::interop` API and types.
Changed definition of a function to the test it is actually used, and added a missing import
…er-research#50) Drops wheel sizes by about half. Previously the entire install tree of CppInterOp was staged that included duplicate shared libs due to versioning. This is fixed by adding a stripped shared-lib option in CppInterOp, leveraged in this patch.
…ch#52) [cpyrt] Clear the error indicator only where a call failed A debug build of CPython asserts when a C API call is made with the error indicator already set, so the __cpp_cross__ annotation, the meta_setattro fallthrough to tp_setattro, and the VectorData alias need it cleared. Clear it only on the failing path: AddToClass reports failure, and the two CPPScope sites can test the value they just produced, so an error raised elsewhere still propagates. meta_getattro returns a new reference; release it instead of leaking it.
* [test] Find eigen and boost under the Homebrew and MacPorts prefixes * [ci] Build and test manylinux and macOS arm64 wheels
…esearch#54) SetArg() created an element converter per call and appended it to fConverters, but Clear() frees only fBuffer, so the vector grew without bound across repeated std::initializer_list conversions. Create each element converter once, on first use of its index, and reuse it.
…iler-research#51) * Serialize and atomize test dictionary builds * Force loadfile scheduling for distributed test runs * Normalize the xfail marker keyword order * Correct the xfail markers and add missing reasons * Add the --run-crashing-xfails collection option * Enable strict xfail * Drop xfail markers that no longer fail on macOS and cling * Make the span tests include their own header
keremsahn
force-pushed
the
cppins-prop-dealloc
branch
3 times, most recently
from
September 1, 2026 11:52
622f8b2 to
82a9b99
Compare
keremsahn
marked this pull request as draft
September 1, 2026 12:06
keremsahn
force-pushed
the
cppins-prop-dealloc
branch
2 times, most recently
from
September 1, 2026 12:34
041ff25 to
9d29a43
Compare
keremsahn
force-pushed
the
cppins-prop-dealloc
branch
from
September 1, 2026 12:44
9d29a43 to
a706d92
Compare
Contributor
Author
|
I do not have access to a mac and I am trying to figure out why macos tests fail, that is why I am pushing constantly |
keremsahn
force-pushed
the
cppins-prop-dealloc
branch
2 times, most recently
from
September 1, 2026 13:14
5a08cf9 to
763a5f7
Compare
…p information and this information effects kIsCreator flag of overload group , currently analyzer is not called, just attribute checker is called
…mory-related attributes in the FunctionDecl, analyzer is disabled by default and set by cppjit.use_alloc_analyzer(True/False)
keremsahn
force-pushed
the
cppins-prop-dealloc
branch
from
September 1, 2026 13:14
763a5f7 to
7d54a18
Compare
… delete AllocType was collapsed into kIsCreator in HandleReturn and never reached op_dealloc_nofree, so malloc'd, new[]'d and raw operator-new'd memory were all freed with a scalar delete. Carry it on the instance as three flags saying what to do: kIsArrayAlloc, kIsNoConstruct, kIsMalloc. HandleReturn sets them when taking ownership; op_dealloc_nofree branches on them to delete[], free, ::operator delete or ::operator delete[]. No destructor runs for the raw cases. All flags clear keeps the old delete path, so constructors and explicit __python_owns__ are unaffected. delete[] goes through CppInterOp's dtor wrapper, so interop::Destruct just stops pinning its count to 0; the rest are plain host-side calls. Fixed two fixtures that claimed malloc via attributes but called new, added coverage for the new paths plus a destructor counter, and exposed read-only __is_array_alloc__ / __is_no_construct__ / __is_malloc__ for the tests. Verified under valgrind: no mismatched free or memory leak. Also manual ownership setting is added to test07.
keremsahn
force-pushed
the
cppins-prop-dealloc
branch
from
September 1, 2026 15:46
7d54a18 to
eba937e
Compare
keremsahn
marked this pull request as ready for review
September 1, 2026 16:12
Comment on lines
+207
to
+208
| alloc() | ||
| assert cppjit.gbl.memory.memOwn.dtorCount == 0 |
Collaborator
There was a problem hiding this comment.
Suggested change
| alloc() | |
| assert cppjit.gbl.memory.memOwn.dtorCount == 0 | |
| alloc() | |
| gc.collect() | |
| assert cppjit.gbl.memory.memOwn.dtorCount == 0 |
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.
Built upon #37, just last commit is related to this PR
I added three flags to the CPPInstance to distinguish different allocation methods, and in HandleReturn ,where ownership is given, corresponding flags are set after analyzer/attribute check.
Using these new flags CPPInstance::op_dealloc_nofree introduces different kind of deallocations.
Also tests changed a lot after this feature
And I need to explain why I added kIsArrayAlloc instead of using kIsArray, users can set kIsArray flag by reshape feature:
and if user reshapes the returned object, that will lead UB because object is deallocated by operator delete[]
@Vipul-Cariappa @aaronj0 @vgvassilev