Sunday, July 21, 2013

Memory Testing Issue

I spent the day yesterday installing a new SSD (Solid State Drive).  After installing the OS (the same Linux Mint 13 KDE 64-bit) and transferring my previous configuration (home directory), the version of Mint 13's KDE was upgraded from version 4.8.5 to 4.10.5 using the Kubuntu backports repository.  Along with KDE 4.10.5 came a slightly new version of the Qt libraries (from 4.8.1 to 4.8.2) and CMake (2.8.7 to 2.8.9).  While the CMake change had no effect, the new Qt libraries caused the memory tests to fail.

The reason for the failures was due to the error suppression file containing specific references to Qt 4.8.1, which obviously didn't match the errors produced when using Qt 4.8.2.  Changing all the "4.8.1" string to "4.8.2" allowed the memory test to pass.  Instead of having separate suppression files for each version of Qt, the suppression file was changed to a CMake configure input file where CMake fills in the current Qt version.

Testing this change with an installed version of Qt 4.8.4 (Qt 4.8.5. is now the latest version of the Qt 4.8 series) did not work because of two issues.  The first was that this version of Qt was located in a different path.  The suppression input file was modified to also get the directory of Qt filled in by CMake.  The second was that Qt 4.8.4 produced a few additional memory errors.  These errors were added to the suppression input file and do not cause any issues when testing with Qt 4.8.2.

In addition to these changes, a temporary regtestn script was added, similar to memtestn, that tests the expression tests and the translator tests that are working with the new translator routines.  A temporary batch file regtestn.bat was also added, however, because of the limitations of DOS batch files, it couldn't easily be restricted to only test the first five translator tests.

[commit 3bb45e3ced]

New Translator – Minor Code Improvements

During the implementation of the LET command translation using the new translator routines (which is now complete), some areas of improvement were seen in the code that could be made.  This changes were kept separate from the latest sub-string assignment implementation commit.

The first was really a correction in the LET translate routine that would be needed once the multiple statements per line ability, separated by colons, was implemented.  The issue was when an error is detected at the very beginning of a LET statement.  To detect if the error was at the beginning, the column of the token was checked to see if it was zero.  This was used to determine which error to return.  However, this only works for a LET statement at the very beginning of a line.  To correct this, before entering the get references loop, the column of the first token (the command token if there was one, or the first token) is saved.  This saved column is then used to detect if the token with an error is at the beginning of the statement.

An improvement was made in how a flag is accessed from a table entry.  There were flags() functions (taking either a code or a token pointer) that returned the flags for the table entry (if the code has an entry, otherwise the null flag was returned).  The returned value was then anded to the desired flag to see if the result was non-zero (flag set) or zero (flag not set)  These were changed to the hasFlag() functions that take a second argument for the desired flag, and return non-zero (flag is set) or zero (flag is not set).

While testing the LET translation, a lot of time was spent chasing down token memory leaks.  The solution was to set the UnUsed sub-code in the token if it was not used.  Care was needed to not set this sub-code if the token was used (for instance, the token was in the RPN output list or on the hold stack).  There were quite a few of these set statements.  As an alternative solution, this sub-code is now set once when a token is obtained from the parser by the get token routine.  When the token is added to the output list, this sub-code is cleared.  A simple output append routine was implemented to do this for all locations appending to the output list.

[commit a67b759432] [commit 6193ef5550] [commit 887cfc06e1]