|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75018 Data corruption when reading fields of bit type
Submitted: 2017-08-01 14:19 UTC Modified: 2017-10-23 05:28 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: ale5000 at gmail dot com Assigned: ab (profile)
Status: Closed Package: MySQLi related
PHP Version: 7.1.7 OS: Windows 7 64-bit
Private report: No CVE-ID: None
 [2017-08-01 14:19 UTC] ale5000 at gmail dot com
It corrupt data when reading fields of bit type.
See the sample code.

The problem is possibly Windows specific but I'm not sure.

Test script:
$username = 'root';
$password = '';
$database_name = 'test_db';

$mysqli = new mysqli('', $username, $password, $database_name);

if($mysqli->connect_errno) die('Error');

$sql = "CREATE TABLE test (bit_column_1 bit(1) NOT NULL) DEFAULT CHARSET=utf8";

$sql = "INSERT INTO test (bit_column_1) VALUES (0)";

$sql = "SELECT bit_column_1 FROM test";
if(!$result = $mysqli->query($sql)) die('Failed');

$row = $result->fetch_assoc();
echo "Result: ".$row['bit_column_1'];

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-08-01 15:07 UTC] michal at cihar dot com
I've just tested this and here is what I've found out:

- I can reproduce this when running 32-bit PHP on 64-bit Windows, it does not happen in 64-bit builds
- The returned value seems to be random, depending on executed code or MySQL statements
- I can reproduce this behavior on PHP 7.1.7 and 7.2.0beta1

Results I got: 0x1508618400000000 0x100000000 0x10c6632400000000 (though this most likely doesn't mean anything)
 [2017-09-13 12:13 UTC]
Automatic comment on behalf of ab
Log: Fixed bug #75018, fixed bug #75177
 [2017-09-13 12:13 UTC]
-Status: Open +Status: Closed
 [2017-09-13 17:50 UTC] ale5000 at gmail dot com

Since this bug can lead to data corruption is it possible to release a new version of PHP with this fix included in a short time?
 [2017-09-24 10:11 UTC] strange_v at ukr dot net
I've just reproduced this issue on latest version (7.1.9) which was compiled from sources for armv7 platform.
 [2017-10-22 15:05 UTC]
-Assigned To: +Assigned To: ab
 [2017-10-22 15:05 UTC]
Oh, i've overseen the question. It's included wit 7.1.11, see the NEWS.

 [2017-10-22 21:15 UTC] ale5000 at gmail dot com
I only see 7.1.10 on

Where is 7.1.11 and what is the url of the NEWS?
 [2017-10-23 05:28 UTC]
@ale5000 coming this week. You can check the RC in the mean time 

PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC