Skip to content

Remove usage of alloca() & create vk_loader_platform.c - #2076

Merged
charles-lunarg merged 3 commits into
KhronosGroup:mainfrom
charles-lunarg:remove_alloca
Oct 22, 2026
Merged

charles-lunarg merged 3 commits into
KhronosGroup:mainfrom
charles-lunarg:remove_alloca

Conversation

@charles-lunarg

@charles-lunarg charles-lunarg commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Create vk_loader_platform.c to hold function definitions

Also replaces the usage of loader_fopen in asm_offset.c with the per
platform calls as it was the only function from vk_loader_platform.h
used by asm_offset. This prevents needing to compile
vk_loader_platform.c in the asm_offset executable.

Remove alloca from codebase

Alloca is not considered good practice and its usage has caused crashes
for users. Removing stack_allocation.h improving the allocating handling
logic across the codebase, since many places avoided returning out-of-
host-memory (OOHM) errors by using alloca instead of a real allocation.
This is done by passing a bool pointer out parameter to indicate an OOHM
error condition has occured.

In addition to the refactoring for OOHM, helpers for converting utf-8 to
ucs (aka wide chars to multi-byte chars) were added, since they too need
to allocate memory to hold the converted string.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build queued with queue ID 166139.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build queued with queue ID 166156.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build queued with queue ID 166170.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3878 running.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build queued with queue ID 166213.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3879 running.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3879 passed.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build queued with queue ID 166300.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build queued with queue ID 166317.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3881 running.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3881 failed.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build queued with queue ID 166345.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build queued with queue ID 166362.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build queued with queue ID 166364.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3884 running.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3884 passed.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build queued with queue ID 166469.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build queued with queue ID 166486.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3886 running.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3886 passed.

`= {};` is a compiler extension.
@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build queued with queue ID 166513.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3887 running.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build queued with queue ID 166531.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build queued with queue ID 166532.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3889 running.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build queued with queue ID 166568.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3890 running.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build queued with queue ID 166589.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3891 running.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build queued with queue ID 166608.

@charles-lunarg charles-lunarg changed the title Remove usage of alloca() & create vk_loader_platform.h Remove usage of alloca() & create vk_loader_platform.c Oct 22, 2026
@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3892 running.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3892 passed.

Also replaces the usage of loader_fopen in asm_offset.c with the per
platform calls as it was the only function from vk_loader_platform.h
used by asm_offset. This prevents needing to compile
vk_loader_platform.c in the asm_offset executable.
@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build queued with queue ID 167276.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build queued with queue ID 167293.

Alloca is not considered good practice and its usage has caused crashes
for users. Removing stack_allocation.h improving the allocating handling
logic across the codebase, since many places avoided returning out-of-
host-memory (OOHM) errors by using alloca instead of a real allocation.
This is done by passing a bool pointer out parameter to indicate an OOHM
error condition has occured.

In addition to the refactoring for OOHM, helpers for converting utf-8 to
ucs (aka wide chars to multi-byte chars) were added, since they too need
to allocate memory to hold the converted string.
@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build queued with queue ID 167322.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3897 running.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3897 passed.

@charles-lunarg

Copy link
Copy Markdown
Collaborator Author

Went through extensive review from claude, found many major and minor issues which have all been resolved.

@charles-lunarg
charles-lunarg merged commit 9cb1f10 into KhronosGroup:main Oct 22, 2026
52 checks passed
@charles-lunarg
charles-lunarg deleted the remove_alloca branch October 22, 2026 19:48
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.

2 participants