Skip to content

Commit 6b92dce

Browse files
committed
Clear the hypertable cache pointer on invalidation
Failure to do this results in the possible use after free if hypertable_cache_create fails due to out of memory. Possibly (not reproducible, since there is no OOMs anymore) observed on the running instance with: ``` [1034109]: [69d02db8.fc77d-15] [XX000] ERROR: cache "(null)" is not initialized [1034109]: [69d02db8.fc77d-16] 0 tsdbadmin@tsdb,app=PostgreSQL JDBC Driver [XX000] STATEMENT: INSERT INTO sample_table (a_id, timestamp, metric, b_text, c_text, d_text, created, updated, e_bool) VALUES ($1, $2, $3, $4, $5, $6, NOW(), NOW(), false) ON CONFLICT (a_id, timestamp, metric, b_text) DO NOTHING [891]: [69c81ac3.37b-1174] 0 @,app= [00000] LOG: server process (PID 1034109) was terminated by signal 11: Segmentation fault [891]: [69c81ac3.37b-1175] 0 @,app= [00000] DETAIL: Failed process was running: INSERT INTO sample_table (a_id, timestamp, metric, b_text, c_text, d_text, created, updated, e_bool) VALUES ($1, $2, $3, $4, $5, $6, NOW(), NOW(), false) ON CONFLICT (a_id, timestamp, metric, b_text) DO NOTHING
1 parent c6cf17a commit 6b92dce

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

src/hypertable_cache.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ void
153153
ts_hypertable_cache_invalidate_callback(void)
154154
{
155155
ts_cache_invalidate(&hypertable_cache_current);
156+
/* Prevent reusing the old pointer if cache_create aborts. */
157+
hypertable_cache_current = NULL;
156158
hypertable_cache_current = hypertable_cache_create();
157159
}
158160

0 commit comments

Comments
 (0)