Fixed the leak responsible for the accumulation of unreferenced scalars #1

merged 13 commits into from May 6, 2013


None yet
2 participants

creaktive commented Nov 4, 2012

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.

  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/
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.

dolmen commented Dec 25, 2012

Reverse link to RT#81053

@creaktive creaktive added a commit that referenced this pull request May 6, 2013

@creaktive creaktive Merge pull request #1 from creaktive/master
Fixed the leak responsible for the accumulation of unreferenced scalars

@creaktive creaktive merged commit ccddffe into sparky:master May 6, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment