2013-12-24 13:55 kelteze'ssel, MauMau i'rta:
> Hello,
>
> I encountered a bug of ECPG with PG 9.2.4, which probably exists in all 
> releases. The
> attached patch is for 9.4. Could you review and backport this to at least 9.2 
> and later?
>
>
> [Problem]
> The attached ECPG app

The app wasn't attached, only the patch.
If this is a small test app, it can also be a part of the patch in the form of a
regression test.

> crashes and dumps core with SIGBUS on Solaris for SPARC. I used Solaris 10, 
> and Oracle
> Studio to compile the app for 64-bit build. The same app completes 
> successfully on Linux
> and Windows for x86/x564.
>
> The steps to reproduce the problem is:
> 1. ecpg sigbus.pgc
> 2. cc -xtarget=generic64 -I<pgsql_dir>/include sigbus.c -L<pgsql_dir>/lib 
> -lecpg
> 3. a.out
>
> When execting FETCH statement using an SQL descriptor, the app crashes at the 
> following
> line in ECPGdo(), which is in src/interfaces/ecpg/ecpglib/execute.c:
>
> var->value = *((char **) (var->pointer));
>
>
> [Cause]
> ecpg outputs the following line in the preprocessed source file:
>
> { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0",
> ECPGt_char,(cur),(long)4,(long)1,(4)*sizeof(char),
> ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
> ECPGt_descriptor, (desc1), 0L, 0L, 0L,
> ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
>
> So, the above line is executed in ECPGdo(). On the other hand, desc1 is not 
> aligned on
> 8-byte boundary. This unaligned access causes SIGBUS.
>
>
> [Fix]
> Because desc1 is a char array, else block should be executed instead of the 
> above path.
>
> var->value = var->pointer;
>
> Therefore, make ecpg pass SQL descriptor host variables to ECPGdo() with 
> non-zero lengths.
>
>
> Regards
> MauMau
>
>


-- 
----------------------------------
Zolta'n Bo"szo"rme'nyi
Cybertec Scho"nig & Scho"nig GmbH
Gro"hrmu"hlgasse 26
A-2700 Wiener Neustadt, Austria
Web: http://www.postgresql-support.de
     http://www.postgresql.at/

Reply via email to