Fix twital re-record - test find mode bad

Summary: refs facebook/hhvm#3381

Reviewed By: @JoelMarcey

Differential Revision: D1481847
unflakey md5 and sha1 test

Summary: failed on D1479623?vs=on&id=4750825&whitespace=ignore-all#toc

Reviewed By: @fredemmott

Differential Revision: D1482115
Lint fixes for man page

Summary: See rrh code review: https://github.com/facebook/hhvm/commit/e32f5bf0cc7a74d671c6922108c68bfbdfdbe1f4

Thanks rrh

Reviewed By: @fredemmott

Differential Revision: D1481918
Return false in fscanf if the file is empty

Summary: This will fix #3352.
Closes https://github.com/facebook/hhvm/pull/3364

Reviewed By: @LiraNuna

Differential Revision: D1478505

Pulled By: svcscm
hphp: placate newer clang regarding non-local lambda expressions

Summary: * hphp/hhbbc/test/type-system.cpp: Several non-local lambda
expressions needlessly used [&] ("capture-default").  Remove
the "&".  Here's a sample diagnostic:
  hphp/hhbbc/test/type-system.cpp:169:44: error: non-local lambda\
    expression cannot have a capture-default
  auto const test_empty_array = folly::lazy([&] {

For reference, here's the relevant part of the standard:
  C++11 [expr.prim.lambda]p9:
    A lambda-expression whose smallest enclosing scope is a block scope
    is a local lambda expression; any other lambda expression shall not
    have a capture-default or simple-capture in its lambda-introducer.

Reviewed By: @alexmalyshev

Differential Revision: D1482394
Don't #include libelf on OS X

Summary: We don't need libelf includes on OS X here; we have our own
implementation on Mach-O. Actually including the headers is annoying --
for compatibility reasons, OS X package managers to build libelf in
"disable compat" mode, which doesn't install these headers in
/usr/include, so you need to do `-I/foo/bar/libelf` -- but `libelf.h`
itself does a `#include <libelf/libelf.h>` so you //also// need
`-I/foo/bar` if `/foo/bar` isn't a standard include directory (again
common on OS X).

But this whole thing should be moot, we don't need it, just move it
under ifdef.

Reviewed By: @ptarjan

Differential Revision: D1482087
Kill JmpFlagBothPaths flag

Summary: Instead, just check if a block exists for that offset.
Also, clean up some stuff that became unnecessary.

Reviewed By: @swtaarrs

Differential Revision: D1478708
Fix bug in cgLoad

Summary: If the type is a subtype of Null, we early-exit. We already
detect the dead-load situation, and type of {InitNull|Uninit}
should go down the cgLoadTypedValue case, which should correctly
load.

Now that I look more closely I don't think this is a bug,
but the code was misleading.

Reviewed By: @swtaarrs

Differential Revision: D1478816
Rename JmpFlagBreakTracelet to JmpFlagEndsRegion

Summary: That's it.

Reviewed By: @alexmalyshev

Differential Revision: D1482019
Remove unnecessary abstraction from fastcgi server

Summary: I did this while trying to make sense of the current setup. The
ProtocolSession class didn't appear to serve any purpose so it's been collapsed
into the only subclass. I've also added brief descriptions of most classes
describing their role in the server, and made a few other cleanup tweaks.

Reviewed By: @ptarjan

Differential Revision: D1476104
Properly shut down fastcgi worker threads when connection is closed

Summary: If the fastcgi connection from the webserver was closed while a
request was reading its POST data, the worker thread processing that request
would get stuck indefinitely waiting for the rest of the data to arrive. Given
enough time, all worker threads in the server could get stuck, causing the
server to become completely unresponsive until a restart. Make sure we notify
the appropriate condition variable to avoid this.

Reviewed By: @ptarjan

Differential Revision: D1476306
Flakeylist mediawiki base conversion test

Summary: Becamse flakey with gmp extension. Same issue exists in PHP5 with gmp conversion - for example:

```
<?php
$in = '0x1234567890abhaer';
$gmp = gmp_init($in, 36);
$val = gmp_strval($gmp, 36);
var_dump(str_pad($val, strlen($in), '0', STR_PAD_LEFT));
```

https://bugzilla.wikimedia.org/show_bug.cgi?id=69249

Reviewed By: @JoelMarcey

Differential Revision: D1482806
Get rid of static Hdf instance in RuntimeOption.

Summary: Resubmitting D1458015.
Avoid constructing static Hdf instance in RuntimeOption.
Instead, registered a call back function in RuntimeOption ("HookOption")
which is called in Load().

Reviewed By: @markw65

Differential Revision: D1480544
Clownlist doctrine2 test that also fails on php5

Summary: refs facebook/hhvm#3375

```
Exception: [Doctrine\Common\Proxy\Exception\OutOfBoundsException] Missing value for primary key id on Doctrine\Tests\Models\CMS\CmsUser

With queries:
18. SQL: '"COMMIT"' Params:
17. SQL: 'INSERT INTO cms_users (status, username, name, email_id) VALUES (?, ?, ?, ?)' Params: '', 'ocramius', 'Marco', ''
16. SQL: '"START TRANSACTION"' Params:
15. SQL: 'CREATE TABLE cms_groups (id INTEGER NOT NULL, name VARCHAR(50) NOT NULL, PRIMARY KEY(id))' Params:
14. SQL: 'CREATE TABLE cms_emails (id INTEGER NOT NULL, email VARCHAR(250) NOT NULL, PRIMARY KEY(id))' Params:
13. SQL: 'CREATE UNIQUE INDEX UNIQ_ACAC157BA76ED395 ON cms_addresses (user_id)' Params:
12. SQL: 'CREATE TABLE cms_addresses (id INTEGER NOT NULL, user_id INTEGER DEFAULT NULL, country VARCHAR(50) NOT NULL, zip VARCHAR(50) NOT NULL, city VARCHAR(50) NOT NULL, PRIMARY KEY(id), CONSTRAINT FK_ACAC157BA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id) NOT DEFERRABLE INITIALLY IMMEDIATE)' Params:
11. SQL: 'CREATE INDEX IDX_D533FD95A76ED395 ON cms_articles (user_id)' Params:
10. SQL: 'CREATE TABLE cms_articles (id INTEGER NOT NULL, user_id INTEGER DEFAULT NULL, topic VARCHAR(255) NOT NULL, text CLOB NOT NULL, version INTEGER DEFAULT 1 NOT NULL, PRIMARY KEY(id), CONSTRAINT FK_D533FD95A76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id) NOT DEFERRABLE INITIALLY IMMEDIATE)' Params:
9. SQL: 'CREATE INDEX IDX_F21F790FA76ED395 ON cms_phonenumbers (user_id)' Params:
8. SQL: 'CREATE TABLE cms_phonenumbers (phonenumber VARCHAR(50) NOT NULL, user_id INTEGER DEFAULT NULL, PRIMARY KEY(phonenumber), CONSTRAINT FK_F21F790FA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id) NOT DEFERRABLE INITIALLY IMMEDIATE)' Params:
7. SQL: 'CREATE INDEX IDX_7EA9409AFE54D947 ON cms_users_groups (group_id)' Params:
6. SQL: 'CREATE INDEX IDX_7EA9409AA76ED395 ON cms_users_groups (user_id)' Params:
5. SQL: 'CREATE TABLE cms_users_groups (user_id INTEGER NOT NULL, group_id INTEGER NOT NULL, PRIMARY KEY(user_id, group_id), CONSTRAINT FK_7EA9409AA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_7EA9409AFE54D947 FOREIGN KEY (group_id) REFERENCES cms_groups (id) NOT DEFERRABLE INITIALLY IMMEDIATE)' Params:
4. SQL: 'CREATE UNIQUE INDEX UNIQ_3AF03EC5A832C1C9 ON cms_users (email_id)' Params:
3. SQL: 'CREATE UNIQUE INDEX UNIQ_3AF03EC5F85E0677 ON cms_users (username)' Params:
2. SQL: 'CREATE TABLE cms_users (id INTEGER NOT NULL, email_id INTEGER DEFAULT NULL, status VARCHAR(50) DEFAULT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id), CONSTRAINT FK_3AF03EC5A832C1C9 FOREIGN KEY (email_id) REFERENCES cms_emails (id) NOT DEFERRABLE INITIALLY IMMEDIATE)' Params:
```

Reviewed By: @JoelMarcey

Differential Revision: D1482260
Added xdebug server setup code

Summary: This diff adds a class "XDebugServer" that represents an xdebug remote
debugging server. The server is attached and detached in `ext_xdebug.cpp`
similar to the `XDebugProfiler`.

This diff also adds support for taking in config settings using the
environment variable `XDEBUG_CONFIG`. This is necessary for supporting
all the server options php5 xdebug does.

I've also changed the request local data to be thread local. Attaching
the server (in the next diff) revealed some bugs in the current
implementation.

Depends on D1471865.

Reviewed By: @ptarjan

Differential Revision: D1472286
Make sure to free memory used for CodeGenFixups

Summary: std::vector::clear() doesn't reduce its capacity.
Use the swap trick instead.

Some of these are maps or sets, so don't really need this treatment,
but we could change representations, so easier to just do all of them.

Reviewed By: @swtaarrs

Differential Revision: D1481874
Fix bug with idx() for the HHVM open source build

Summary: An assertion (func != nullptr) triggers on the HHVM OSS build when idx() is
not defined and an <?hh file tries to call idx().

This diff fixes the issue by updating the bytecode emitter so that it only
emits the Idx instruction if systemlib defines idx().

Reviewed By: @sgolemon

Differential Revision: D1474391
Fix places where kStrMapKind was not a case along with kIntMapKind and kMixedKind

Reviewed By: @paroski

Differential Revision: D1483939
Make the logic for raising checked array warnings clearer

Summary: Make it explcit in places that we are raising warnings because the templated
array kind is either `kIntMapKind` or `kStrMapKind`. The `!= kMixedKind` checks
should be reserved for behavior that both `kIntMapKind` and `kStrMapKind` should
exhibit.

It worked previously because in array-data.cpp we don't ever instantiate the
templated version with the "wrong" kind because of the different DISPATCH_XXX
macros.

Reviewed By: @elgenie

Differential Revision: D1478372
Checked map-like arrays should not warn for array_merge

Summary: Renumber is only called in the following places:

* array-common.cpp | ArrayCommon::Dequeue | Remove key then renumber (dequeue should already warn/downgrade and is only used by APCLocalArray and NVTWrapper)
* empty-array.cpp | EmptyArray::Merge | Calls MixedArray::Copy(elems) then renumber them (array_merge shouldn't warn)
* type-array.cpp | Array::mergeImpl | If rhs is empty, m_px->renumber() (array_merge shouldn't warn)

In all the places, we don't need to raise a warning, and in fact we don't want
to. This was an oversight by yours truly.

If we do want to raise warnings at a later point (since array_merge does not
support Collections) the proper way to do it would be in f_array_merge, but not
in ::Renumber.

Reviewed By: @elgenie

Differential Revision: D1478885