Re: Bug in selectrow_arrayref (C version)



On Wed, Apr 25, 2007 at 11:30:52PM +0100, Rob Davies wrote:

I have tracked down a subtle bug in selectrow_arrayref. It's in
DBI-1.54/Driver.xst, so it's probably in various drivers - I found it
in DBD-Oracle-1.19.

What happens is selectrow_arrayref calls dbixst_bounce_method which uses
EXPAND to grow the stack. This may cause the stack to be realloc'd
with the result that the stack has moved to a new location when
dbixst_bounce_method returns. selectrow_arrayref doesn't take this into
account and carries on using the old location in its copy of sp.

Good catch.

The patch below is my attempt at fixing the problem. Someone who actually
understands perl and XS may well be able to come up with something better.
The patch is for Driver.xst in DBI version 1.54. I tested the fix in
DBD::Oracle and it does provide a cure.

I've checked all the other places where dbixst_bounce_method is used, and
as far as I can tell this is the only one that causes a problem.
selectall_arrayref may be affected, but I don't think this is the case.
All of the other functions that use it appear to not use sp before they
return.

+ /* The following two lines are needed in case dbixst_bounce_method
+ caused the stack to be reallocated */
+ SPAGAIN;
+ sp -= items;

Thanks for this Rob. I've applied the fix to both selectall_arrayref
and selectrow_arrayref.

Tim.

p.s. I expect to release 1.55 next week.
.



Relevant Pages

  • Re: State of the Union: Wireless
    ... > * Wireless drivers and the wireless stack need to be maintained IN-TREE ...
    (Linux-Kernel)
  • Re: Maybe we should stop "Paging Beth Stone" already...
    ... | IRQ goes off, then you've got to do a TSS switch to get back to kernel ... without swapping all contents of the TSS. ... (* Check segment selector and descriptor for stack of new privilege ... For me non-hardware devices belong to software and don't need 'drivers'. ...
    (alt.lang.asm)
  • Re: Bringing up eCos on a new platform
    ... That's exactly the reason I'm treating the processor choice and RTOS choice ... At present eCos with ColdFire, one of a couple of ARMs ... TCP/IP stack + some peripheral drivers). ...
    (comp.arch.embedded)
  • Re: HEADS UP: E1000 networking changes in STABLE/7.1 RELEASE
    ... Now if they would just optimize the IP stack for SMP and the rest of the drivers we may have a piece of equipment and OS ... hundreds of thousands of new flows per second for instance), although it's still the most flexible. ... that is based on my igb code, he promised to have some patches back to me ...
    (freebsd-net)
  • [GIT PULL] ieee1394 fixes post 2.6.22-rc3
    ... (old stack) ... fix regression in 2.6.22-rc1: ... your IEEE 1394 adapter. ... To compile this driver as a module, say M here: ...
    (Linux-Kernel)