Skip to content

Handle allocation failure when boxing - #919

Merged
maleadt merged 1 commit into
mainfrom
tb/box-null-malloc
Sep 4, 2026
Merged

Handle allocation failure when boxing#919
maleadt merged 1 commit into
mainfrom
tb/box-null-malloc

Conversation

@maleadt

@maleadt maleadt commented Sep 3, 2026

Copy link
Copy Markdown
Member

Runtime.box wrote the type tag and payload through every pointer returned by malloc. OpenCL has no device allocator and returns C_NULL; after inlining, back-end optimizers can treat those stores as undefined and remove the throwing path, including signal_exception.

Use the same failure path as gc_pool_alloc: report OOM and throw OutOfMemoryError before writing. This prevents an invalid Julia object from escaping and gives optimization a real exceptional path. Cover both allocator-less SPIR-V back-ends and verify the OOM and original exception paths.

`Runtime.box` wrote the type tag and payload through every pointer returned by `malloc`. OpenCL has no device allocator and returns `C_NULL`; after inlining, back-end optimizers can treat those stores as undefined and remove the throwing path, including `signal_exception`.

Use the same failure path as `gc_pool_alloc`: report OOM and throw `OutOfMemoryError` before writing. This prevents an invalid Julia object from escaping and gives optimization a real exceptional path. Cover both allocator-less SPIR-V back-ends and verify the OOM and original exception paths.
@maleadt

maleadt commented Sep 3, 2026

Copy link
Copy Markdown
Member Author

This is a prerequisite for improved exception handling in OpenCL.jl (without having to add a device-side allocator).

@codecov

codecov Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.14%. Comparing base (c098b16) to head (06cc32c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #919      +/-   ##
==========================================
+ Coverage   85.04%   85.14%   +0.09%     
==========================================
  Files          29       29              
  Lines        5563     5566       +3     
==========================================
+ Hits         4731     4739       +8     
+ Misses        832      827       -5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@maleadt
maleadt merged commit ea53814 into main Sep 4, 2026
33 checks passed
@maleadt
maleadt deleted the tb/box-null-malloc branch September 4, 2026 07:21
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.

1 participant