sorlok / waitzar

Automatically exported from code.google.com/p/waitzar
Other
0 stars 0 forks source link

WaitZar pointer-related bug possibly occuring in the help keyboard #79

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
#WZ 1.7 candidate release
Dang, so close. 

It appears that WaitZar's use of the debug keyboard will crash the
getWordKeyStrokes() call to push_back() with a very useless pointer
deallocation error.

Most likely cause for this is that an external pointer to an element within
that vector is pointed to externally, which will cause all sorts of
nonsense when the vector is resized. 

Yet another reason I should be using STL strings, since a string is the
most likely thing to have an external reference in this list. 

This will take some time to debug, since it is hard to reproduce (and I
haven't nailed it down in Debug mode yet). It generally occurs in this fashion:
1) Look up a word that exists.
2) Choose that word.
3) Enter that sentence.
4) WZ crashes.

Original issue reported on code.google.com by seth.h...@gmail.com on 12 May 2009 at 3:50

GoogleCodeExporter commented 9 years ago
Note: This bug so far has only appeared when typing Zawgyi, and then only 
rarely.

Note: Since we have to run the entire battery of WaitZar tests anyway when we 
start
WaitZar, now would be an excellent time to start replacing bad WZ code with STL 
code.
We can't replace everything at once, so here's my strategy for now:

1) Replace int** in the model with vector<vector<int> >, but have the vectors be
resized explicitly to avoid wasting time & memory resizing. (This will 
introduce an
API break in libwaitzar).
2) Replace, where possible, char* with string and wchar_t* with wstring. 
3) Replace ANY pointers in a vector with values. (e.g., we have vector<vector*>
somewhere).

As a side effect, we can remove the restrictions on words/nexi/prefixes.

This should eliminate our error, and will most likely improve memory usage. 
However,
it might slow down the program. For all three stages, the following data must be
collected:
Memory:
1) Memory in use when app. starts.
2) Memory in use after typing one word, looking up one word, and then emitting 
both.
Time:
1) Time to start up, ms
2) Time to add the entire Myanmar_Listv2 file in mywords.txt
3) Time to (programmatically) type and resolve (get keystrokes for) all words 
in the
model.

We'll need a testing loop for this, of course.

It's unfortunate that this might take some time, but I'd rather not release a 
buggy
version. And, the fact that you shouldn't hold pointers to elements inside 
vectors is
something I didn't know about, so I can imagine that similar errors exist 
(though
none have been reported). Each release of WaitZar WILL be error-free.

Original comment by seth.h...@gmail.com on 12 May 2009 at 5:54

GoogleCodeExporter commented 9 years ago
1) Replaced int**  with vector<vector<int> >. This is slowwwww in Debug mode, 
but
comparatively fast in Release mode. Unfortunately, building a model from 2,000
entries in mywords is now slower. But I see no need to optimize this until 
someone
starts using WZ for another (really big) language.

2) Most char* and wchar_t* items are now strings/wstrings. This is MUCH neater. 
Some
internal algorithms need to be replaced, so I just wrapped them. I'd say 97% of 
all
C-style string usage is gone. (Note: char[] arrays are ok if they're not 
printed).

3) Most naive STL usage (vector<vector *<int> > instead of vector<vector<int> 
>) has
been removed. Also, most pointers have been removed. Also, const and const& 
have been
applied more liberally. 

4) One latent bug (F1->k->back->space->enter) was fixed.

Only a little more re-writing needs to be done (and a whole lot of error 
checking).
Initial performance measurements are positive. Pending an iterator check, I'll 
close
this bug.

Original comment by seth.h...@gmail.com on 28 May 2009 at 5:45

GoogleCodeExporter commented 9 years ago
All re-writing is done, and the pointer bug seems to be gone. Now doing error
checking and QA.

Original comment by seth.h...@gmail.com on 1 Jun 2009 at 8:43

GoogleCodeExporter commented 9 years ago
Whoops, forgot to close this. Fixed, a long time ago.

Original comment by seth.h...@gmail.com on 24 Nov 2009 at 2:50