|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75595 Database connect
Submitted: 2017-11-30 13:15 UTC Modified: 2021-04-18 04:22 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: markus at prepaid-order dot com Assigned: dharman (profile)
Status: No Feedback Package: PDO MySQL
PHP Version: 7.1.12 OS: ubuntu 16.04
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: markus at prepaid-order dot com
New email:
PHP Version: OS:


 [2017-11-30 13:15 UTC] markus at prepaid-order dot com
simple mariadb PDO connect and give result after success...

when Database is available all worked fine.... shut down DB instance manual and host is not available call simple php script with this function...

if Database is down catch block will not work and php is working and after that following Message appear.

Fatal error: Allowed memory size of 629145600 bytes exhausted (tried to allocate 20480 bytes)

my php function shows like this.

the Code worked before,source code have never changed.
tested with arbitrary php_memory limit,but the issue is still available...

testet with php 5.6,7.0,7.1 (default)...

it works fine with 7.1,but have no idea...

timeout array in PDO constructor have also removed...

Test script:
> function getDBConnection()
> {
>     global $pdo;
>     try {
>         if ($pdo == null)
>             $pdo = new PDO(
>                 'mysql:host=databaseHost;dbname=someDatabase;charset=utf8mb4',
>                 'removed',
>                 'removed_too'
>             );
>     } catch (Exception $ex) {
>         generateErrorPlistWithFailReason(ErrorCodes::DATABASE_IS_DOWN, 
>         exit();
>     }
>     return $pdo;
> }

Expected result:
resource result and or result from catch block (if databse is down/notavailable)...

Actual result:
after timeout 

Fatal error: Allowed memory size of 629145600 bytes exhausted (tried to allocate 20480 bytes)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-11-30 14:48 UTC]
-Status: Open +Status: Feedback
 [2017-11-30 14:48 UTC]
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.

According to your description the problem would be somewhere within generateErrorPlistWithFailReason...
 [2017-11-30 15:39 UTC] markus at prepaid-order dot com
-Status: Feedback +Status: Open
 [2017-11-30 15:39 UTC] markus at prepaid-order dot com
this simple function is inside of any php class.
remember (it works) fine !!!! but the catch block never called when pdo resource is null or timed out.

this is only the connection to connect the database.You can call any small sql statement no matter.

this works fine (only database is online an available). You can stop the mysql instance via /etcInit.d/mysql stop
you can make any connection see my PDO DSN string select any table or sql statement,
hope you can see the error too... please shut down the database instance and call the php script / connection again,aou will see the error appear.
 [2021-04-09 13:00 UTC]
-Status: Open +Status: Feedback -Assigned To: +Assigned To: dharman
 [2021-04-09 13:00 UTC]
I am closing this bug report as it is not clear what the actual issue reported is. If you are still encountering the same problem with modern PHP versions, please create minimal reproducible script which we can copy and paste. The code provided so far has syntax errors and calls an unknown function. You claim that the catch block is never called, but the actual output is a memory overflow. Please explain the problem more clearly.
 [2021-04-18 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.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Feb 25 04:01:28 2024 UTC