EMsoft-org / EMSphInx

C++ Spherical Indexing repository
GNU General Public License v2.0
8 stars 20 forks source link

Error when indexing .ebsp file: Can't dereference out of range vector iterator #13

Open jwestraadt opened 2 years ago

jwestraadt commented 2 years ago

Hello!

The following error occurs at the end of the analysis when running EMSphInx on a .ebsp file. It occurs for both the precompiled binary files and a debug version compiled from source. When I set the batchsize equal to an even factor of the total number of patterns then it completes the analysis without this error.

image

The Ni example data completes the analysis with any batchsize parameter without issue.

jwestraadt commented 2 years ago

Some initial debugging in index_ebsd.cpp shows that the error occurs during scheduling of the last partial batch in the following loop.

    size_t batches = idxData.pat->numPat() / nml.batchSize;//how many batches are needed
    if(batches * nml.batchSize < idxData.pat->numPat()) ++batches;//extra batch for leftovers
    for(size_t i = 0; i < batches; i++) {//loop over batches
        const size_t start = i * nml.batchSize;//first pattern
        const size_t end = std::min(start + nml.batchSize, idxData.pat->numPat());//last pattern
        pool.schedule(std::bind(idxData.workItem, std::placeholders::_1));//queue indexing
    }