postgresql-interfaces/psqlodbc GitHub issues and pull requests (mirror)  
help / color / mirror / Atom feed
[postgresql-interfaces/psqlodbc] PR #18: Notes todo and attempt to fix memory leak
7+ messages / 2 participants
[nested] [flat]

* [postgresql-interfaces/psqlodbc] PR #18: Notes todo and attempt to fix memory leak
@ 2024-05-13 19:57 "davecramer (@davecramer)" <[email protected]>
  0 siblings, 0 replies; 7+ messages in thread

From: davecramer (@davecramer) @ 2024-05-13 19:57 UTC (permalink / raw)
  To: postgresql-interfaces/psqlodbc <[email protected]>

This may be too naive.

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: [postgresql-interfaces/psqlodbc] PR #18: Notes todo and attempt to fix memory leak
@ 2024-05-14 10:10 ` "progmachine (@progmachine)" <[email protected]>
  5 siblings, 0 replies; 7+ messages in thread

From: progmachine (@progmachine) @ 2024-05-14 10:10 UTC (permalink / raw)
  To: postgresql-interfaces/psqlodbc <[email protected]>

(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.

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: [postgresql-interfaces/psqlodbc] PR #18: Notes todo and attempt to fix memory leak
@ 2024-05-14 10:17 ` "progmachine (@progmachine)" <[email protected]>
  5 siblings, 0 replies; 7+ messages in thread

From: progmachine (@progmachine) @ 2024-05-14 10:17 UTC (permalink / raw)
  To: postgresql-interfaces/psqlodbc <[email protected]>

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... (

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: [postgresql-interfaces/psqlodbc] PR #18: Notes todo and attempt to fix memory leak
@ 2024-05-14 10:44 ` "progmachine (@progmachine)" <[email protected]>
  5 siblings, 0 replies; 7+ messages in thread

From: progmachine (@progmachine) @ 2024-05-14 10:44 UTC (permalink / raw)
  To: postgresql-interfaces/psqlodbc <[email protected]>

(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.

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: [postgresql-interfaces/psqlodbc] PR #18: Notes todo and attempt to fix memory leak
@ 2024-05-14 10:57 ` "davecramer (@davecramer)" <[email protected]>
  5 siblings, 0 replies; 7+ messages in thread

From: davecramer (@davecramer) @ 2024-05-14 10:57 UTC (permalink / raw)
  To: postgresql-interfaces/psqlodbc <[email protected]>

> 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 ?

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: [postgresql-interfaces/psqlodbc] PR #18: Notes todo and attempt to fix memory leak
@ 2024-05-14 11:58 ` "progmachine (@progmachine)" <[email protected]>
  5 siblings, 0 replies; 7+ messages in thread

From: progmachine (@progmachine) @ 2024-05-14 11:58 UTC (permalink / raw)
  To: postgresql-interfaces/psqlodbc <[email protected]>

> 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... =)

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: [postgresql-interfaces/psqlodbc] PR #18: Notes todo and attempt to fix memory leak
@ 2024-05-14 12:03 ` "davecramer (@davecramer)" <[email protected]>
  5 siblings, 0 replies; 7+ messages in thread

From: davecramer (@davecramer) @ 2024-05-14 12:03 UTC (permalink / raw)
  To: postgresql-interfaces/psqlodbc <[email protected]>

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

The tests run fine on windows using regress.ps1



^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2024-05-14 12:03 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-05-13 19:57 [postgresql-interfaces/psqlodbc] PR #18: Notes todo and attempt to fix memory leak "davecramer (@davecramer)" <[email protected]>
2024-05-14 10:10 ` "progmachine (@progmachine)" <[email protected]>
2024-05-14 10:17 ` "progmachine (@progmachine)" <[email protected]>
2024-05-14 10:44 ` "progmachine (@progmachine)" <[email protected]>
2024-05-14 10:57 ` "davecramer (@davecramer)" <[email protected]>
2024-05-14 11:58 ` "progmachine (@progmachine)" <[email protected]>
2024-05-14 12:03 ` "davecramer (@davecramer)" <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox