Re: Segfault in in PyString_FromStringAndSize
"Fernando M. Maresca" <[email protected]>
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi. Sorry for start a new thread; I'd just not got my previous message bounced from the list reflector. It's seems the segfault comes from the buffer Py_Malloc'd inside utils.c psycopg_escape_string() It's called from adapter_qstring.c qstring_quote(qstringObject *self) function, circa :101, with the argument "to" as NULL, so the allocation is performed inside the former, and returned to the caller. Trying to use the returned allocated buffer produces a segfault. So, the pointer is inaccessible once returned from psycopg_escape_string(), at least at some times. I've modified adapter_qstring.c to get a buffer allocated before calling psycopg_escape_string() and pass it as the "to" arg instead of NULL, so the ret value is discarded, and the same buffer is used in the rest of the function. This *may* have corrected the segfaults, or at least no one arose since this change. Of course, I don't know if this is a solution or not, nor if it's really is the cause of the problem, but looks like there is from where the segfault comes. I've looking inside psycopg_escape_string() before it returns (in the original form, e.g. with to == NULL) and the allocated buffer is sane, I can get its size and content through prinft inside this function, even until the segfault. Can anybody share a thought on this? Thanks, best regards, Fernando _______________________________________________ Psycopg mailing list Psycopg-IAPFreCvJWPBWskQ1e/[email protected] http://lists.initd.org/mailman/listinfo/psycopg
signature.asc
(application/pgp-signature, 197 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEUEARECAAYFAkmxMsIACgkQCtDmpVXdEMaOwQCgiwEVY3Fhl+FFCHAuAoh6qSGt o4sAl2FUjXVicY2E3ijh7Z4H90o4nV8= =Tbsw -----END PGP SIGNATURE-----