[Mesa-dev] [PATCH v2 6/6] swr: avoid using exceptions for expected condition handling
Cherniak, Bruce
bruce.cherniak at intel.com
Tue Nov 22 16:43:55 UTC 2016
Reviewed-by: Bruce Cherniak <bruce.cherniak at intel.com>
> On Nov 17, 2016, at 10:56 PM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
>
> I was getting a weird segfault from GCC 4.9.3:
>
> 0x00007ffff54f27aa in strlen () from /lib64/libc.so.6
> (gdb) bt
> #0 0x00007ffff54f27aa in strlen () from /lib64/libc.so.6
> #1 0x00007ffff4f128e5 in get_cie_encoding (cie=cie at entry=0x7ffff6e09813)
> at /gcc-4.9.3/libgcc/unwind-dw2-fde.c:272
> #2 0x00007ffff4f1318e in classify_object_over_fdes (ob=ob at entry=0xd7bb90, this_fde=0x7ffff7f11010)
> at /gcc-4.9.3/libgcc/unwind-dw2-fde.c:628
> #3 0x00007ffff4f135ba in init_object (ob=0xd7bb90)
> at /gcc-4.9.3/libgcc/unwind-dw2-fde.c:749
> #4 search_object (ob=ob at entry=0xd7bb90, pc=pc at entry=0x7ffff4f11f4d <_Unwind_RaiseException+61>)
> at /gcc-4.9.3/libgcc/unwind-dw2-fde.c:961
> #5 0x00007ffff4f13e62 in _Unwind_Find_registered_FDE (bases=0x7fffffffd358, pc=0x7ffff4f11f4d <_Unwind_RaiseException+61>)
> at /gcc-4.9.3/libgcc/unwind-dw2-fde.c:1025
> #6 _Unwind_Find_FDE (pc=0x7ffff4f11f4d <_Unwind_RaiseException+61>, bases=bases at entry=0x7fffffffd358)
> at /gcc-4.9.3/libgcc/unwind-dw2-fde-dip.c:450
> #7 0x00007ffff4f11197 in uw_frame_state_for (context=context at entry=0x7fffffffd2b0, fs=fs at entry=0x7fffffffd100)
> at /gcc-4.9.3/libgcc/unwind-dw2.c:1245
> #8 0x00007ffff4f11b15 in uw_init_context_1 (context=context at entry=0x7fffffffd2b0, outer_cfa=outer_cfa at entry=0x7fffffffd660, outer_ra=0x7ffff518d23b <__cxa_throw+91>)
> at /gcc-4.9.3/libgcc/unwind-dw2.c:1566
> #9 0x00007ffff4f11f4e in _Unwind_RaiseException (exc=0xd7c250)
> at /gcc-4.9.3/libgcc/unwind.inc:88
> #10 0x00007ffff518d23b in __cxa_throw () from /usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/libstdc++.so.6
> #11 0x00007ffff51ed556 in std::__throw_out_of_range(char const*) ()
> from /usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/libstdc++.so.6
> #12 0x00007fffea778be0 in std::map<pipe_format, SWR_FORMAT, std::less<pipe_format>, std::allocator<std::pair<pipe_format const, SWR_FORMAT> > >::at (
> this=0x7fffebeb4c40 <mesa_to_swr_format(pipe_format)::mesa2swr>,
> __k=@0x7fffffffd73c: PIPE_FORMAT_RGTC1_UNORM)
> at /usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/stl_map.h:549
> #13 0x00007fffea776aee in mesa_to_swr_format (format=PIPE_FORMAT_RGTC1_UNORM) at swr_screen.cpp:597
>
> We can just void this whole issue by not using exceptions in the
> first place.
>
> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
> ---
> src/gallium/drivers/swr/swr_screen.cpp | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/src/gallium/drivers/swr/swr_screen.cpp b/src/gallium/drivers/swr/swr_screen.cpp
> index aede662..36afcc3 100644
> --- a/src/gallium/drivers/swr/swr_screen.cpp
> +++ b/src/gallium/drivers/swr/swr_screen.cpp
> @@ -594,12 +594,11 @@ mesa_to_swr_format(enum pipe_format format)
> */
> };
>
> - try {
> - return mesa2swr.at(format);
> - }
> - catch (std::out_of_range) {
> + auto it = mesa2swr.find(format);
> + if (it == mesa2swr.end())
> return (SWR_FORMAT)-1;
> - }
> + else
> + return it->second;
> }
>
> static boolean
> --
> 2.7.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list