Skip to content

setTypeMap crash with PHP 7.1 #529

Closed
@rinu

Description

@rinu

Calling Cursor::setTypeMap crashes in some cases.
I posted more details here: https://bugs.php.net/bug.php?id=74073


Description:

A project I'm working on, recently started using MongoDB for some of it's storage. I can't share the entire project, the following is the smallest code example that reproduces the crash.

This is not an issue with the official Ubuntu PHP 7.0 packages. I have compiled PHP 7.1.1 and MongoDB extension myself.

I tried getting a core dump but couldn't figure it out. I have a debug build so it should be possible but I can't get it set up.

Steps to reproduce:

  1. Use PHP 7.1.1
  2. Install mongodb extension
  3. Create composer.json with the following contents:
{
	"require" : {
	}
}
  1. Run composer install
  2. Save test script as test.php
  3. Run php test.php

Test script:

<?php

require 'vendor/autoload.php';

$manager = new MongoDB\Driver\Manager("mongodb://localhost:27017");

$bulk = new MongoDB\Driver\BulkWrite;
$id = $bulk->insert(['x' => 1]);
$manager->executeBulkWrite('db.collection', $bulk);

$query = new MongoDB\Driver\Query(['_id' => $id]);
$cursor = $manager->executeQuery('db.collection', $query);
$cursor->setTypeMap([
	'array' => 'MongoDB\\Model\\BSONArray',
	'document' => 'MongoDB\\Model\\BSONDocument',
	'root' => 'MongoDB\\Model\\BSONDocument'
]);

Expected result:

Unhandled exception

Actual result:

php: /home/rauno/php7/include/php/Zend/zend_string.h:263: zend_string_free: Assertion `(s)->gc.refcount <= 1' failed.
Aborted (core dumped)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions