sparky/perl-Net-Curl — pull request #1 by creaktive (2012-11-04 20:56:26+00:00)
Title: Fixed the leak responsible for the accumulation of unreferenced scalars

The leak occurs due to creation of empty base object inside the XS code. This fix also happens to solve the *"Attempt to free unreferenced scalar: SV 0xdeadbeef during global destruction."* issue.
Modifications:

1. Reimplemented ```t/old-13slowleak.t``` as ```t/96-leak.t```, using *Devel::Leak*. It now runs 10_000 iterations instead of 200. However, it's still fast, as the downloaded URL is ```"file:///$Bin/$Script"``` (by default). This was required to spot the problem.
2. Updated ```Makefile.PL``` so *pkg-config* is now able to detect *libcurl* in non-standard locations (like *$HOME*). This was required for me to deploy test cases on multiple *perlbrew*-based installations.
3. Updated ```inc/symbols-in-versions``` from *libcurl/7.28.0* and created a ```.gitignore``` file. Not actually required to fix the leak, but hell, why not? :)
4. The fix itself: in ```Curl.xs```, *HASHREF_BY_DEFAULT* definition was updated, reverting the order of *newRV_noinc()* / *sv_2mortal()*.

The dismissal of **"Attempt to free unreferenced scalar..."* warning can be verified via *Net::Curl::Simple* test suite; while using the original *Net::Curl*, it repeatedly produces the aforementioned message:
```
...
t/42-coro-anyevent.t ..... 1/20 Please rebuild libcurl with AsynchDNS to avoid blocking DNS requests
# loaded implementation: Net/Curl/Simple/Async/AnyEvent.pm
Attempt to free unreferenced scalar: SV 0x7fa88b964378 during global destruction.
t/42-coro-anyevent.t ..... ok
...
```
I also "smoked" the patched *Net::Curl* on a reasonably large crawler system (which processes over 1 million HTML-pages every 24 hours) no unexpected behavior was detected.