Pointer being freed was not allocated?

Hi!
Why is my game crashing and comes up with this argument?


After some time i figured out where it was coming from and now i know for sure that it is coming from this code here:

 case 2:
                
                while (true) {
                    
                    int l= RandomHelper::random_int(2, 32);
                    
                    //Check whether the current poss has been used in the current quiz or not
                    bool hasBeenUsed = false;
                    
                    if (usedStrings.size() >= 1) {
                        
                        for (int i = 0; i < usedStrings.size(); i++) {
                            
                            if (usedStrings.at(i) == std::get<2>(getItemSet(l))) {
                                
                                hasBeenUsed = true;
                                
                            }
                        }
                    }
                    if (hasBeenUsed == false) {
                        std::string naming = (std::string)std::get<3>(getChampSet(l));
                       usedStrings.push_back(naming); return naming;
                }
                }

Btw the initialization of usedStrings =

static std::vector<std::string> usedStrings;

?

Thanks!!!<33

I’m not sure but try doing a usedStrings.clear() before pushing anything into the vector.

But i have to store all the strings that i have used before in the vector…And clear kinda removes everything so the code can’t check whether the string has been used before right?

Thanks anyway, i appreciate ur time!

In recent Xcodes there’s a tool called Address Sanitizer, here’s some info and how to enable it: http://useyourloaf.com/blog/using-the-address-sanitizer.html

I’m pretty sure you will easily find a problem in your code with it and highly recommend turning it on permanently in debug builds

What I meant is as soon as you declare the variable for the vector,clear it on the next line.
Like this:
static std::vectorstd::string usedStrings;
usedStrings.clear();

Uh! Something happened! #oneMoreThingLearned :wink:
BUT it got kinda scary when all this text occurred, how to know what it is referring to, THANKS!<3:
=================================================================
==2794==ERROR: AddressSanitizer: attempting double-free on 0x19c6cd70 in thread T0:
#0 0x2b0e4ad in wrap__ZdlPv (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/7.0.0/lib/darwin/libclang_rt.asan_iossim_dynamic.dylib+0x4c4ad)
#1 0x76b109e in std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >::~basic_string() (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/libc++.1.dylib+0x4209e)
#2 0x14ed06 in std::__1::__tuple_leaf<0ul, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, false>::~__tuple_leaf() tuple:180
#3 0x14ed9c in std::__1::__tuple_impl<std::__1::__tuple_indices<0ul, 1ul, 2ul, 3ul>, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >::~__tuple_impl() tuple:397
#4 0x14ed46 in std::__1::__tuple_impl<std::__1::__tuple_indices<0ul, 1ul, 2ul, 3ul>, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >::~__tuple_impl() tuple:397
#5 0x14ed26 in std::__1::tuple<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >::~tuple() tuple:500
#6 0x14e4c6 in std::__1::tuple<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >::~tuple() tuple:500
#7 0xf0c39 in QuizGraphic::getRandObj(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >) QuizGraphic.cpp:138
#8 0x1bd9d5 in Quizer::getQuiz(HUD
) Quizer.cpp:274
#9 0x1ca912 in Quizer::getHint(cocos2d::Ref
) Quizer.cpp:626
#10 0x1d62e8 in void std::__1::__invoke_void_return_wrapper::__call<std::__1::__bind<void (Quizer::)(cocos2d::Ref), Quizer*, std::__1::placeholders::__ph<1>&>&, cocos2d::Ref*>(std::__1::__bind<void (Quizer::)(cocos2d::Ref), Quizer*, std::__1::placeholders::__ph<1>&>&&&, cocos2d::Ref*&&) __functional_base:382
#11 0x1d5b1a in std::__1::__function::__func<std::__1::__bind<void (Quizer::)(cocos2d::Ref), Quizer*, std::__1::placeholders::__ph<1>&>, std::__1::allocator<std::__1::__bind<void (Quizer::)(cocos2d::Ref), Quizer*, std::__1::placeholders::__ph<1>&> >, void (cocos2d::Ref*)>::operator()(cocos2d::Ref*&&) functional:1407
#12 0x1433af0 in std::__1::function<void (cocos2d::Ref*)>::operator()(cocos2d::Ref*) const functional:1793
#13 0x141e13e in cocos2d::MenuItem::activate() CCMenuItem.cpp:114
#14 0x13fd930 in cocos2d::Menu::onTouchEnded(cocos2d::Touch*, cocos2d::Event*) CCMenu.cpp:271
#15 0x1410ef4 in void std::__1::__invoke_void_return_wrapper::__call<std::__1::__bind<void (cocos2d::Menu::)(cocos2d::Touch, cocos2d::Event*), cocos2d::Menu*, std::__1::placeholders::__ph<1>&, std::__1::placeholders::__ph<2>&>&, cocos2d::Touch*, cocos2d::Event*>(std::__1::__bind<void (cocos2d::Menu::)(cocos2d::Touch, cocos2d::Event*), cocos2d::Menu*, std::__1::placeholders::__ph<1>&, std::__1::placeholders::__ph<2>&>&&&, cocos2d::Touch*&&, cocos2d::Event*&&) __functional_base:382
#16 0x141048d in std::__1::__function::__func<std::__1::__bind<void (cocos2d::Menu::)(cocos2d::Touch, cocos2d::Event*), cocos2d::Menu*, std::__1::placeholders::__ph<1>&, std::__1::placeholders::__ph<2>&>, std::__1::allocator<std::__1::__bind<void (cocos2d::Menu::)(cocos2d::Touch, cocos2d::Event*), cocos2d::Menu*, std::__1::placeholders::__ph<1>&, std::__1::placeholders::__ph<2>&> >, void (cocos2d::Touch*, cocos2d::Event*)>::operator()(cocos2d::Touch*&&, cocos2d::Event*&&) functional:1407
#17 0x19759cf in std::__1::function<void (cocos2d::Touch*, cocos2d::Event*)>::operator()(cocos2d::Touch*, cocos2d::Event*) const functional:1793
#18 0x19207d0 in cocos2d::EventDispatcher::dispatchTouchEvent(cocos2d::EventTouch*)::$_3::operator()(cocos2d::EventListener*) const CCEventDispatcher.cpp:902
#19 0x191e1f4 in bool std::__1::__invoke_void_return_wrapper::__call<cocos2d::EventDispatcher::dispatchTouchEvent(cocos2d::EventTouch*)::$_3&, cocos2d::EventListener*>(cocos2d::EventDispatcher::dispatchTouchEvent(cocos2d::EventTouch*)::$_3&&&, cocos2d::EventListener*&&) __functional_base:415
#20 0x191dffa in std::__1::__function::__func<cocos2d::EventDispatcher::dispatchTouchEvent(cocos2d::EventTouch*)::$_3, std::__1::allocatorcocos2d::EventDispatcher::dispatchTouchEvent(cocos2d::EventTouch*)::$_3, bool (cocos2d::EventListener*)>::operator()(cocos2d::EventListener*&&) functional:1407
#21 0x193ac90 in std::__1::function<bool (cocos2d::EventListener*)>::operator()(cocos2d::EventListener*) const functional:1793
#22 0x18fbf1f in cocos2d::EventDispatcher::dispatchEventToListeners(cocos2d::EventDispatcher::EventListenerVector*, std::__1::function<bool (cocos2d::EventListener*)> const&) CCEventDispatcher.cpp:757
#23 0x1901646 in cocos2d::EventDispatcher::dispatchTouchEvent(cocos2d::EventTouch*) CCEventDispatcher.cpp:948
#24 0x18fc6c6 in cocos2d::EventDispatcher::dispatchEvent(cocos2d::Event*) CCEventDispatcher.cpp:798
#25 0x1c9337b in cocos2d::GLView::handleTouchesOfEndOrCancel(cocos2d::EventTouch::EventCode, int, long*, float*, float*) CCGLView.cpp:419
#26 0x1c93cbd in cocos2d::GLView::handleTouchesEnd(int, long*, float*, float*) CCGLView.cpp:430
#27 0x1a9ab76 in -[CCEAGLView touchesEnded:withEvent:] CCEAGLView-ios.mm:450
#28 0x529220f in -[UIWindow _sendTouchesForEvent:] (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/UIKit.framework/UIKit+0xa720f)
#29 0x52932ad in -[UIWindow sendEvent:] (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/UIKit.framework/UIKit+0xa82ad)
#30 0x5238efa in -[UIApplication sendEvent:] (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/UIKit.framework/UIKit+0x4defa)
#31 0x520ecb5 in _UIApplicationHandleEventQueue (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/UIKit.framework/UIKit+0x23cb5)
#32 0x7795d1e in CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation+0x7ad1e)
#33 0x778b9aa in __CFRunLoopDoSources0 (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation+0x709aa)
#34 0x778adc7 in __CFRunLoopRun (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation+0x6fdc7)
#35 0x778a705 in CFRunLoopRunSpecific (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation+0x6f705)
#36 0x778a51a in CFRunLoopRunInMode (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation+0x6f51a)
#37 0x8655663 in GSEventRunModal (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices+0xe663)
#38 0x86554a0 in GSEventRun (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices+0xe4a0)
#39 0x52151ea in UIApplicationMain (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/UIKit.framework/UIKit+0x2a1ea)
#40 0x1f2f0f in main main.m:6
#41 0x7ebea20 in start (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/system/libdyld.dylib+0x2a20)
#42 0x0 ()

0x19c6cd70 is located 0 bytes inside of 16-byte region [0x19c6cd70,0x19c6cd80)
freed by thread T0 here:
#0 0x2b0e4ad in wrap__ZdlPv (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/7.0.0/lib/darwin/libclang_rt.asan_iossim_dynamic.dylib+0x4c4ad)
#1 0x76b109e in std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >::~basic_string() (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/libc++.1.dylib+0x4209e)
#2 0x14ed06 in std::__1::__tuple_leaf<0ul, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, false>::~__tuple_leaf() tuple:180
#3 0x14ed9c in std::__1::__tuple_impl<std::__1::__tuple_indices<0ul, 1ul, 2ul, 3ul>, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >::~__tuple_impl() tuple:397
#4 0x14ed46 in std::__1::__tuple_impl<std::__1::__tuple_indices<0ul, 1ul, 2ul, 3ul>, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >::~__tuple_impl() tuple:397
#5 0x14ed26 in std::__1::tuple<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >::~tuple() tuple:500
#6 0x14e4c6 in std::__1::tuple<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >::~tuple() tuple:500
#7 0xf0c39 in QuizGraphic::getRandObj(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >) QuizGraphic.cpp:138
#8 0x1bd9d5 in Quizer::getQuiz(HUD*) Quizer.cpp:274
#9 0x1ca912 in Quizer::getHint(cocos2d::Ref*) Quizer.cpp:626
#10 0x1d62e8 in void std::__1::__invoke_void_return_wrapper::__call<std::__1::__bind<void (Quizer::)(cocos2d::Ref), Quizer*, std::__1::placeholders::__ph<1>&>&, cocos2d::Ref*>(std::__1::__bind<void (Quizer::)(cocos2d::Ref), Quizer*, std::__1::placeholders::__ph<1>&>&&&, cocos2d::Ref*&&) __functional_base:382
#11 0x1d5b1a in std::__1::__function::__func<std::__1::__bind<void (Quizer::)(cocos2d::Ref), Quizer*, std::__1::placeholders::__ph<1>&>, std::__1::allocator<std::__1::__bind<void (Quizer::)(cocos2d::Ref), Quizer*, std::__1::placeholders::__ph<1>&> >, void (cocos2d::Ref*)>::operator()(cocos2d::Ref*&&) functional:1407
#12 0x1433af0 in std::__1::function<void (cocos2d::Ref*)>::operator()(cocos2d::Ref*) const functional:1793
#13 0x141e13e in cocos2d::MenuItem::activate() CCMenuItem.cpp:114
#14 0x13fd930 in cocos2d::Menu::onTouchEnded(cocos2d::Touch*, cocos2d::Event*) CCMenu.cpp:271
#15 0x1410ef4 in void std::__1::__invoke_void_return_wrapper::__call<std::__1::__bind<void (cocos2d::Menu::)(cocos2d::Touch, cocos2d::Event*), cocos2d::Menu*, std::__1::placeholders::__ph<1>&, std::__1::placeholders::__ph<2>&>&, cocos2d::Touch*, cocos2d::Event*>(std::__1::__bind<void (cocos2d::Menu::)(cocos2d::Touch, cocos2d::Event*), cocos2d::Menu*, std::__1::placeholders::__ph<1>&, std::__1::placeholders::__ph<2>&>&&&, cocos2d::Touch*&&, cocos2d::Event*&&) __functional_base:382
#16 0x141048d in std::__1::__function::__func<std::__1::__bind<void (cocos2d::Menu::)(cocos2d::Touch, cocos2d::Event*), cocos2d::Menu*, std::__1::placeholders::__ph<1>&, std::__1::placeholders::__ph<2>&>, std::__1::allocator<std::__1::__bind<void (cocos2d::Menu::)(cocos2d::Touch, cocos2d::Event*), cocos2d::Menu*, std::__1::placeholders::__ph<1>&, std::__1::placeholders::__ph<2>&> >, void (cocos2d::Touch*, cocos2d::Event*)>::operator()(cocos2d::Touch*&&, cocos2d::Event*&&) functional:1407
#17 0x19759cf in std::__1::function<void (cocos2d::Touch*, cocos2d::Event*)>::operator()(cocos2d::Touch*, cocos2d::Event*) const functional:1793
#18 0x19207d0 in cocos2d::EventDispatcher::dispatchTouchEvent(cocos2d::EventTouch*)::$_3::operator()(cocos2d::EventListener*) const CCEventDispatcher.cpp:902
#19 0x191e1f4 in bool std::__1::__invoke_void_return_wrapper::__call<cocos2d::EventDispatcher::dispatchTouchEvent(cocos2d::EventTouch*)::$_3&, cocos2d::EventListener*>(cocos2d::EventDispatcher::dispatchTouchEvent(cocos2d::EventTouch*)::$_3&&&, cocos2d::EventListener*&&) __functional_base:415
#20 0x191dffa in std::__1::__function::__func<cocos2d::EventDispatcher::dispatchTouchEvent(cocos2d::EventTouch*)::$_3, std::__1::allocatorcocos2d::EventDispatcher::dispatchTouchEvent(cocos2d::EventTouch*)::$_3, bool (cocos2d::EventListener*)>::operator()(cocos2d::EventListener*&&) functional:1407
#21 0x193ac90 in std::__1::function<bool (cocos2d::EventListener*)>::operator()(cocos2d::EventListener*) const functional:1793
#22 0x18fbf1f in cocos2d::EventDispatcher::dispatchEventToListeners(cocos2d::EventDispatcher::EventListenerVector*, std::__1::function<bool (cocos2d::EventListener*)> const&) CCEventDispatcher.cpp:757
#23 0x1901646 in cocos2d::EventDispatcher::dispatchTouchEvent(cocos2d::EventTouch*) CCEventDispatcher.cpp:948
#24 0x18fc6c6 in cocos2d::EventDispatcher::dispatchEvent(cocos2d::Event*) CCEventDispatcher.cpp:798
#25 0x1c9337b in cocos2d::GLView::handleTouchesOfEndOrCancel(cocos2d::EventTouch::EventCode, int, long*, float*, float*) CCGLView.cpp:419
#26 0x1c93cbd in cocos2d::GLView::handleTouchesEnd(int, long*, float*, float*) CCGLView.cpp:430
#27 0x1a9ab76 in -[CCEAGLView touchesEnded:withEvent:] CCEAGLView-ios.mm:450
#28 0x529220f in -[UIWindow _sendTouchesForEvent:] (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/UIKit.framework/UIKit+0xa720f)
#29 0x52932ad in -[UIWindow sendEvent:] (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/UIKit.framework/UIKit+0xa82ad)

previously allocated by thread T0 here:
#0 0x2b0de6d in wrap__Znwm (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/7.0.0/lib/darwin/libclang_rt.asan_iossim_dynamic.dylib+0x4be6d)
#1 0x76b0be9 in std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >::__init(char const*, unsigned long) (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/libc++.1.dylib+0x41be9)
#2 0x1495f8 in QuizGraphic::getItemSet(int) string:2001
#3 0xf026e in QuizGraphic::getRandObj(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >) QuizGraphic.cpp:138
#4 0x1bd9d5 in Quizer::getQuiz(HUD*) Quizer.cpp:274
#5 0x1ca912 in Quizer::getHint(cocos2d::Ref*) Quizer.cpp:626
#6 0x1d62e8 in void std::__1::__invoke_void_return_wrapper::__call<std::__1::__bind<void (Quizer::)(cocos2d::Ref), Quizer*, std::__1::placeholders::__ph<1>&>&, cocos2d::Ref*>(std::__1::__bind<void (Quizer::)(cocos2d::Ref), Quizer*, std::__1::placeholders::__ph<1>&>&&&, cocos2d::Ref*&&) __functional_base:382
#7 0x1d5b1a in std::__1::__function::__func<std::__1::__bind<void (Quizer::)(cocos2d::Ref), Quizer*, std::__1::placeholders::__ph<1>&>, std::__1::allocator<std::__1::__bind<void (Quizer::)(cocos2d::Ref), Quizer*, std::__1::placeholders::__ph<1>&> >, void (cocos2d::Ref*)>::operator()(cocos2d::Ref*&&) functional:1407
#8 0x1433af0 in std::__1::function<void (cocos2d::Ref*)>::operator()(cocos2d::Ref*) const functional:1793
#9 0x141e13e in cocos2d::MenuItem::activate() CCMenuItem.cpp:114
#10 0x13fd930 in cocos2d::Menu::onTouchEnded(cocos2d::Touch*, cocos2d::Event*) CCMenu.cpp:271
#11 0x1410ef4 in void std::__1::__invoke_void_return_wrapper::__call<std::__1::__bind<void (cocos2d::Menu::)(cocos2d::Touch, cocos2d::Event*), cocos2d::Menu*, std::__1::placeholders::__ph<1>&, std::__1::placeholders::__ph<2>&>&, cocos2d::Touch*, cocos2d::Event*>(std::__1::__bind<void (cocos2d::Menu::)(cocos2d::Touch, cocos2d::Event*), cocos2d::Menu*, std::__1::placeholders::__ph<1>&, std::__1::placeholders::__ph<2>&>&&&, cocos2d::Touch*&&, cocos2d::Event*&&) __functional_base:382
#12 0x141048d in std::__1::__function::__func<std::__1::__bind<void (cocos2d::Menu::)(cocos2d::Touch, cocos2d::Event*), cocos2d::Menu*, std::__1::placeholders::__ph<1>&, std::__1::placeholders::__ph<2>&>, std::__1::allocator<std::__1::__bind<void (cocos2d::Menu::)(cocos2d::Touch, cocos2d::Event*), cocos2d::Menu*, std::__1::placeholders::__ph<1>&, std::__1::placeholders::__ph<2>&> >, void (cocos2d::Touch*, cocos2d::Event*)>::operator()(cocos2d::Touch*&&, cocos2d::Event*&&) functional:1407
#13 0x19759cf in std::__1::function<void (cocos2d::Touch*, cocos2d::Event*)>::operator()(cocos2d::Touch*, cocos2d::Event*) const functional:1793
#14 0x19207d0 in cocos2d::EventDispatcher::dispatchTouchEvent(cocos2d::EventTouch*)::$_3::operator()(cocos2d::EventListener*) const CCEventDispatcher.cpp:902
#15 0x191e1f4 in bool std::__1::__invoke_void_return_wrapper::__call<cocos2d::EventDispatcher::dispatchTouchEvent(cocos2d::EventTouch*)::$_3&, cocos2d::EventListener*>(cocos2d::EventDispatcher::dispatchTouchEvent(cocos2d::EventTouch*)::$_3&&&, cocos2d::EventListener*&&) __functional_base:415
#16 0x191dffa in std::__1::__function::__func<cocos2d::EventDispatcher::dispatchTouchEvent(cocos2d::EventTouch*)::$_3, std::__1::allocatorcocos2d::EventDispatcher::dispatchTouchEvent(cocos2d::EventTouch*)::$_3, bool (cocos2d::EventListener*)>::operator()(cocos2d::EventListener*&&) functional:1407
#17 0x193ac90 in std::__1::function<bool (cocos2d::EventListener*)>::operator()(cocos2d::EventListener*) const functional:1793
#18 0x18fbf1f in cocos2d::EventDispatcher::dispatchEventToListeners(cocos2d::EventDispatcher::EventListenerVector*, std::__1::function<bool (cocos2d::EventListener*)> const&) CCEventDispatcher.cpp:757
#19 0x1901646 in cocos2d::EventDispatcher::dispatchTouchEvent(cocos2d::EventTouch*) CCEventDispatcher.cpp:948
#20 0x18fc6c6 in cocos2d::EventDispatcher::dispatchEvent(cocos2d::Event*) CCEventDispatcher.cpp:798
#21 0x1c9337b in cocos2d::GLView::handleTouchesOfEndOrCancel(cocos2d::EventTouch::EventCode, int, long*, float*, float*) CCGLView.cpp:419
#22 0x1c93cbd in cocos2d::GLView::handleTouchesEnd(int, long*, float*, float*) CCGLView.cpp:430
#23 0x1a9ab76 in -[CCEAGLView touchesEnded:withEvent:] CCEAGLView-ios.mm:450
#24 0x529220f in -[UIWindow _sendTouchesForEvent:] (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/UIKit.framework/UIKit+0xa720f)
#25 0x52932ad in -[UIWindow sendEvent:] (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/UIKit.framework/UIKit+0xa82ad)
#26 0x5238efa in -[UIApplication sendEvent:] (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/UIKit.framework/UIKit+0x4defa)
#27 0x520ecb5 in _UIApplicationHandleEventQueue (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/UIKit.framework/UIKit+0x23cb5)
#28 0x7795d1e in CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation+0x7ad1e)
#29 0x778b9aa in __CFRunLoopDoSources0 (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation+0x709aa)
**

Already tried but thanks for the thought!

ASan gives you three stacktraces in this case:

  1. where you are attemting to double free
  2. where the memory was freed
  3. where the memory was allocated

you should go down each of the traces and check out corresponding lines in your program.

QuizGraphic::getRandObj(std::1::basic_string1::char_traits, std::__1::allocator >) QuizGraphic.cpp:138 - something is messed up in this line I guess.

WOW COOL! So it is this line but what is wrong with that???

     if (usedStrings.at(i) == std::get<2>(getItemSet(l)))

Help appreciated x10000!

Well, it’s hard to say what’s wrong with just one line of code, but here are a few moments:

  1. Using .at in a loop makes no sense, you control the index
  2. You probably want a struct or class instead of tuple
1 Like

Got it fixed! Thanks for all ! God bless