Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gdrdrv returns the same handle for two pinned buffers #244

Closed
pakmarkthub opened this issue Jan 19, 2023 · 0 comments · Fixed by #248
Closed

gdrdrv returns the same handle for two pinned buffers #244

pakmarkthub opened this issue Jan 19, 2023 · 0 comments · Fixed by #248
Milestone

Comments

@pakmarkthub
Copy link
Collaborator

pakmarkthub commented Jan 19, 2023

Under the following conditions, gdrdrv returns the same handle for two different pinned buffers:

  1. The size of the first buffer is smaller than the GPU page.
  2. The start of the second buffer is within the same page of the first buffer.

The handle for the second buffer supersedes that of the first buffer. One scenario that this behavior becomes problematic is:

  • The first buffer is page-aligned.
  • The second buffer is not page-aligned.

This will run correctly.

gdr_pin_buffer(g, first_buffer_ptr, first_buffer_size, 0, 0, &first_buffer_handle);
gdr_map(g, first_buffer_handle, &first_buffer_map_ptr, first_buffer_size);
gdr_pin_buffer(g, second_buffer_ptr, second_buffer_size, 0, 0, &second_buffer_handle);

This will fail because the offset of the second buffer is non-zero. But the failure happens when trying to map the first buffer!

gdr_pin_buffer(g, first_buffer_ptr, first_buffer_size, 0, 0, &first_buffer_handle);
gdr_pin_buffer(g, second_buffer_ptr, second_buffer_size, 0, 0, &second_buffer_handle);
gdr_map(g, first_buffer_handle, &first_buffer_map_ptr, first_buffer_size);

Code in #242 can be used to reproduce this bug.

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 a pull request may close this issue.

2 participants