Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[BUG] OpenCL bug delete cl_mem crashes in DEBUG builds only #3691

@kar-dim

Description

@kar-dim

NOTE: This issue is the same as the closed one from here: #3607
I opened it because unfortunately the solution was irrelevant. I provide extra info here which may help. Thank you!



I get crashes when deleting the cl_mem returned by the device<cl_mem>(). Either manually deleting it or when it is deleted by a smart pointer. This happens only with DEBUG build.

Description

I am using ArrayFire 3.9.0 (latest as of now), Windows 11 and OpenCL backend.

NOTE: The culprit is this: if we change the MSVC compiler switch for Runtime Library from /MD to /MDd (or even /MTd). That's when the CRT checks the heap for corruptions and crashes....I suspect it may also be a CRT bug but I am not sure..

Reproducible Code and/or Steps

To reproduce it is very simple on my machine! I run the DEBUG build (I am using visual studio with ), and it crashes with this code below:

int main(void)
{
	af::array t = af::randu(2160, 3840);
	af::sync();
	std::unique_ptr<cl_mem> ptr(t.device<cl_mem>());
	...(ptr goes out of scope) -> CRASH
}

of course it crashes with any other variations, like:

int main(void)
{
	af::array t = af::randu(2160, 3840);
	af::sync();
	cl_mem* ptr = t.device<cl_mem>();
	...(code here)...
	delete ptr -> CRASH
}

I have tried to put af::sync() after the device<cl_mem>() call but the result is the same.

System Information

  1. ArrayFire version
    ArrayFire 3.9.0

  2. Devices installed on the system
    AMD gfx1036
    NVIDIA RTX 4070 Super 12GB [1]

  • [ X ] Using the latest available ArrayFire release
  • [ X ] GPU drivers are up to date

Watermark_GPU_v4hTf4e6yI
devenv_EOTa3AQpGv

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions