Segmentation fault
GerbertKaandorp opened this issue · 2 comments
Hi
First, thanks a lot for this conversion! :)
I got a Segmentation fault.
Traced it down to the condition on line 392
I think I fixed it by checking if second.itemType is still INTEGER
if (value2 != dictionaryEnd)
{
suggestItem si;
si.term = move(suggestion);
si.distance = distance;
if (value2->second.itemType == dictionaryItemContainer::INTEGER)
{
si.count = 0;
}
else
{
si.count = value2->second.dictValue->count;
}
suggestions.push_back(si);
}
Can you verify if this is correct?
Thanks!
Gerbert
btw, here is my sample test data:
bbantammerstr
bbantammerstraat
bbantstr
bbantstraat
bbstr
bbstraat
binnenkant
buitenbantammerstr
buitenbantammerstraat
buitenbantstr
buitenbantstraat
buitenbstr
buitenbstraat
deruijterkade
deruijterkd
deruyterkd
druijterkade
druijterkd
druyterkd
houtkopersdwarsstr
houtkopersdwarsstraat
houtkopersdwstr
kalkmarkt
krommewaal
krwaal
oosterdokskade
oosterdokskd
oudewaal
ouwaal
prhendrikkade
prhendrikkd
prinshendrikkade
prinshendrikkd
schippersstr
schippersstraat
and an example that produced the crash:
owaal
Hi,
it's me again.... :)
I found another bug when you set verbose = 2
On line 343 you move candidate
si.term = move(candidate);
but later on line 413 it's still referenced:
string wordClone = candidate;
I fixed it by not moving the candidate.
Maybe you have a more elegant way.
My c++ coding knowledge is a bit rusty :)
Cheers!
Gerbert
ps:
error was found on same test set.
verbose = 2
search for 'prinshendrikkade'
Thank you for your feedback Gerbert.
I fixed all your reported bugs. Also your are very good to finding bug and helping to resolve it :)
This is my test code
SymSpell a;
a.CreateDictionaryEntry("bbantammerstr");
a.CreateDictionaryEntry("bbantammerstraat");
a.CreateDictionaryEntry("bbantstr");
a.CreateDictionaryEntry("bbantstraat");
a.CreateDictionaryEntry("bbstr");
a.CreateDictionaryEntry("bbstraat");
a.CreateDictionaryEntry("binnenkant");
a.CreateDictionaryEntry("buitenbantammerstr");
a.CreateDictionaryEntry("buitenbantammerstraat");
a.CreateDictionaryEntry("buitenbantstr");
a.CreateDictionaryEntry("buitenbantstraat");
a.CreateDictionaryEntry("buitenbstr");
a.CreateDictionaryEntry("buitenbstraat");
a.CreateDictionaryEntry("deruijterkade");
a.CreateDictionaryEntry("deruijterkd");
a.CreateDictionaryEntry("deruyterkd");
a.CreateDictionaryEntry("druijterkade");
a.CreateDictionaryEntry("druijterkd");
a.CreateDictionaryEntry("druyterkd");
a.CreateDictionaryEntry("houtkopersdwarsstr");
a.CreateDictionaryEntry("houtkopersdwarsstraat");
a.CreateDictionaryEntry("houtkopersdwstr");
a.CreateDictionaryEntry("kalkmarkt");
a.CreateDictionaryEntry("krommewaal");
a.CreateDictionaryEntry("krwaal");
a.CreateDictionaryEntry("oosterdokskade");
a.CreateDictionaryEntry("oosterdokskd");
a.CreateDictionaryEntry("oudewaal");
a.CreateDictionaryEntry("ouwaal");
a.CreateDictionaryEntry("prhendrikkade");
a.CreateDictionaryEntry("prhendrikkd");
a.CreateDictionaryEntry("prinshendrikkade");
a.CreateDictionaryEntry("prinshendrikkd");
a.CreateDictionaryEntry("schippersstr");
a.CreateDictionaryEntry("schippersstraat");
a.verbose = 2;
vector items = a.Correct("owaal");
cout << "Total Items :" << items.size() << endl;
auto itemsEnd = items.end();
for (auto it = items.begin(); it != items.end(); ++it)
cout << "Term " << (*it).term << " Distance : " << it->distance << " Count : " << it->count << endl;