[beignet] 03/07: Return failure instead of aborting on cl_mem_allocate failure
Rebecca Palmer
rnpalmer-guest at moszumanska.debian.org
Fri Feb 6 20:13:58 UTC 2015
This is an automated email from the git hooks/post-receive script.
rnpalmer-guest pushed a commit to branch master
in repository beignet.
commit 3d4f998238c20ce93c21389aa7c572c358c1395c
Author: Rebecca N. Palmer <rebecca_palmer at zoho.com>
Date: Fri Feb 6 13:26:58 2015 +0000
Return failure instead of aborting on cl_mem_allocate failure
---
debian/changelog | 1 +
.../patches/fail-gracefully-cl_mem_allocate.patch | 39 ++++++++++++++++++++++
debian/patches/series | 1 +
3 files changed, 41 insertions(+)
diff --git a/debian/changelog b/debian/changelog
index bec8d4e..3f695a3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -12,6 +12,7 @@ beignet (1.0.1-1) UNRELEASED; urgency=medium
* Rename to beignet-opencl-icd for consistency.
* Add more debug output to builtin_pow test.
* Fix bug in compiler_fill_image_1d_array test setup.
+ * Return failure instead of aborting on cl_mem_allocate failure.
-- Andreas Beckmann <anbe at debian.org> Fri, 23 Jan 2015 23:17:24 +0100
diff --git a/debian/patches/fail-gracefully-cl_mem_allocate.patch b/debian/patches/fail-gracefully-cl_mem_allocate.patch
new file mode 100644
index 0000000..d60490f
--- /dev/null
+++ b/debian/patches/fail-gracefully-cl_mem_allocate.patch
@@ -0,0 +1,39 @@
+Description: Fail, don't abort, on allocation failure
+
+Don't assume the buffer passed to cl_mem_delete is fully set up,
+as it won't be when called from cl_mem_allocate's error handling.
+
+Author: Rebecca Palmer <rebecca_palmer at zoho.com>
+
+--- a/src/cl_mem.c
++++ b/src/cl_mem.c
+@@ -1071,16 +1071,19 @@ cl_mem_delete(cl_mem mem)
+ }
+
+ /* Remove it from the list */
+- assert(mem->ctx);
+- pthread_mutex_lock(&mem->ctx->buffer_lock);
+- if (mem->prev)
+- mem->prev->next = mem->next;
+- if (mem->next)
+- mem->next->prev = mem->prev;
+- if (mem->ctx->buffers == mem)
+- mem->ctx->buffers = mem->next;
+- pthread_mutex_unlock(&mem->ctx->buffer_lock);
+- cl_context_delete(mem->ctx);
++ if (mem->ctx) {
++ pthread_mutex_lock(&mem->ctx->buffer_lock);
++ if (mem->prev)
++ mem->prev->next = mem->next;
++ if (mem->next)
++ mem->next->prev = mem->prev;
++ if (mem->ctx->buffers == mem)
++ mem->ctx->buffers = mem->next;
++ pthread_mutex_unlock(&mem->ctx->buffer_lock);
++ cl_context_delete(mem->ctx);
++ } else {
++ assert((mem->prev == 0) && (mem->next == 0));
++ }
+
+ /* Someone still mapped, unmap */
+ if(mem->map_ref > 0) {
diff --git a/debian/patches/series b/debian/patches/series
index 90062fe..3e46a9d 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -4,3 +4,4 @@ Utest-requires-deprecated-function-names.patch
Link-against-terminfo.patch
Enable-test-debug.patch
fix-compiler_fill_image_1d_array.patch
+fail-gracefully-cl_mem_allocate.patch
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-opencl/beignet.git
More information about the Pkg-opencl-commits
mailing list