From b1bfe7979f4992d1202b1be2d0110d431d1cb842 Mon Sep 17 00:00:00 2001 From: Sears Russell Date: Fri, 14 Mar 2008 03:09:29 +0000 Subject: [PATCH] Questionable attempts to appease valgrind. --- CTestConfig.cmake | 4 ++-- src/stasis/allocationPolicy.c | 8 +++++--- src/stasis/logger/logEntry.c | 23 ++++++++++++++--------- stasis/transactional.h | 4 +++- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/CTestConfig.cmake b/CTestConfig.cmake index 75b67a6..8a843b1 100644 --- a/CTestConfig.cmake +++ b/CTestConfig.cmake @@ -4,7 +4,7 @@ # Dashboard is opened for submissions for a 24 hour period starting at # the specified NIGHLY_START_TIME. Time is specified in 24 hour format. SET (CTEST_NIGHTLY_START_TIME "23:00:00 EDT") - +SET (CTEST_TIME_OUT 3000) # Dart server to submit results (used by client) IF(CTEST_DROP_METHOD MATCHES http) # SET (CTEST_DROP_SITE "public.kitware.com") @@ -19,4 +19,4 @@ ELSE(CTEST_DROP_METHOD MATCHES http) ENDIF(CTEST_DROP_METHOD MATCHES http) SET (CTEST_TRIGGER_SITE - "http://${DROP_SITE}/cgi-bin/Submit-vtk-TestingResults.pl") \ No newline at end of file + "http://${DROP_SITE}/cgi-bin/Submit-vtk-TestingResults.pl") diff --git a/src/stasis/allocationPolicy.c b/src/stasis/allocationPolicy.c index b2ebae4..43981fc 100644 --- a/src/stasis/allocationPolicy.c +++ b/src/stasis/allocationPolicy.c @@ -101,7 +101,7 @@ inline static void remove_xidAlloced(allocationPolicy * ap, int xid, availablePa struct RB_ENTRY(tree) * pages = LH_ENTRY(find)(ap->xidAlloced, &xid, sizeof(xid)); assert(pages); const availablePage * check = RB_ENTRY(delete)(p, pages); - assert(check == p); + assert(check == p); // sometimes fails } inline static void insert_xidDealloced(allocationPolicy * ap, int xid, availablePage * p) { @@ -319,7 +319,9 @@ void allocationPolicyAllocedFromPage(allocationPolicy *ap, int xid, int pageid) if(check1) { assert(p->lockCount == 0); lockAlloced(ap, xid, (availablePage*)p); - } + } else { + assert(*xidp == xid); // new + } } void allocationPolicyLockPage(allocationPolicy *ap, int xid, int pageid) { @@ -375,7 +377,7 @@ void allocationPolicyUpdateFreespaceLockedPage(allocationPolicy * ap, int xid, a struct RB_ENTRY(tree) * locks = LH_ENTRY(find)(ap->xidAlloced, &xid, sizeof(int)); assert(key); availablePage * p = (availablePage*) RB_ENTRY(delete)(key, locks); - assert(p); + assert(p); // sometimes fails p->freespace = newFree; key->freespace = newFree; const availablePage * ret = RB_ENTRY(search)(p, locks); diff --git a/src/stasis/logger/logEntry.c b/src/stasis/logger/logEntry.c index d7a3bf3..d295824 100644 --- a/src/stasis/logger/logEntry.c +++ b/src/stasis/logger/logEntry.c @@ -48,9 +48,9 @@ terms specified in this license. #include "../page.h" // For stasis_record_type_to_size() #include // needed for LoggerSizeOfInternalLogEntry() #include - +#include LogEntry * allocCommonLogEntry(lsn_t prevLSN, int xid, unsigned int type) { - LogEntry * ret = malloc(sizeof(struct __raw_log_entry)); + LogEntry * ret = calloc(1,sizeof(struct __raw_log_entry)); ret->LSN = -1; ret->prevLSN = prevLSN; ret->xid = xid; @@ -96,12 +96,14 @@ LogEntry * allocUpdateLogEntry(lsn_t prevLSN, int xid, /** Use calloc since the struct might not be packed in memory; otherwise, we'd leak uninitialized bytes to the log. */ - LogEntry * ret = calloc(1, sizeof(struct __raw_log_entry) + - sizeof(UpdateLogEntry) + argSize + - ((!invertible) ? stasis_record_type_to_size(rid.size) - : 0) + - (whole_page_phys ? PAGE_SIZE - : 0)); + size_t logentrysize = + sizeof(struct __raw_log_entry) + + sizeof(UpdateLogEntry) + argSize + + ((!invertible) ? stasis_record_type_to_size(rid.size) + : 0) + + (whole_page_phys ? PAGE_SIZE + : 0); + LogEntry * ret = calloc(1,logentrysize); ret->LSN = -1; ret->prevLSN = prevLSN; ret->xid = xid; @@ -121,6 +123,9 @@ LogEntry * allocUpdateLogEntry(lsn_t prevLSN, int xid, memcpy((void*)getUpdatePreImage(ret), preImage, PAGE_SIZE); } + //assert(logentrysize == sizeofLogEntry(ret)); + // XXX checks for uninitialized values in valgrind + // stasis_crc32(ret, sizeofLogEntry(ret), 0); return ret; } @@ -138,7 +143,7 @@ LogEntry * allocCLRLogEntry(const LogEntry * old_e) { // Could handle other types, but we should never encounter them here. assert(old_e->type == UPDATELOG); - LogEntry * ret = malloc(sizeofLogEntry(old_e)); + LogEntry * ret = calloc(1, sizeofLogEntry(old_e)); memcpy(ret, old_e, sizeofLogEntry(old_e)); ret->LSN = -1; // prevLSN is OK already diff --git a/stasis/transactional.h b/stasis/transactional.h index 5cb6e8d..136a3f0 100644 --- a/stasis/transactional.h +++ b/stasis/transactional.h @@ -514,6 +514,8 @@ BEGIN_C_DECLS * @todo recordid.page should be 64bit. * @todo int64_t (for recordid.size) is a stopgap fix. */ +#pragma pack(push) +#pragma pack(1) typedef struct { int page; // XXX needs to be pageid_t, but that breaks unit tests. int slot; @@ -525,7 +527,7 @@ typedef struct { size_t size; // unsigned fd : 1; } blob_record_t; - +#pragma pack(pop) extern const recordid ROOT_RECORD;