Skip to content

WGPU: wgpuAdapterRequestDevice inexplicably segfaults if anything relating to a limit is created #38

@hotcocoaNcode

Description

@hotcocoaNcode

M2 MacBook Air running Sequoia 15.0.1, I am honestly at a loss here.

For some inexplicable reason whenever I create a WGPURequiredLimits or WGPUSupportedLimits, the call to wgpuAdapterRequestDevice causes a segfault.

This is such that

//WGPURequiredLimits reqs{};
//reqs = getRequiredLimits();
deviceDesc.requiredLimits = nullptr;

works perfectly fine, while even

WGPURequiredLimits reqs{};
//reqs = getRequiredLimits();
deviceDesc.requiredLimits = nullptr;

or

WGPURequiredLimits reqs{};
reqs = getRequiredLimits();
deviceDesc.requiredLimits = nullptr;

will not succeed.

Since I am using the C API with no reference of the C++ file in my code, I am assuming no weird constructor is being called.
To attempt to circumvent this, I have tried the following horrible thing.

char reqs[sizeof(WGPURequiredLimits)];
*reinterpret_cast<WGPURequiredLimits*>(reqs) = getRequiredLimits();
deviceDesc.requiredLimits = nullptr;

Note that after calling getRequiredLimits(), reqs is never referenced anywhere else.

That is just not how this API works apparently. This causes the program to hang on wgpuAdapterRequestDevice, according to my breakpoints in CLion (on Mac, using LLDB).

I am unbelievably lost. I don't know why this is happening.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions