System.Environment.withArgs and friends leak memory
ArgvLeak.hs
:
import System.Environment
main :: IO ()
main = withArgs ["a","b","c"] $ return ()
repro:
> ghc ArgvLeak.hs
[1 of 1] Compiling Main ( ArgvLeak.hs, ArgvLeak.o )
Linking ArgvLeak ...
> valgrind --leak-check=full ./ArgvLeak
==27227== Memcheck, a memory error detector
==27227== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==27227== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==27227== Command: ./ArgvLeak
==27227==
==27227== Warning: set address range perms: large range [0x200000000, 0x600100000) (noaccess)
==27227==
==27227== HEAP SUMMARY:
==27227== in use at exit: 107 bytes in 9 blocks
==27227== total heap usage: 62 allocs, 53 frees, 60,175 bytes allocated
==27227==
==27227== 55 (40 direct, 15 indirect) bytes in 1 blocks are definitely lost in loss record 6 of 6
==27227== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==27227== by 0x470057: stgCallocBytes (RtsUtils.c:107)
==27227== by 0x4652C1: copyArgv (RtsFlags.c:1811)
==27227== by 0x465FAE: setProgArgv (RtsFlags.c:1877)
==27227== by 0x41CC4A: base_SystemziEnvironment_zdLr7BcsetProgArgv_info (in /home/smarlow/scratch/ArgvLeak)
==27227==
==27227== LEAK SUMMARY:
==27227== definitely lost: 40 bytes in 1 blocks
==27227== indirectly lost: 15 bytes in 4 blocks
==27227== possibly lost: 0 bytes in 0 blocks
==27227== still reachable: 52 bytes in 4 blocks
==27227== suppressed: 0 bytes in 0 blocks
==27227== Reachable blocks (those to which a pointer was found) are not shown.
==27227== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==27227==
==27227== For counts of detected and suppressed errors, rerun with: -v
==27227== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
Trac metadata
Trac field | Value |
---|---|
Version | 8.0.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | libraries/base |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |