Fix skipWhile/takeWhile on a Map
commit588464c7e8a0cd8464fc98cb8f2c7baa70233a73
authorJosh Watzman <jwatzman@fb.com>
Mon, 18 Jan 2016 10:11:56 +0000 (18 02:11 -0800)
committerhhvm-bot <hhvm-bot@fb.com>
Mon, 18 Jan 2016 10:32:13 +0000 (18 02:32 -0800)
tree87badce45b9fb7ad83fae0fc5dd7edbba27dad9a
parentf423902bcf5db1af6a409fde87945d330000b606
Fix skipWhile/takeWhile on a Map

Summary:
Fixed two cases where we could trip an assert in debug mode (and probably worse in opt mode):

- If skipWhile skipped the entire map, then we'd try to load an element past the end in order to copy into the new map.
- We might need to COW the new map, even though we just allocated it, since the default constructor bases it on a static empty map (which is shared in the request). So we need to call `->set` instead of `->setRaw`, which assumes the COW has already happened if needed.

Fixes https://github.com/facebook/hhvm/issues/6597

Reviewed By: paulbiss

Differential Revision: D2745145

fb-gh-sync-id: 0a3eb004c91e165e88fb5f8fb9b0e6434a6d9249
hphp/runtime/ext/collections/ext_collections-idl.cpp
hphp/test/slow/collection_classes/skip-skipwhile-lazy.php [moved from hphp/test/slow/collection_classes/skip-skipwhile.php with 100% similarity]
hphp/test/slow/collection_classes/skip-skipwhile-lazy.php.expect [moved from hphp/test/slow/collection_classes/skip-skipwhile.php.expect with 100% similarity]
hphp/test/slow/collection_classes/skipwhile-takewhile.php [new file with mode: 0644]
hphp/test/slow/collection_classes/skipwhile-takewhile.php.expectf [new file with mode: 0644]