Subject: [postgresql-interfaces/psqlodbc] PR #18: Notes todo and attempt to fix memory leak

From: "davecramer (@davecramer)" <[email-masked]>
Date: Mon, 13 May 2024 19:57:37 +0000

This may be too naive.

---

From: "progmachine (@progmachine)" <[email-masked]>
Date: Tue, 14 May 2024 10:10:05 +0000

(on connection.c:576)

Potential infinite loop, if two sibling array entries is `NULL`.
Potential run out of array borders, if `i` is index of last array element. ASAN will kick you in this place =)
To do such algorithm of cleaning `NULL` pointers out, you need two index variables: `idst` for place you write non-null pointer, `isrc` for place you get that non-null pointer, and isrc goes forward faster than `idst`. After `isrc` reaches end of array, `idst` will be new elements count.

---

From: "progmachine (@progmachine)" <[email-masked]>
Date: Tue, 14 May 2024 10:17:52 +0000

This fix for memory leak is incorrect. It broke the meaning of `CC_clear_col_info` function - this function is clearing COL_INFO cache from `ConnectionClass` object, when it is obsolete, or connection is closing. Your fix will leave obsolete cache entries.
To fix this leak correctly, we need to restore refcnt lifetime management. I have strong intent to do this, because these leaks causing fails with my project's unit tests.
For now, i have another problem - many psqlodbc native tests are failing, saying that `testtab1` does not exist... (

---

From: "progmachine (@progmachine)" <[email-masked]>
Date: Tue, 14 May 2024 10:44:08 +0000

(on connection.c:563)

You do not need to decrement `self->ntables` here, it will leave some entries out of this and next for-loop scopes.

---

From: "davecramer (@davecramer)" <[email-masked]>
Date: Tue, 14 May 2024 10:57:10 +0000

> This fix for memory leak is incorrect. It broke the meaning of `CC_clear_col_info` function - this function is clearing COL_INFO cache from `ConnectionClass` object, when it is obsolete, or connection is closing. Your fix will leave obsolete cache entries. To fix this leak correctly, we need to restore refcnt lifetime management. I have strong intent to do this, because these leaks causing fails with my project's unit tests. For now, i have another problem - many psqlodbc native tests are failing, saying that `testtab1` does not exist... (

Well I need to figure out how to test this.

As for `testtab1` why not use the existing tests ?

---

From: "progmachine (@progmachine)" <[email-masked]>
Date: Tue, 14 May 2024 11:58:58 +0000

> As for `testtab1` why not use the existing tests ?

I am talking about existing tests, located in `test` directory of psqlodbc project:
[regression.diffs.txt](https://github.com/postgresql-interfaces/psqlodbc/files/15307993/regression.diffs.txt)

false alarm... =)

---

From: "davecramer (@davecramer)" <[email-masked]>
Date: Tue, 14 May 2024 12:03:39 +0000

I guess you are running this on a mac or other *nix like machine.

The tests run fine on windows using regress.ps1