View Issue Details

IDProjectCategoryView StatusLast Update
0000066Volume 2Bugpublic2019-05-09 10:32
ReporterTafferAssigned ToTaffer 
PrioritylowSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product VersionIssue 1 
Target VersionIssue 2Fixed in VersionIssue 2 
Summary0000066: code analysis bugs in dbserver
DescriptionBasic cppcheck issues found in dbserver; these need to be investigated/fixed for great justice:

[container.c:436]: (error) Expression 'static_idx=(++static_idx)%ARRAY_SIZE(diffs)' depends on order of evaluation of side effects
[container.c:708]: (error) Uninitialized variable: cmd_len
[container_merge.c:512]: (error) Common realloc mistake: 'base' nulled but not freed upon failure
[container_tplt_utils.c:295]: (error) Common realloc mistake: 'ctnrLineBuf' nulled but not freed upon failure
[container_tplt_utils.c:383]: (error) Uninitialized variable: cmd_len
[container_sql.c:889]: (error) Common realloc mistake: 'multi_buf' nulled but not freed upon failure
[container_sql.c:123]: (error) Uninitialized variable: buf_len
[container_sql.c:152]: (error) Uninitialized variable: buf_len
[container_sql.c:209]: (error) Uninitialized variable: buf_len
[container_sql.c:228]: (error) Uninitialized variable: buf_len
[container_sql.c:253]: (error) Uninitialized variable: buf_len
[container_sql.c:276]: (error) Uninitialized variable: buf_len
[dbinit.c:740]: (error) Invalid number of character '(' when no macros are defined.
[dblog.c:38]: (error) va_list 'ap' was opened but not closed by va_end().
[dbinit.c:740]: (error) Invalid number of character '(' when these macros are defined: 'ACCOUNTSERVER'.
[dbinit.c:740]: (error) Invalid number of character '(' when these macros are defined: 'ACCOUNTSERVER;CLIENT;SERVER;TEST_CLIENT'.
[dbinit.c:740]: (error) Invalid number of character '(' when these macros are defined: 'ACCOUNTSERVER;CLIENT;SERVER;TEST_CLIENT;CLIENT;FINAL;SERVER'.
[dbinit.c:740]: (error) Invalid number of character '(' when these macros are defined: 'CLIENT;SERVER'.
[dbinit.c:740]: (error) Invalid number of character '(' when these macros are defined: 'CLIENT;SERVER;TEST_CLIENT'.
[dbinit.c:740]: (error) Invalid number of character '(' when these macros are defined: 'DBSERVER'.
[loadBalancing.c:104]: (error) Uninitialized variable: i
[dbinit.c:740]: (error) Invalid number of character '(' when these macros are defined: 'DBSERVER;FULLDEBUG;QUEUESERVER'.
[dbinit.c:740]: (error) Invalid number of character '(' when these macros are defined: 'DO_STUPID_DATABASE_TESTS'.
[dbdispatch.c:1238]: (error) Uninitialized variable: map_con
[dbinit.c:740]: (error) Invalid number of character '(' when these macros are defined: 'HASH_TABLE_TRACK;STRING_TABLE_TRACK'.
[dbinit.c:740]: (error) Invalid number of character '(' when these macros are defined: 'LAUNCHERCOMM_PARSE_INFO_DEFS'.
[dbinit.c:740]: (error) Invalid number of character '(' when these macros are defined: 'OFFLINE_ENABLE_DELETION_LOG_IMPORT_CODE'.
[servercfg.c:152]: (error) Resource leak: file
[statagg.c:710]: (error) Memory leak: pchBuff
[offline.c:1828]: (error) Memory leak: containerBuffer
Steps To ReproduceRun cppcheck in the dbserver directory:

cppcheck \
-j8 \
--output-file=000-cppcheck \
-I ../Common/account \
-I ../3rdparty/zeromq2-1/include \
-I ../libs/UtilitiesLib/UtilsCXX \
-I ../libs/UtilitiesLib/UtilsNew \
.

This runs the default set of checkers over all the source in the current directory (recursively searching subdirectories), using all the include directories found in the project file. Output goes to 000-cppcheck.
Additional Informationcppcheck --enable=all finds a lot more things (567 complaints instead of 30), but most of them are code style complaints rather than outright bugs.
TagsNo tags attached.
subsystem

Activities

Taffer

2019-05-09 00:27

developer   ~0000045

dbinit.c has broken my brain... line 740 is the CLOSELINK() macro usage here:

```
#define closesocket(sock) {\
        printf_stderr("Closing %s...\n", ##sock); \
        closesocket(sock); \
        printf_stderr("done\r\n");\
    }

#define CLOSELINK(netlink) \
    if (netlink) { \
        closesocket(((NetLink*)netlink)->socket); \
    } else { \
        OutputDebugStringf("Error: %s is null (i=%d)", ##netlink, i); \
    }

    closesocket(net_links.listen_sock);
    for (i=0; i<net_links.links->size; i++) {
        CLOSELINK(net_links.links->storage[i]);
    }
```

I looks OK to me (although using macros like that is definitely a bad smell).

Taffer

2019-05-09 00:55

developer   ~0000046

PR 0000034 - https://git.ourodev.com/CoX/Source/pulls/34/files?style=unified&whitespace=ignore-all

Taffer

2019-05-09 10:30

developer   ~0000047

Re-opening to assign to v2i2.

Issue History

Date Modified Username Field Change
2019-05-07 10:43 Taffer New Issue
2019-05-07 11:00 Taffer Assigned To => Taffer
2019-05-07 11:00 Taffer Status new => assigned
2019-05-09 00:27 Taffer Note Added: 0000045
2019-05-09 00:55 Taffer Status assigned => resolved
2019-05-09 00:55 Taffer Resolution open => fixed
2019-05-09 00:55 Taffer Note Added: 0000046
2019-05-09 10:30 Taffer Status resolved => feedback
2019-05-09 10:30 Taffer Resolution fixed => reopened
2019-05-09 10:30 Taffer Note Added: 0000047
2019-05-09 10:32 Taffer Priority normal => low
2019-05-09 10:32 Taffer Status feedback => resolved
2019-05-09 10:32 Taffer Resolution reopened => fixed
2019-05-09 10:32 Taffer Product Version => Issue 1
2019-05-09 10:32 Taffer Fixed in Version => Issue 2
2019-05-09 10:32 Taffer Target Version => Issue 2