Other ecpg thread unsafety

Started by ITAGAKI Takahiroover 18 years ago2 messages
#1ITAGAKI Takahiro
itagaki.takahiro@oss.ntt.co.jp

I looked for another thread-unsafe usage of variables like prep_stmts,
and I found the 4 possibly-unsafe ones:

[1]: all_descriptors in ecpg/ecpglib/descriptor.c: Management of descriptors used by SQL DESCRIPTOR is not safe.
Management of descriptors used by SQL DESCRIPTOR is not safe.

[2]: auto_allocs in ecpg/ecpglib/memory.c: All memory allocation for statements are not safe.
All memory allocation for statements are not safe.

[3]: nextStmtID in ecpg/ecpglib/prepare.c: Increment is not safe in ECPGauto_prepare().
Increment is not safe in ECPGauto_prepare().

[4]: stmtCacheEntries in ecpg/ecpglib/prepare.c: Reading/writing are not safe in ECPGauto_prepare().
Reading/writing are not safe in ECPGauto_prepare().

I'm not convinced that all of the above are completely dangerous,
but [2]auto_allocs in ecpg/ecpglib/memory.c: All memory allocation for statements are not safe. might affect all of users writing multi-threaded ecpg programs...
Are there any bugs we should fix?

Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center

#2Michael Meskes
meskes@postgresql.org
In reply to: ITAGAKI Takahiro (#1)
Re: Other ecpg thread unsafety

On Wed, Sep 26, 2007 at 05:56:59PM +0900, ITAGAKI Takahiro wrote:

[1] all_descriptors in ecpg/ecpglib/descriptor.c:
Management of descriptors used by SQL DESCRIPTOR is not safe.

[2] auto_allocs in ecpg/ecpglib/memory.c:
All memory allocation for statements are not safe.

These two should suffer from the same problem prep_stmt suffered from.

[3] nextStmtID in ecpg/ecpglib/prepare.c:
Increment is not safe in ECPGauto_prepare().

Not sure whether this is really a problem, but if we're fixing stuff
anyway, why not play it safe.

[4] stmtCacheEntries in ecpg/ecpglib/prepare.c:
Reading/writing are not safe in ECPGauto_prepare().

This also doesn't look like a dangerous bug, but it's still not working
as it should. I'd say let's fix them all.

Michael
--
Michael Meskes
Email: Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes@jabber.org
Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!