Thread: BUG #14267: ecpg bug causes hanging for certain data types

BUG #14267: ecpg bug causes hanging for certain data types

From
nilesoien@gmail.com
Date:
VGhlIGZvbGxvd2luZyBidWcgaGFzIGJlZW4gbG9nZ2VkIG9uIHRoZSB3ZWJz
aXRlOgoKQnVnIHJlZmVyZW5jZTogICAgICAxNDI2NwpMb2dnZWQgYnk6ICAg
ICAgICAgIE5pbGVzIE9pZW4KRW1haWwgYWRkcmVzczogICAgICBuaWxlc29p
ZW5AZ21haWwuY29tClBvc3RncmVTUUwgdmVyc2lvbjogOS41LjMKT3BlcmF0
aW5nIHN5c3RlbTogICBDZW50T1MgcmVsZWFzZSA2LjcgKEZpbmFsKQpEZXNj
cmlwdGlvbjogICAgICAgIAoKDQpIaSwNCg0KV2UgaGF2ZSBhIHByb2dyYW0g
dGhhdCBjb21waWxlcyB3aXRoIGVjcGcgdGhhdCBzZWVtZWQgdG8gaGFuZyB1
bnRpbCB3ZQpjaGFuZ2VkIHRoZSB0eXBlIG9mIGEgdmFyaWFibGUgZnJvbSAi
dW5zaWduZWQgbG9uZyBsb25nIiB0byBiZSBzaW1wbHkgImxvbmcKbG9uZyBp
bnQiLg0KDQpXZSB0aGluayB3ZSd2ZSB0cmFja2VkIHRoaXMgZG93biBzb21l
d2hhdC4NCg0KSXQgYXBwZWFycyB0aGF0IHRoZXJlIG1pZ2h0IGJlIGEgZGVm
ZWN0IGluIHRoZSBndWFyZCBzdGF0ZW1lbnQgdGhhdCBhcHBlYXJzCm9uIGxp
bmVzIDM3NyBhbmQgMzc4IG9mIGRhdGEuYyAoaW4gdGhlIEVDUEcgQyBwcmVw
cm9jZXNzb3IgaW4gUEcgdmVyc2lvbgo5LjUuMywgc2VlIHRoZSBmaXJzdCBz
bmlwcGV0IGJlbG93KS4gaXNhcnJheSBpcyBkZWZpbmVkIGFzIGEgQyBlbnVt
LCBob3dldmVyCnRoZSBjb25kaXRpb24gdXNlZCBpbiB0aGUgZ3VhcmQgYXBw
ZWFycyB0byBiZSB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TkZPUk1JWF9NT0RFKGNvbXBhdCkgJiYKKnNjYW5fbGVuZ3RoID09ICcu
JykgJiYgKnNjYW5fbGVuZ3RoICE9ICdcMCcgJiYgKnNjYW5fbGVuZ3RoICE9
ICcgJykpICAgICAgIAovKiBHYXJiYWdlIGxlZnQgKi8NCiAgMzgwICAgICAg
ICAgICAgICAgICAgICAgew0KICAzODEgICAgICAgICAgICAgICAgICAgICAg
ICAgZWNwZ19yYWlzZShsaW5lbm8sIEVDUEdfVUlOVF9GT1JNQVQsCkVDUEdf
U1FMU1RBVEVfREFUQVRZUEVfTUlTTUFUQ0gsIHB2YWwpOw0KICAzODIgICAg
ICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIChmYWxzZSk7DQogIDM4MyAg
ICAgICAgICAgICAgICAgICAgIH0NCiAgMzg0ICAgICAgICAgICAgICAgICAg
ICAgcHZhbCA9IHNjYW5fbGVuZ3RoOw0KICAzODUgDQogIDM4NiAgICAgICAg
ICAgICAgICAgICAgIGJyZWFrOw0KICAzODcgI2VuZGlmICAgLyogSEFWRV9T
VFJUT1VMTCAqLw0KDQogIDM5MiBjYXNlIEVDUEd0X2RvdWJsZToNCiAgMzky
ICAgICAgICAgICAgICAgICAgICAgaWYgKGlzYXJyYXkgJiYgKnB2YWwgPT0g
JyInKQ0KICAzOTMgICAgICAgICAgICAgICAgICAgICAgICAgcHZhbCsrOw0K
ICAzOTQgDQogIDM5NSAgICAgICAgICAgICAgICAgICAgIGlmICghY2hlY2tf
c3BlY2lhbF92YWx1ZShwdmFsLCAmZHJlcywKJnNjYW5fbGVuZ3RoKSkNCiAg
Mzk2ICAgICAgICAgICAgICAgICAgICAgICAgIGRyZXMgPSBzdHJ0b2QocHZh
bCwgJnNjYW5fbGVuZ3RoKTsNCiAgMzk3IA0KICAzOTggICAgICAgICAgICAg
ICAgICAgICBpZiAoaXNhcnJheSAmJiAqc2Nhbl9sZW5ndGggPT0gJyInKQ0K
ICAzOTkgICAgICAgICAgICAgICAgICAgICAgICAgc2Nhbl9sZW5ndGgrKzsN
Cg0KICA1OTkgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFpc2FycmF5
ICYmIGdhcmJhZ2VfbGVmdChpc2FycmF5LApzY2FuX2xlbmd0aCwgY29tcGF0
KSkNCiAgNjAwICAgICAgICAgICAgICAgICAgICAgICAgIHsNCiAgNjAxICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICBmcmVlKG5yZXMpOw0KICA2MDIg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVjcGdfcmFpc2UobGluZW5v
LCBFQ1BHX05VTUVSSUNfRk9STUFULA0KICA2MDMgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAKRUNQR19TUUxTVEFURV9EQVRBVFlQ
RV9NSVNNQVRDSCwgcHZhbCk7DQogIDYwNCAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgcmV0dXJuIChmYWxzZSk7DQogIDYwNSAgICAgICAgICAgICAg
ICAgICAgICAgICB9DQoNCiAgNjU3ICAgICAgICAgICAgICAgICAgICAgICAg
IGlmICghaXNhcnJheSAmJiBnYXJiYWdlX2xlZnQoaXNhcnJheSwKc2Nhbl9s
ZW5ndGgsIGNvbXBhdCkpDQogIDY1OCAgICAgICAgICAgICAgICAgICAgICAg
ICB7DQogIDY1OSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnJlZShp
cmVzKTsNCiAgNjYwICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlY3Bn
X3JhaXNlKGxpbmVubywgRUNQR19JTlRFUlZBTF9GT1JNQVQsDQogIDY2MSAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIApFQ1BHX1NR
TFNUQVRFX0RBVEFUWVBFX01JU01BVENILCBwdmFsKTsNCiAgNjYyICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKGZhbHNlKTsNCiAgNjYz
ICAgICAgICAgICAgICAgICAgICAgICAgIH0NCg0KICA3MDcgICAgICAgICAg
ICAgICAgICAgICAgICAgaWYgKCFpc2FycmF5ICYmIGdhcmJhZ2VfbGVmdChp
c2FycmF5LApzY2FuX2xlbmd0aCwgY29tcGF0KSkNCiAgNzA4ICAgICAgICAg
ICAgICAgICAgICAgICAgIHsNCiAgNzA5ICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICBlY3BnX3JhaXNlKGxpbmVubywgRUNQR19EQVRFX0ZPUk1BVCwN
CiAgNzEwICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
CkVDUEdfU1FMU1RBVEVfREFUQVRZUEVfTUlTTUFUQ0gsIHB2YWwpOw0KICA3
MTEgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoZmFsc2Up
Ow0KICA3MTIgICAgICAgICAgICAgICAgICAgICAgICAgfQ0KDQogIDc1NSAg
ICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzYXJyYXkgJiYgZ2FyYmFn
ZV9sZWZ0KGlzYXJyYXksCnNjYW5fbGVuZ3RoLCBjb21wYXQpKQ0KICA3NTYg
ICAgICAgICAgICAgICAgICAgICAgICAgew0KICA3NTcgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgIGVjcGdfcmFpc2UobGluZW5vLApFQ1BHX1RJTUVT
VEFNUF9GT1JNQVQsDQogIDc1OCAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgIApFQ1BHX1NRTFNUQVRFX0RBVEFUWVBFX01JU01BVENI
LCBwdmFsKTsNCiAgNzU5ICAgICAgICAgICAgICAgICAgICAgICAgICAgICBy
ZXR1cm4gKGZhbHNlKTsNCiAgNzYwICAgICAgICAgICAgICAgICAgICAgICAg
IH0NCg0KDQpJdCBjb3VsZCBiZSB0aGF0IHRoZSB0eXBlICJ1bnNpZ25lZCBs
b25nIGxvbmciIGlzIHNpbXBseSBub3Qgc3VwcG9ydGVkLApob3dldmVyIEkn
ZCBzdGlsbCBzdWdnZXN0IHRoYXQgaWYg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DQpUaGFua3Mg
Zm9yIGNvbnNpZGVyaW5nIHRoaXMhDQoNCk5pbGVzIE9pZW4NCk5hdGlvbmFs
IFNvbGFyIE9ic2VydmF0b3J5DQpCb3VsZGVyIENvbG9yYWRvDQoNCg0KCgo=

Re: BUG #14267: ecpg bug causes hanging for certain data types

From
Michael Meskes
Date:
On Wed, Jul 27, 2016 at 07:30:42PM +0000, nilesoien@gmail.com wrote:
> The following bug has been logged on the website:
> ...
> We have a program that compiles with ecpg that seemed to hang until we
> changed the type of a variable from "unsigned long long" to be simply "long
> long int".

Thanks for finding this.

> We think we've tracked this down somewhat.
>
> It appears that there might be a defect in the guard statement that appears
> on lines 377 and 378 of data.c (in the ECPG C preprocessor in PG version
> ...

And more thanks for tracking it down. I have no idea why this ages old code is
still in there. Apparently not many people use unsigned long long. Anyway, a
fix will be pushed as soon as I'm online again.

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Meskes at (Debian|Postgresql) dot Org
Jabber: michael at xmpp dot meskes dot org
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL