php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69381 out of memory with sage odbc driver (ok in 5.6.5)
Submitted: 2015-04-05 20:13 UTC Modified: 2015-04-27 14:45 UTC
From: JLH at Dataplan dot co dot uk Assigned: ab (profile)
Status: Closed Package: ODBC related
PHP Version: 5.6.7 OS: Windows 2012r2 nts
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: JLH at Dataplan dot co dot uk
New email:
PHP Version: OS:

 

 [2015-04-05 20:13 UTC] JLH at Dataplan dot co dot uk
Description:
------------
On upgrading from php 5.6.5 nts (server 2012r2 64bit) to 5.6.7, our odbc_exec is no longer working.
we are using the sage line 50 odbc driver to extract data from the accounts software we use.

I suspect this is related to bug id 68964

Test script:
---------------
c:\inetpub\php\php.exe c:\inetpub\wwwroot\sage.php

sage.php contains:
<?php
$odbcconn=odbc_connect("SageLine50v20","user","pass");
$query=odbc_exec($odbcconn,"SELECT ACCOUNT_REF, NAME FROM sales_ledger");
?>


Expected result:
----------------
in the 5.6.5 version, the code will display no errors

Actual result:
--------------
in the 5.6.7 version we get:
PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 1956365745 bytes) in C:\inetpub\wwwroot\sage.php on line 3

So i changed the memory limit from 512M to 3G to see what would happen:
PHP Fatal error:  Out of memory (allocated 262144) (tried to allocate 1956365745
 bytes) in C:\inetpub\wwwroot\sage.php on line 3

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-04-06 15:25 UTC] ab@php.net
-Status: Open +Status: Feedback
 [2015-04-06 15:25 UTC] ab@php.net
Could you please check with the latest snapshots as in bug #69354? Looks very similar to it.

Thanks.
 [2015-04-13 09:51 UTC] JLH at Dataplan dot co dot uk
I tried using php from php-master-nts-windows-vc11-x86-rf265928.zip as requested and still have an error

VirtualAlloc() failed: [0x00000008] Not enough storage is available to process t
his command.

PHP Fatal error:  Out of memory (allocated 2097152) (tried to allocate 195376781
3 bytes) in C:\inetpub\wwwroot\sage.php on line 3
 [2015-04-14 06:30 UTC] ab@php.net
Ok, in this case, please provide the exact instructions how to reproduce this.

Thanks.
 [2015-04-14 17:15 UTC] JLH at Dataplan dot co dot uk
Other than the code above, it requires sage accounts be installed on the machine (or its odbc driver at least) which is not free software.
I could provide you access to a test virtual machine for you to see the problem on with a demo data set in sage if that is ok?
 [2015-04-15 07:29 UTC] ab@php.net
@JLH, you've already shown the error messages and confirmed the bug is still present, no need to just see that again.

What I'm asking for is to be able to debug and recompile PHP using your driver and data, and then make a fix and a unit test. So it were probably easier the other way round - if you could please supply the test db and the driver. Maybe they have some trial of the driver?

Thanks.
 [2015-04-23 17:36 UTC] JLH at Dataplan dot co dot uk
Sorry for the delay

I have put the standard sage demo data, the odbc driver and a readme.txt at
http://109.234.200.229/php69381/

Hope that helps
 [2015-04-26 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 [2015-04-26 06:05 UTC] requinix@php.net
-Status: No Feedback +Status: Open
 [2015-04-26 18:25 UTC] cmb@php.net
-Status: Open +Status: Analyzed -Assigned To: +Assigned To: ab
 [2015-04-26 18:25 UTC] cmb@php.net
The ODBC trace[1] explains what's happening. The SQLColAttributes
call for SQL_DESC_CONCISE_TYPE[2] returns SQL_VARCHAR. That causes
SQLColAttributes to be called with SQL_DESC_OCTET_LENGTH[3] to get
the displaysize, but the driver can't handle that attribute.
However, the SQL_ERROR is not caught, and the implementation
proceeds with emalloc'ing whatever is stored in displaysize.

For comparison, see the ODBC trace[4] under PHP 5.6.5.

This issue is closely related to bug #68350.

Anatol, can you please have a look.

[1] <https://gist.github.com/cmb69/e34ce51bfc50f6a8c8d6>
[2] <http://lxr.php.net/xref/PHP_TRUNK/ext/odbc/php_odbc.c#959>
[3] <http://lxr.php.net/xref/PHP_TRUNK/ext/odbc/php_odbc.c#994>
[4] <https://gist.github.com/cmb69/39662a0973653ddf7880>
 [2015-04-27 14:43 UTC] ab@php.net
@JLH thanks for the delivery, I can now confirm the insights of @cmb.

The Sage driver claims compatibility with ODBC 3.8, however this piece seems to be a bug in that driver. SQL_DESC_OCTET_LENGTH is introduced with ODBC 3.0, so it should be supported. @JLH it might probably make sense to report this to the origin. 

I'm going to debug this more next days, seems that other drivers having unclean 3.x implementations may be sensitive to this as well. In the worst case I guess we'll need to apply the quirk from the bug #68350.

Thanks.
 [2015-04-27 14:45 UTC] ab@php.net
@cmb, ah ... that's SQLColAttribute, not SQLColAttributes - as we've ODBC 3.0 by default.

Thanks.
 [2015-04-28 13:04 UTC] ab@php.net
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src.git;a=commit;h=268eb1999b1598a2a1a875c5f0172d5b615811ac
Log: fix bug #69381
 [2015-04-28 13:04 UTC] ab@php.net
-Status: Analyzed +Status: Closed
 [2015-04-28 13:16 UTC] ab@php.net
Automatic comment on behalf of frederic.marchal@wowtechnology.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=f505d112074d7d0693ee6829945865b4788f777f
Log: Fixed bug #69381 out of memory with sage odbc driver
 [2016-07-20 11:38 UTC] davey@php.net
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src.git;a=commit;h=268eb1999b1598a2a1a875c5f0172d5b615811ac
Log: fix bug #69381
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Nov 23 07:01:29 2024 UTC