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

Marek Olšák maraeo at gmail.com
Sun Aug 15 20:27:07 PDT 2010

On Mon, Aug 16, 2010 at 2:37 AM, nobled <nobled at dreamwidth.org> wrote:

> 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)

Pushed, thanks!

> 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)

The r300g part is ok. Concerning the rest, I'd like to get a consent from
the other driver maintainers.

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 .

I think we should fall back to the non-LLVM path i.e. the slow, interpreted
one. Luca has also sent an alternate fix:


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20100816/956af8ad/attachment.html>

More information about the mesa-dev mailing list