View Issue Details

IDProjectCategoryView StatusLast Update
0002804Ham Radio DeluxeBugpublic2018-07-25 20:47
ReporterK7ZCZ 
Assigned ToK7ZCZ 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformIntel i7-5960XOSWindows 10 Professional x64OS Version16299
Product Version 
Target VersionFixed in Version6.4.0.873 
Summary0002804: Logbook: DX Lookup code builds bad SQL, causes bad results and repeated SQL errors
DescriptionThe Logbook DX Cluster code will repeatedly issue bad SQL statements against the database. These statements are syntactically incorrect and cause an error, which the application simply ignores, failing to consider the desired outcome of the SQL statement against the spot provided.
Steps To Reproduce1) Fire up the logbook
2) Open a database. The larger the database, the better
3) Conenct to a DX cluster
4) Observe the logfile window.

BUG#1) Eventually, you'll find an error message like this:

13:26:56  DX Lookup      Error: Callsign lookups -
13:26:56  DX Lookup      Error: Call ......: KA4TLC -
13:26:56  DX Lookup      Error: Band ......: 15M -
13:26:56  DX Lookup      Error: Mode ......: DIGI -
13:26:56  DX Lookup      Error: Database ..: HRDBlank -
13:26:56  DX Lookup      Error: Incorrect syntax near the keyword 'OR'.


This error is caused by a race condition, so it won't always happen. Try again, if it doesn't. It might take several tries.
TagsNo tags attached.
ModuleLogbook
Sub-ModuleDX Cluster
Testing Beta Successful

Relationships

Activities

K7ZCZ

2018-07-06 09:50

manager   ~0005615

The Logbook DX Cluster feature relies on some SQL statements to get data from the database to see if a particular spot has been worked before -- and does so along a few different dimensions: call itself, band, mode, band+mode, and so on. The queries can get a little bit involved. Some feature long sequences of conjunctions which become part of a filter.

For example, we want to know if a particualr mode has been involved with a call, but only among a certain DXCC entity, and only in certain modes. The list of modes is pretty long. To save time, the list of modes expressed in a SQL string is pre-formed just once and repeatedly concatenated to any statement which might need it.

The bug is this: that the code which builds those statements is not thread safe. One example is the function GetPhoneSQLString(), which causes the specific bad SQL in this issue. The function tests a static to see if the static is populated; if not, it begins building the string. If two threads arrive at this function and both begin building the string, the end up walking on eachother because there's no locking over the initialization or access to the string. An example of the bogus SQL is here:

SELECT COL_MODE FROM [TABLE_HRD_CONTACTS_V01] WHERE (COL_DXCC = '291') AND  NOT ((COL_MODE = 'CW') OR ( OR (COL_MODE = 'SSTV') OR (COL_MODE = 'MABELL'))(COL_MODE = 'USB') OR (COL_MODE = 'LSB') OR (COL_MODE = 'AM') OR (COL_MODE = 'FM') OR (COL_MODE = 'SSTV') OR (COL_MODE = 'MABELL')))  AND ( (COL_QSL_RCVD NOT LIKE 'N%') OR (COL_EQSL_QSL_RCVD NOT LIKE 'N%') OR (COL_LOTW_QSL_RCVD NOT LIKE 'N%') )


The second top-level OR clause comes from GetPhoneSQLString(), and we can see that it is a combination of multiple filter strings.

K7ZCZ

2018-07-06 15:06

manager   ~0005620

A fix is available at this shelved change set
https://hrdsoftware.visualstudio.com/HRD/_versionControl/shelveset?ss=fix%20SQL%20String%20creation%20race%3Bmikeblas%40msn.com

K7ZCZ

2018-07-07 09:26

manager   ~0005628

fixed with this checkin
https://hrdsoftware.visualstudio.com/HRD/_versionControl/changeset/4212

g3ucq

2018-07-13 15:21

viewer   ~0005676

I do not see those error messages.

WA9PIE

2018-07-17 16:44

administrator   ~0005722

I tested and no longer see these.

Issue History

Date Modified Username Field Change
2018-07-05 17:06 K7ZCZ New Issue
2018-07-06 09:44 K7ZCZ Summary Logbook: DX Lookup code buidls bad SQL, causes bad results and repeated SQL errors => Logbook: DX Lookup code builds bad SQL, causes bad results and repeated SQL errors
2018-07-06 09:44 K7ZCZ Steps to Reproduce Updated View Revisions
2018-07-06 09:50 K7ZCZ Note Added: 0005615
2018-07-06 15:06 K7ZCZ Note Added: 0005620
2018-07-07 09:26 K7ZCZ Assigned To => K7ZCZ
2018-07-07 09:26 K7ZCZ Status new => resolved
2018-07-07 09:26 K7ZCZ Resolution open => fixed
2018-07-07 09:26 K7ZCZ Note Added: 0005628
2018-07-12 14:35 K7ZCZ Fixed in Version => 6.4.0.864
2018-07-13 15:21 g3ucq Note Added: 0005676
2018-07-17 16:44 WA9PIE Status resolved => closed
2018-07-17 16:44 WA9PIE Testing Not Started => Beta Successful
2018-07-17 16:44 WA9PIE Note Added: 0005722
2018-07-23 22:52 WA9PIE Project 3 - Current Dev List => Ham Radio Deluxe
2018-07-24 15:36 WA9PIE Project Ham Radio Deluxe => 3 - Current Dev List
2018-07-25 08:00 WA9PIE Fixed in Version 6.4.0.864 => 6.4.0.873
2018-07-25 20:47 WA9PIE Project 3 - Current Dev List => Ham Radio Deluxe