[Mesa-dev] [PATCHES] handle potential errors in context creation

nobled nobled at dreamwidth.org
Sun Aug 15 17:37:28 PDT 2010


Except for the first patch, this is mostly adding a bunch of different
null checks:

1. r300g: Fix macro
This fixes a potential bug if (has_hyperz) is false (it would act as
if has_hyperz is true).
2. r300g: Fix leaks in failed context creation
This patch is the biggest one: It refactors the create/destroy context
functions; before, if r300_create_context failed to allocate something
essential it was either ignored or it only partly cleaned up after
itself (ex: leaking all the allocations in r300_init_atoms(),
forgetting to decrement the number of existing contexts, leaking the
mutexes initialized by r300_hyperz_init_mm, etc), and there's a *lot*
to stuff to clean up, so this just re-uses the logic in
r300_destroy_context to avoid code duplication.
3. r300g: Let hyperz init fail
Adds a boolean return value to check if the calls to u_mmInit failed
(they can potentially return null)
4. gallium: Check if draw_create returns null
This changes all the drivers that depend on the draw module to abort
if draw_create returned null (which it might if using LLVM and on a
CPU without SSE2, or if it just couldn't allocate memory)
5. draw: Check if llvm returns null
Always check for null and don't rely on assert(), since that won't
help on non-debug builds. Might also help with
http://bugs.freedesktop.org/29578 .
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-r300g-Fix-macro.patch
Type: text/x-patch
Size: 1135 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20100815/fdc645fe/attachment-0005.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-r300g-Fix-leaks-in-failed-context-creation.patch
Type: text/x-patch
Size: 5941 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20100815/fdc645fe/attachment-0006.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-r300g-Let-hyperz-init-fail.patch
Type: text/x-patch
Size: 3044 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20100815/fdc645fe/attachment-0007.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-gallium-Check-if-draw_create-returns-null.patch
Type: text/x-patch
Size: 3887 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20100815/fdc645fe/attachment-0008.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0005-draw-Check-if-llvm-returns-null.patch
Type: text/x-patch
Size: 1576 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20100815/fdc645fe/attachment-0009.bin>


More information about the mesa-dev mailing list