database->test;
$collection->drop();

$collection->batchInsert([
    ['a' => 'b'],
    ['a' => 'b']
    ]
);

######################
/**
 * @var MongoCursor
 */
$cursor = $collection->find(); // <- THIS LINE THROWS an Exception. $collection->find() returns an instance of MongoCursor

/** also tried this: */
$cursor2 = new MongoCursor($connection, 'database.test');

######################

$result = iterator_to_array($cursor);
foreach ( $result as $id => $value )
{
    echo "id: ".strval($value['_id']);
    xdebug_var_dump( $value );
}
xdebug_var_dump($cursor);
xdebug_var_dump($cursor2);
unset($cursor);
unset($cursor2);



$breakPointAfterDestroyingCursors = true; //Skipping to this line as a breakpoint from the begginning of the file DOES NOT THROW AN EXCEPTION

?>


####  INDEX  ####

 *  description
 *  Versions
 *  php.ini (relevant settings)
 *   - mongo settings
 *   - xdebug settings
 *  NetBeans IDE LOG
 *  xdebug LOG


When running a "Debug Project" in NetBeans, whenever MongoCursor object is instantiated,
NetBeans throws a SocketException after ~1.5 seconds. If the instances are unset and the 
exception-throwing step is skipped (with a breakpoint), the debugging session continues normally.



####   Versions  ####
PHP 5.4.6
Xdebug 2.2.1
Server version: Apache/2.2.23 (Win32)
NetBeans Version: NetBeans IDE 7.2.1 (Build 201210100934)
Java: 1.7.0_13; Java HotSpot(TM) Client VM 23.7-b01
System: Windows 7 version 6.1 running on x86 (64); Cp1250; en_US (nb)
MongoDB PHP extension: 1.3.1



####  PHP .ini  ####
extension       = php_mongo-1.3.1-5.4-vc9.dll
zend_extension  = php_xdebug-2.2.1-5.4-vc9.dll
xdebug.remote_enable = on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
output_buffering = Off




####  $ php -i | grep mongo -i  ####
mongo
MongoDB Support => enabled
mongo.allow_empty_keys => 0 => 0
mongo.chunk_size => 262144 => 262144
mongo.cmd => $ => $
mongo.default_host => localhost => localhost
mongo.default_port => 27017 => 27017
mongo.is_master_interval => no value => no value
mongo.long_as_object => 0 => 0
mongo.native_long => 0 => 0
mongo.ping_interval => no value => no value
mongo.utf8 => 1 => 1



####  NetBeans settings  ####


Tools/Options/PHP/Debugging/...
 * debugger port: 9000
 * session ID: netbeans-xdebug
 * stop at first line: true
 * watches and balloon evaluation: false
 * Maximum depth of structures: disabled
 * Maximum number of children: disabled
 * Show requested URLs: false
 * Show Debugger console: false

/nbproject/...
  /private/.private.properties >>>
    copy.src.files=false
    copy.src.target=
    index.file=test.php
    run.as=LOCAL
    url=http://cake/xdebug_mongo_crash/
  /project.properties >>>
    include.path=${php.global.include.path}
    php.version=PHP_54
    source.encoding=UTF-8
    src.dir=.
    tags.asp=false
    tags.short=true
    web.root=.




#### $ php -i | grep xdebug -i ####
xdebug
xdebug support => enabled
xdebug.auto_trace => Off => Off
xdebug.cli_color => 0 => 0
xdebug.collect_assignments => Off => Off
xdebug.collect_includes => On => On
xdebug.collect_params => 0 => 0
xdebug.collect_return => Off => Off
xdebug.collect_vars => Off => Off
xdebug.coverage_enable => On => On
xdebug.default_enable => On => On
xdebug.dump.COOKIE => no value => no value
xdebug.dump.ENV => no value => no value
xdebug.dump.FILES => no value => no value
xdebug.dump.GET => no value => no value
xdebug.dump.POST => no value => no value
xdebug.dump.REQUEST => no value => no value
xdebug.dump.SERVER => no value => no value
xdebug.dump.SESSION => no value => no value
xdebug.dump_globals => On => On
xdebug.dump_once => On => On
xdebug.dump_undefined => Off => Off
xdebug.extended_info => On => On
xdebug.file_link_format => no value => no value
xdebug.idekey => no value => no value
xdebug.max_nesting_level => 100 => 100
xdebug.overload_var_dump => On => On
xdebug.profiler_aggregate => Off => Off
xdebug.profiler_append => Off => Off
xdebug.profiler_enable => Off => Off
xdebug.profiler_enable_trigger => Off => Off
xdebug.profiler_output_dir => \ => \
xdebug.profiler_output_name => cachegrind.out.%p => cachegrind.out.%p
xdebug.remote_autostart => Off => Off
xdebug.remote_connect_back => Off => Off
xdebug.remote_cookie_expire_time => 3600 => 3600
xdebug.remote_enable => On => On
xdebug.remote_handler => dbgp => dbgp
xdebug.remote_host => localhost => localhost
xdebug.remote_log => no value => no value
xdebug.remote_mode => req => req
xdebug.remote_port => 9000 => 9000
xdebug.scream => Off => Off
xdebug.show_exception_trace => Off => Off
xdebug.show_local_vars => Off => Off
xdebug.show_mem_delta => Off => Off
xdebug.trace_enable_trigger => Off => Off
xdebug.trace_format => 0 => 0
xdebug.trace_options => 0 => 0
xdebug.trace_output_dir => \ => \
xdebug.trace_output_name => trace.%c => trace.%c
xdebug.var_display_max_children => 128 => 128
xdebug.var_display_max_data => 512 => 512
xdebug.var_display_max_depth => 3 => 3



########## IDE LOG #########

INFO [org.netbeans.modules.php.dbgp.URIMapper]: class org.netbeans.modules.php.dbgp.URIMapper$1: C:\somepath\CakeCode\shop\app\Plugin\Products\Test\Case\Model\ProductDetailTest.php -> file:///C:/somepath/CakeCode/shop/app/Plugin/Products/Test/Case/Model/ProductDetailTest.php
INFO [org.netbeans.modules.php.dbgp.URIMapper]: class org.netbeans.modules.php.dbgp.URIMapper$1: C:\somepath\CakeCode\shop\lib\Cake\Model\Model.php -> file:///C:/somepath/CakeCode/shop/lib/Cake/Model/Model.php
INFO [org.netbeans.modules.php.dbgp.URIMapper]: class org.netbeans.modules.php.dbgp.URIMapper$1: C:\somepath\CakeCode\shop\lib\Cake\Model\Datasource\DboSource.php -> file:///C:/somepath/CakeCode/shop/lib/Cake/Model/Datasource/DboSource.php
INFO [org.netbeans.modules.php.dbgp.URIMapper]: class org.netbeans.modules.php.dbgp.URIMapper$1: C:\somepath\CakeCode\shop\lib\Cake\Model\Datasource\DboSource.php -> file:///C:/somepath/CakeCode/shop/lib/Cake/Model/Datasource/DboSource.php
INFO [org.netbeans.modules.php.dbgp.URIMapper]: class org.netbeans.modules.php.dbgp.URIMapper$1: C:\somepath\CakeCode\shop\app\Plugin\Mongodb\Test\Case\Model\MongodbAssociationsTest.php -> file:///C:/somepath/CakeCode/shop/app/Plugin/Mongodb/Test/Case/Model/MongodbAssociationsTest.php
INFO [org.netbeans.modules.php.dbgp.URIMapper]: class org.netbeans.modules.php.dbgp.URIMapper$1: file:///C:/somepath/CakeCode/xdebug_mongo_crash/test.php -> C:\somepath\CakeCode\xdebug_mongo_crash\test.php
INFO [org.netbeans.modules.php.dbgp.URIMapper]: class org.netbeans.modules.php.dbgp.URIMapper$1: file:///C:/somepath/CakeCode/xdebug_mongo_crash/test.php -> C:\somepath\CakeCode\xdebug_mongo_crash\test.php
INFO [org.netbeans.modules.php.dbgp.URIMapper]: class org.netbeans.modules.php.dbgp.URIMapper$1: file:///C:/somepath/CakeCode/xdebug_mongo_crash/test.php -> C:\somepath\CakeCode\xdebug_mongo_crash\test.php
INFO [org.netbeans.modules.php.dbgp.URIMapper]: class org.netbeans.modules.php.dbgp.URIMapper$1: file:///C:/somepath/CakeCode/xdebug_mongo_crash/test.php -> C:\somepath\CakeCode\xdebug_mongo_crash\test.php
INFO [org.netbeans.modules.php.dbgp.URIMapper]: class org.netbeans.modules.php.dbgp.URIMapper$1: file:///C:/somepath/CakeCode/xdebug_mongo_crash/test.php -> C:\somepath\CakeCode\xdebug_mongo_crash\test.php
INFO [org.netbeans.modules.php.dbgp.URIMapper]: class org.netbeans.modules.php.dbgp.URIMapper$1: file:///C:/somepath/CakeCode/xdebug_mongo_crash/test.php -> C:\somepath\CakeCode\xdebug_mongo_crash\test.php
INFO [org.netbeans.modules.php.dbgp.URIMapper]: class org.netbeans.modules.php.dbgp.URIMapper$1: file:///C:/somepath/CakeCode/xdebug_mongo_crash/test.php -> C:\somepath\CakeCode\xdebug_mongo_crash\test.php
INFO [org.netbeans.modules.php.dbgp.DebugSession]
java.net.SocketException: Connection reset
	at java.net.SocketInputStream.read(Unknown Source)
	at java.net.SocketInputStream.read(Unknown Source)
	at java.net.SocketInputStream.read(Unknown Source)
	at org.netbeans.modules.php.dbgp.packets.DbgpMessage.getDataSize(DbgpMessage.java:297)
	at org.netbeans.modules.php.dbgp.packets.DbgpMessage.create(DbgpMessage.java:126)
	at org.netbeans.modules.php.dbgp.DebugSession.receiveData(DebugSession.java:265)
	at org.netbeans.modules.php.dbgp.DebugSession.sendCommands(DebugSession.java:213)
[catch] at org.netbeans.modules.php.dbgp.DebugSession.run(DebugSession.java:143)
	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)





#######  XDEBUG LOG  ######




#### THIS REQUEST IS WHEN SKIPPING TO THE BREAKPOINT (everything OK)###

#### START SUCCESSFUL REQUEST ####

Log opened at 2013-02-13 07:34:53
I: Connecting to configured address/port: localhost:9000.
I: Connected to client. :-)
-> 

<- feature_set -i 66 -n show_hidden -v 1
-> 

<- feature_set -i 67 -n max_depth -v 3
-> 

<- feature_set -i 68 -n max_children -v 30
-> 

<- feature_get -i 69 -n max_data
-> 

<- step_into -i 70
-> 

<- stack_get -i 71
-> 

<- context_names -i 72
-> 

<- context_get -i 73 -c 0
-> 

<- context_get -i 74 -c 1
-> 

<- breakpoint_set -i 75 -t line -s enabled -f file:///C:/srv/CakeCode/xdebug_mongo_crash/test.php -n 37
-> 

<- run -i 76
-> 

<- stack_get -i 77
-> 

<- context_names -i 78
-> 

<- context_get -i 79 -c 0
-> 

<- context_get -i 80 -c 1
-> 

<- property_get -i 81 -n $breakPointAfterDestroyingCursors
-> 

<- step_over -i 82
-> 

<- stack_get -i 83
-> 

<- context_names -i 84
-> 

<- context_get -i 85 -c 0
-> 

<- context_get -i 86 -c 1
-> 

<- property_get -i 87 -n $breakPointAfterDestroyingCursors
-> 

<- run -i 88
-> 

Log closed at 2013-02-13 07:35:33

#### END SUCCESSFUL REQUEST ####










#### THIS REQUEST THROWS A SOCKET EXCEPTION ####

#### START EXCEPTIONal REQUEST ####

Log opened at 2013-02-13 07:36:16
I: Connecting to configured address/port: localhost:9000.
I: Connected to client. :-)
-> 

<- feature_set -i 89 -n show_hidden -v 1
-> 

<- feature_set -i 90 -n max_depth -v 3
-> 

<- feature_set -i 91 -n max_children -v 30
-> 

<- feature_get -i 92 -n max_data
-> 

<- breakpoint_set -i 93 -t line -s enabled -f file:///C:/srv/CakeCode/xdebug_mongo_crash/test.php -n 37
-> 

<- step_into -i 94
-> 

<- stack_get -i 95
-> 

<- context_names -i 96
-> 

<- context_get -i 97 -c 0
-> 

<- context_get -i 98 -c 1
-> 

<- step_over -i 99
-> 

<- stack_get -i 100
-> 

<- context_names -i 101
-> 

<- context_get -i 102 -c 0
-> 

<- context_get -i 103 -c 1
-> 

<- step_over -i 104
-> 

<- stack_get -i 105
-> 

<- context_names -i 106
-> 

<- context_get -i 107 -c 0
-> 

<- context_get -i 108 -c 1
-> 

<- step_over -i 109
-> 

<- stack_get -i 110
-> 

<- context_names -i 111
-> 

<- context_get -i 112 -c 0
-> 

<- context_get -i 113 -c 1
-> 

<- step_over -i 114
-> 

<- stack_get -i 115
-> 

<- context_names -i 116
-> 

<- context_get -i 117 -c 0
-> 

<- context_get -i 118 -c 1
-> 

<- step_over -i 119
-> 

<- stack_get -i 120
-> 

<- context_names -i 121
-> 

<- context_get -i 122 -c 0
-> 

<- context_get -i 123 -c 1
-> 

<- step_over -i 124
-> 

<- stack_get -i 125
-> 

<- context_names -i 126
-> 

<- context_get -i 127 -c 0