Fatal signal 11 When creating sprite from image downloaded from server and stored locally


#1

I am using the below code to download images from server and store the image in the local path,
and then i store that local path in a dictionary.

but when i try to create a sprite using the location stored in dictionary it gives “Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 21104 (GLThread 8101)” Error in android and crashes

it works fine in Ios Device

void KQDownloadManager::downloadImage(ValueMap& quizdictionary)
{

   _quizdictionary = quizdictionary;
    //url 
    std::string url = quizdictionary["url"].asString();
    
    std::string name = url.c_str();
    name.erase( remove( name.begin(), name.end(), '/' ), name.end() );
    name.erase( remove( name.begin(), name.end(), ':' ), name.end() );
    
    std::string path = FileUtils::getInstance()->getWritablePath() + name.c_str();

    network::Downloader *downloader = new (std::nothrow) network::Downloader();
    downloader->createDownloadFileTask(url.c_str(), path,name.c_str());
    
    downloader->onFileTaskSuccess = [this,path,quizdictionary](const DownloadTask& task)
    {
        
        auto itd = std::find(KQQuizManager::sharedManager()->_questionsArray.begin (), KQQuizManager::sharedManager()->_questionsArray.end (), quizdictionary);
        auto index = std::distance(KQQuizManager::sharedManager()->_questionsArray.begin (), itd);
    
        if (itd == KQQuizManager::sharedManager()->_questionsArray.end ())
        {
            // name not in vector
            CCLOG("enter here 0");
        }
        else
        {
            index = std::distance(KQQuizManager::sharedManager()->_questionsArray.begin (), itd);
            
            ValueMap& questionDictionary = KQQuizManager::sharedManager()->_questionsArray.at(index);
            this->updateTheQuestionDictValues(path.c_str(),questionDictionary);
        }
        return;
    };
    
    downloader->onTaskError = [this,quizdictionary](const DownloadTask& task,int errorCode,int errorCodeInternal,const std::string& errorStr)
    {
        //Retry to download the failed downloads!
        
            //Call to update the downloaded asset path...
        auto itd = std::find(KQQuizManager::sharedManager()->_questionsArray.begin (), KQQuizManager::sharedManager()->_questionsArray.end (), quizdictionary);
        auto index = std::distance(KQQuizManager::sharedManager()->_questionsArray.begin (), itd);
        
        if (itd == KQQuizManager::sharedManager()->_questionsArray.end ())
        {
            // name not in vector
            CCLOG("enter here 0");
        }
        else
        {
            index = std::distance(KQQuizManager::sharedManager()->_questionsArray.begin (), itd);
            
            ValueMap& questionDictionary = KQQuizManager::sharedManager()->_questionsArray.at(index);
            this->downloadImage(questionDictionary);
        }
            
    };

}

#pragma mark - On Http responce
void KQDownloadManager::updateTheQuestionDictValues(std::string pathOfTheAsset, ValueMap& questionDict)
{
ValueMap& tobeUpdated = questionDict;

//update the path of the downloaded data
auto itd = std::find(KQQuizManager::sharedManager()->_questionsArray.begin (), KQQuizManager::sharedManager()->_questionsArray.end (), tobeUpdated);
auto index = std::distance(KQQuizManager::sharedManager()->_questionsArray.begin (), itd);

if (itd == KQQuizManager::sharedManager()->_questionsArray.end ())
{
    // name not in vector
    CCLOG("enter here 0");
}
else
{
    
    
    index = std::distance(KQQuizManager::sharedManager()->_questionsArray.begin (), itd);
    ValueMap& questionDictionary = KQQuizManager::sharedManager()->_questionsArray.at(index);
    
    questionDictionary["questionLocalPath"] = pathOfTheAsset.c_str();
    std::string temp = questionDictionary["questionLocalPath"].asString();
    _questionCount++;
    CCLOG( " total questions %d",_questionCount);
    
}

}

Error

--------- beginning of crash

02-17 10:59:13.662 21087-21104/com.KidsQuizGame.Juego A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 21104 (GLThread 8101)

                                                          [ 02-17 10:59:13.672 31194:31194 E/         ]
                                                          [adb] handle_packet() t->online(1) p->msg.arg0(105) p->msg.arg1(0) OPEN
                                                          
                                                          
                                                          [ 02-17 10:59:13.672 31194:31194 E/         ]
                                                          [adb] handle the adb command, and the command = adb shell:cat /proc/net/xt_qtaguid/stats | grep 10273
                                                          
                                                          [ 02-17 10:59:13.705 31194:31194 E/         ]
                                                          [adb] cuurent command is A_CLSE