Skip Menu |

This queue is for tickets about the DBD-Pg CPAN distribution.

Report information
The Basics
Id: 24579
Status: resolved
Priority: 0/
Queue: DBD-Pg

People
Owner: Nobody in particular
Requestors: DSUGAL [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.49
Fixed in: 2.0.0



Subject: Segfault on AIX with statements that have placeholders
If you build DBD::Pg on AIX, it'll segfault in the pow() calls under some circumstances in dbd_st_prepare_statement. Apparently there are two separate pow() functions in different libraries on AIX -- one takes int arguments, the other takes double arguments. The following patch switches to use powf() instead of pow(). Given that it's always pow(10,x), where 1<=x<=7, a lookup table'd probably be faster, but I'm not picturing this function call being much of a speed issue. (I don't know if powf() is everywhere, so it may be more portable) --- dbdimp.c~ Wed May 3 22:11:14 2006 +++ dbdimp.c Thu Jan 25 10:57:53 2007 @@ -1503,7 +1503,7 @@ continue; /* The parameter itself: dollar sign plus digit (s) */ for (x=1; x<7; x++) { - if (currseg->placeholder < pow((double) 10,(double)x)) + if (currseg->placeholder < powf((float) 10,(float)x)) break; } if (x>=7) @@ -2081,7 +2081,7 @@ continue; /* The parameter itself: dollar sign plus digit(s) */ for (x=1; x<7; x++) { - if (currseg->placeholder < pow ((double)10,(double)x)) + if (currseg->placeholder < powf ((float)10,(float)x)) break; } if (x>=7)
I'm not clear on why AIX is segfaulting? Is it not seeing the explicit casts in there? Very odd. Seems little harm in using powf though, so I'm switching to that until we find a better workaround for AIX. r10488
From: DSUGAL [...] cpan.org
It segfaults because there are two different implementations of pow() available on AIX, one that takes float args and one that takes int args. Which one gets linked in depends on the order of libraries on the link line when things are built; get the wrong one and things go bang. (The 'wrong' version's provided for compatibility with something as far as I remember, but it's been quite a while since I looked)