Hi,

I am getting some weird valgrind backtraces caused by a double free in
readImageToTexture. Can you tell me if the following code is the
correct way to use readImageToTexture? There are no implemented
examples of how to do this in compiz++.

            hasInit = true;
            mMove = 0.0;
            CompString back_s (optionGetBackground ());
            CompString logo_s (optionGetLogo ());

            fprintf (stderr, "String is %s\n", back_s.c_str ());

            back_img =
                GLTexture::readImageToTexture (back_s,
                                               back);
            logo_img =
                GLTexture::readImageToTexture (logo_s,
                                               logo);

            if (!back_img.size ())
            {
                CompString defaultBack (SPLASH_BACKGROUND_DEFAULT);
                back_img =
                    GLTexture::readImageToTexture (defaultBack, back);

                if (back_img.size ())
                {
                    compLogMessage ("splash", CompLogLevelWarn,
                                    "Could not load splash background image "
                                    "\"%s\" using default!",
                                    back_s.c_str () );
                }
            }

            if (!logo_img.size ())
            {
                CompString defaultLogo (SPLASH_LOGO_DEFAULT);
                logo_img =
                    GLTexture::readImageToTexture (defaultLogo, logo);

                if (logo_img.size ())
                {
                    compLogMessage ("splash", CompLogLevelWarn,
                                    "Could not load splash logo image "
                                    "\"%s\" using default!",
                                    logo_s.c_str () );
                }
            }

            if (!back_img.size ())
                compLogMessage ("splash", CompLogLevelWarn,
                                "Could not load splash background image "
                                "\"%s\" !", back_s.c_str () );

            if (!logo_img.size ())
                compLogMessage ("splash", CompLogLevelWarn,
                                "Could not load splash logo image \"%s\" !",
                                logo_s.c_str () );
        }

The valgrind backtrace is as follows when toggling the splash:

==14837==
==14837== Conditional jump or move depends on uninitialised value(s)
==14837==    at 0x4023B3D: free (in
/usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==14837==    by 0x5A9BA3B: GLTexture::readImageToTexture(std::string&,
CompSize&) (texture.cpp:374)
==14837==    by 0x75C16C0: SplashScreen::preparePaint(int) (splash.cpp:77)
==14837==    by 0x5A2BE33: CompositeScreen::preparePaint(int) (screen.cpp:848)
==14837==    by 0x5A2CBB1: CompositeScreen::handlePaintTimeout()
(screen.cpp:764)
==14837==    by 0x5A31DCF: boost::_mfi::mf0<bool,
CompositeScreen>::operator()(CompositeScreen*) const
(mem_fn_template.hpp:49)
==14837==    by 0x5A31E43: bool
boost::_bi::list1<boost::_bi::value<CompositeScreen*>
>::operator()<bool, boost::_mfi::mf0<bool, CompositeScreen>,
boost::_bi::list0>(boost::_bi::type<bool>, boost::_mfi::mf0<bool,
CompositeScreen>&, boost::_bi::list0&, long) (bind.hpp:221)
==14837==    by 0x5A31E94: boost::_bi::bind_t<bool,
boost::_mfi::mf0<bool, CompositeScreen>,
boost::_bi::list1<boost::_bi::value<CompositeScreen*> >
>::operator()() (bind_template.hpp:20)
==14837==    by 0x5A31EBD:
boost::detail::function::function_obj_invoker0<boost::_bi::bind_t<bool,
boost::_mfi::mf0<bool, CompositeScreen>,
boost::_bi::list1<boost::_bi::value<CompositeScreen*> > >,
bool>::invoke(boost::detail::function::function_buffer&)
(function_template.hpp:137)
==14837==    by 0x80BA48D: boost::function0<bool, std::allocator<void>
>::operator()() const (function_template.hpp:825)
==14837==    by 0x80A4E15: PrivateScreen::handleTimers(timeval*)
(screen.cpp:434)
==14837==    by 0x80ACD58: CompScreen::eventLoop() (screen.cpp:144)
==14837==
==14837== Invalid free() / delete / delete[]
==14837==    at 0x4023B7A: free (in
/usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==14837==    by 0x5A9BA3B: GLTexture::readImageToTexture(std::string&,
CompSize&) (texture.cpp:374)
==14837==    by 0x75C16C0: SplashScreen::preparePaint(int) (splash.cpp:77)
==14837==    by 0x5A2BE33: CompositeScreen::preparePaint(int) (screen.cpp:848)
==14837==    by 0x5A2CBB1: CompositeScreen::handlePaintTimeout()
(screen.cpp:764)
==14837==    by 0x5A31DCF: boost::_mfi::mf0<bool,
CompositeScreen>::operator()(CompositeScreen*) const
(mem_fn_template.hpp:49)
==14837==    by 0x5A31E43: bool
boost::_bi::list1<boost::_bi::value<CompositeScreen*>
>::operator()<bool, boost::_mfi::mf0<bool, CompositeScreen>,
boost::_bi::list0>(boost::_bi::type<bool>, boost::_mfi::mf0<bool,
CompositeScreen>&, boost::_bi::list0&, long) (bind.hpp:221)
==14837==    by 0x5A31E94: boost::_bi::bind_t<bool,
boost::_mfi::mf0<bool, CompositeScreen>,
boost::_bi::list1<boost::_bi::value<CompositeScreen*> >
>::operator()() (bind_template.hpp:20)
==14837==    by 0x5A31EBD:
boost::detail::function::function_obj_invoker0<boost::_bi::bind_t<bool,
boost::_mfi::mf0<bool, CompositeScreen>,
boost::_bi::list1<boost::_bi::value<CompositeScreen*> > >,
bool>::invoke(boost::detail::function::function_buffer&)
(function_template.hpp:137)
==14837==    by 0x80BA48D: boost::function0<bool, std::allocator<void>
>::operator()() const (function_template.hpp:825)
==14837==    by 0x80A4E15: PrivateScreen::handleTimers(timeval*)
(screen.cpp:434)
==14837==    by 0x80ACD58: CompScreen::eventLoop() (screen.cpp:144)
==14837==  Address 0xbe9e263c is on thread 1's stack
==14837==
==14837== Conditional jump or move depends on uninitialised value(s)
==14837==    at 0x4023B3D: free (in
/usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==14837==    by 0x5A9BA3B: GLTexture::readImageToTexture(std::string&,
CompSize&) (texture.cpp:374)
==14837==    by 0x75C1732: SplashScreen::preparePaint(int) (splash.cpp:80)
==14837==    by 0x5A2BE33: CompositeScreen::preparePaint(int) (screen.cpp:848)
==14837==    by 0x5A2CBB1: CompositeScreen::handlePaintTimeout()
(screen.cpp:764)
==14837==    by 0x5A31DCF: boost::_mfi::mf0<bool,
CompositeScreen>::operator()(CompositeScreen*) const
(mem_fn_template.hpp:49)
==14837==    by 0x5A31E43: bool
boost::_bi::list1<boost::_bi::value<CompositeScreen*>
>::operator()<bool, boost::_mfi::mf0<bool, CompositeScreen>,
boost::_bi::list0>(boost::_bi::type<bool>, boost::_mfi::mf0<bool,
CompositeScreen>&, boost::_bi::list0&, long) (bind.hpp:221)
==14837==    by 0x5A31E94: boost::_bi::bind_t<bool,
boost::_mfi::mf0<bool, CompositeScreen>,
boost::_bi::list1<boost::_bi::value<CompositeScreen*> >
>::operator()() (bind_template.hpp:20)
==14837==    by 0x5A31EBD:
boost::detail::function::function_obj_invoker0<boost::_bi::bind_t<bool,
boost::_mfi::mf0<bool, CompositeScreen>,
boost::_bi::list1<boost::_bi::value<CompositeScreen*> > >,
bool>::invoke(boost::detail::function::function_buffer&)
(function_template.hpp:137)
==14837==    by 0x80BA48D: boost::function0<bool, std::allocator<void>
>::operator()() const (function_template.hpp:825)
==14837==    by 0x80A4E15: PrivateScreen::handleTimers(timeval*)
(screen.cpp:434)
==14837==    by 0x80ACD58: CompScreen::eventLoop() (screen.cpp:144)
==14837==
==14837== Mismatched free() / delete / delete []
==14837==    at 0x4023B7A: free (in
/usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==14837==    by 0x5A9BA3B: GLTexture::readImageToTexture(std::string&,
CompSize&) (texture.cpp:374)
==14837==    by 0x75C1732: SplashScreen::preparePaint(int) (splash.cpp:80)
==14837==    by 0x5A2BE33: CompositeScreen::preparePaint(int) (screen.cpp:848)
==14837==    by 0x5A2CBB1: CompositeScreen::handlePaintTimeout()
(screen.cpp:764)
==14837==    by 0x5A31DCF: boost::_mfi::mf0<bool,
CompositeScreen>::operator()(CompositeScreen*) const
(mem_fn_template.hpp:49)
==14837==    by 0x5A31E43: bool
boost::_bi::list1<boost::_bi::value<CompositeScreen*>
>::operator()<bool, boost::_mfi::mf0<bool, CompositeScreen>,
boost::_bi::list0>(boost::_bi::type<bool>, boost::_mfi::mf0<bool,
CompositeScreen>&, boost::_bi::list0&, long) (bind.hpp:221)
==14837==    by 0x5A31E94: boost::_bi::bind_t<bool,
boost::_mfi::mf0<bool, CompositeScreen>,
boost::_bi::list1<boost::_bi::value<CompositeScreen*> >
>::operator()() (bind_template.hpp:20)
==14837==    by 0x5A31EBD:
boost::detail::function::function_obj_invoker0<boost::_bi::bind_t<bool,
boost::_mfi::mf0<bool, CompositeScreen>,
boost::_bi::list1<boost::_bi::value<CompositeScreen*> > >,
bool>::invoke(boost::detail::function::function_buffer&)
(function_template.hpp:137)
==14837==    by 0x80BA48D: boost::function0<bool, std::allocator<void>
>::operator()() const (function_template.hpp:825)
==14837==    by 0x80A4E15: PrivateScreen::handleTimers(timeval*)
(screen.cpp:434)
==14837==    by 0x80ACD58: CompScreen::eventLoop() (screen.cpp:144)
==14837==  Address 0x8d00220 is 0 bytes inside a block of size 28 alloc'd
==14837==    at 0x402476E: operator new(unsigned) (in
/usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==14837==    by 0x5A9B642: PrivateTexture::loadImageData(char const*,
unsigned, unsigned, unsigned, unsigned) (texture.cpp:293)
==14837==    by 0x5A9B9AD: GLTexture::imageBufferToTexture(char
const*, CompSize) (texture.cpp:347)
==14837==    by 0x5A9BA2D: GLTexture::readImageToTexture(std::string&,
CompSize&) (texture.cpp:372)
==14837==    by 0x75C16C0: SplashScreen::preparePaint(int) (splash.cpp:77)
==14837==    by 0x5A2BE33: CompositeScreen::preparePaint(int) (screen.cpp:848)
==14837==    by 0x5A2CBB1: CompositeScreen::handlePaintTimeout()
(screen.cpp:764)
==14837==    by 0x5A31DCF: boost::_mfi::mf0<bool,
CompositeScreen>::operator()(CompositeScreen*) const
(mem_fn_template.hpp:49)
==14837==    by 0x5A31E43: bool
boost::_bi::list1<boost::_bi::value<CompositeScreen*>
>::operator()<bool, boost::_mfi::mf0<bool, CompositeScreen>,
boost::_bi::list0>(boost::_bi::type<bool>, boost::_mfi::mf0<bool,
CompositeScreen>&, boost::_bi::list0&, long) (bind.hpp:221)
==14837==    by 0x5A31E94: boost::_bi::bind_t<bool,
boost::_mfi::mf0<bool, CompositeScreen>,
boost::_bi::list1<boost::_bi::value<CompositeScreen*> >
>::operator()() (bind_template.hpp:20)
==14837==    by 0x5A31EBD:
boost::detail::function::function_obj_invoker0<boost::_bi::bind_t<bool,
boost::_mfi::mf0<bool, CompositeScreen>,
boost::_bi::list1<boost::_bi::value<CompositeScreen*> > >,
bool>::invoke(boost::detail::function::function_buffer&)
(function_template.hpp:137)
==14837==    by 0x80BA48D: boost::function0<bool, std::allocator<void>
>::operator()() const (function_template.hpp:825)
==14837==
==14837== Conditional jump or move depends on uninitialised value(s)
==14837==    at 0x5DD841A: (within /usr/lib/libGLcore.so.177.80)
==14837==
==14837== Conditional jump or move depends on uninitialised value(s)
==14837==    at 0x5DD8432: (within /usr/lib/libGLcore.so.177.80)
String is splash_background.png
==14837==
==14837== Invalid read of size 4
==14837==    at 0x5A994B3: GLTexture::decRef(GLTexture*) (texture.cpp:382)
==14837==    by 0x5A99606: GLTexture::List::clear() (texture.cpp:94)
==14837==    by 0x5A9AA23: GLTexture::List::operator=(GLTexture::List
const&) (texture.cpp:80)
==14837==    by 0x75C16D8: SplashScreen::preparePaint(int) (splash.cpp:77)
==14837==    by 0x5A2BE33: CompositeScreen::preparePaint(int) (screen.cpp:848)
==14837==    by 0x5A2CBB1: CompositeScreen::handlePaintTimeout()
(screen.cpp:764)
==14837==    by 0x5A31DCF: boost::_mfi::mf0<bool,
CompositeScreen>::operator()(CompositeScreen*) const
(mem_fn_template.hpp:49)
==14837==    by 0x5A31E43: bool
boost::_bi::list1<boost::_bi::value<CompositeScreen*>
>::operator()<bool, boost::_mfi::mf0<bool, CompositeScreen>,
boost::_bi::list0>(boost::_bi::type<bool>, boost::_mfi::mf0<bool,
CompositeScreen>&, boost::_bi::list0&, long) (bind.hpp:221)
==14837==    by 0x5A31E94: boost::_bi::bind_t<bool,
boost::_mfi::mf0<bool, CompositeScreen>,
boost::_bi::list1<boost::_bi::value<CompositeScreen*> >
>::operator()() (bind_template.hpp:20)
==14837==    by 0x5A31EBD:
boost::detail::function::function_obj_invoker0<boost::_bi::bind_t<bool,
boost::_mfi::mf0<bool, CompositeScreen>,
boost::_bi::list1<boost::_bi::value<CompositeScreen*> > >,
bool>::invoke(boost::detail::function::function_buffer&)
(function_template.hpp:137)
==14837==    by 0x80BA48D: boost::function0<bool, std::allocator<void>
>::operator()() const (function_template.hpp:825)
==14837==    by 0x80A4E15: PrivateScreen::handleTimers(timeval*)
(screen.cpp:434)
==14837==  Address 0x8d00238 is not stack'd, malloc'd or (recently) free'd
==14837==
==14837== Invalid read of size 4
==14837==    at 0x5A994B6: GLTexture::decRef(GLTexture*) (texture.cpp:382)
==14837==    by 0x5A99606: GLTexture::List::clear() (texture.cpp:94)
==14837==    by 0x5A9AA23: GLTexture::List::operator=(GLTexture::List
const&) (texture.cpp:80)
==14837==    by 0x75C16D8: SplashScreen::preparePaint(int) (splash.cpp:77)
==14837==    by 0x5A2BE33: CompositeScreen::preparePaint(int) (screen.cpp:848)
==14837==    by 0x5A2CBB1: CompositeScreen::handlePaintTimeout()
(screen.cpp:764)
==14837==    by 0x5A31DCF: boost::_mfi::mf0<bool,
CompositeScreen>::operator()(CompositeScreen*) const
(mem_fn_template.hpp:49)
==14837==    by 0x5A31E43: bool
boost::_bi::list1<boost::_bi::value<CompositeScreen*>
>::operator()<bool, boost::_mfi::mf0<bool, CompositeScreen>,
boost::_bi::list0>(boost::_bi::type<bool>, boost::_mfi::mf0<bool,
CompositeScreen>&, boost::_bi::list0&, long) (bind.hpp:221)
==14837==    by 0x5A31E94: boost::_bi::bind_t<bool,
boost::_mfi::mf0<bool, CompositeScreen>,
boost::_bi::list1<boost::_bi::value<CompositeScreen*> >
>::operator()() (bind_template.hpp:20)
==14837==    by 0x5A31EBD:
boost::detail::function::function_obj_invoker0<boost::_bi::bind_t<bool,
boost::_mfi::mf0<bool, CompositeScreen>,
boost::_bi::list1<boost::_bi::value<CompositeScreen*> > >,
bool>::invoke(boost::detail::function::function_buffer&)
(function_template.hpp:137)
==14837==    by 0x80BA48D: boost::function0<bool, std::allocator<void>
>::operator()() const (function_template.hpp:825)
==14837==    by 0x80A4E15: PrivateScreen::handleTimers(timeval*)
(screen.cpp:434)
==14837==  Address 0x30 is not stack'd, malloc'd or (recently) free'd
==14837==
==14837== Process terminating with default action of signal 11 (SIGSEGV)
==14837==  Access not within mapped region at address 0x30
==14837==    at 0x5A994B6: GLTexture::decRef(GLTexture*) (texture.cpp:382)
==14837==    by 0x5A99606: GLTexture::List::clear() (texture.cpp:94)
==14837==    by 0x5A9AA23: GLTexture::List::operator=(GLTexture::List
const&) (texture.cpp:80)
==14837==    by 0x75C16D8: SplashScreen::preparePaint(int) (splash.cpp:77)
==14837==    by 0x5A2BE33: CompositeScreen::preparePaint(int) (screen.cpp:848)
==14837==    by 0x5A2CBB1: CompositeScreen::handlePaintTimeout()
(screen.cpp:764)
==14837==    by 0x5A31DCF: boost::_mfi::mf0<bool,
CompositeScreen>::operator()(CompositeScreen*) const
(mem_fn_template.hpp:49)
==14837==    by 0x5A31E43: bool
boost::_bi::list1<boost::_bi::value<CompositeScreen*>
>::operator()<bool, boost::_mfi::mf0<bool, CompositeScreen>,
boost::_bi::list0>(boost::_bi::type<bool>, boost::_mfi::mf0<bool,
CompositeScreen>&, boost::_bi::list0&, long) (bind.hpp:221)
==14837==    by 0x5A31E94: boost::_bi::bind_t<bool,
boost::_mfi::mf0<bool, CompositeScreen>,
boost::_bi::list1<boost::_bi::value<CompositeScreen*> >
>::operator()() (bind_template.hpp:20)
==14837==    by 0x5A31EBD:
boost::detail::function::function_obj_invoker0<boost::_bi::bind_t<bool,
boost::_mfi::mf0<bool, CompositeScreen>,
boost::_bi::list1<boost::_bi::value<CompositeScreen*> > >,
bool>::invoke(boost::detail::function::function_buffer&)
(function_template.hpp:137)
==14837==    by 0x80BA48D: boost::function0<bool, std::allocator<void>
>::operator()() const (function_template.hpp:825)
==14837==    by 0x80A4E15: PrivateScreen::handleTimers(timeval*)
(screen.cpp:434)
==14837==
==14837== ERROR SUMMARY: 150 errors from 16 contexts (suppressed: 128 from 3)
==14837== malloc/free: in use at exit: 72,526,494 bytes in 91,042 blocks.
==14837== malloc/free: 2,062,274 allocs, 1,971,234 frees, 291,957,604
bytes allocated.
==14837== For counts of detected errors, rerun with: -v
==14837== searching for pointers to 91,042 not-freed blocks.
==14837== checked 8,278,832 bytes.
==14837==
==14837== LEAK SUMMARY:
==14837==    definitely lost: 3,332 bytes in 67 blocks.
==14837==      possibly lost: 7,476 bytes in 270 blocks.
==14837==    still reachable: 72,515,686 bytes in 90,705 blocks.
==14837==         suppressed: 0 bytes in 0 blocks.
==14837== Rerun with --leak-check=full to see details of leaked memory.





-- 
Sam Spilsbury
_______________________________________________
Dev mailing list
[email protected]
http://lists.compiz-fusion.org/mailman/listinfo/dev

Reply via email to