core icon indicating copy to clipboard operation
core copied to clipboard

C# (7.0) Leak with Address Sanitizer when it fails to load a script

Open viferga opened this issue 2 years ago • 0 comments

🐛 Bug Report

This test has a suppresion, but it should be reviewed carefully: https://github.com/metacall/core/blob/85ecba341a6f724dfd85e540e522016be52c428d/source/tests/sanitizer/lsan.supp#L37

Some reference: https://carljohansen.wordpress.com/2020/05/09/compiling-expression-trees-with-roslyn-without-memory-leaks-2/ https://stackoverflow.com/questions/27266907/no-appdomains-in-net-core-why https://learn.microsoft.com/en-us/dotnet/api/system.runtime.loader.assemblyloadcontext.loadfromstream?view=net-7.0 https://github.com/dotnet/docs/blob/main/docs/fundamentals/syslib-diagnostics/syslib0024.md https://github.com/carljohansen/miscellaneous/blob/8cd82e02c222900fe99545fb155a79c015b7c028/SearchFilterCompiler.cs#L54

63: ==13145==ERROR: LeakSanitizer: detected memory leaks
63: 
63: Direct leak of 53734912 byte(s) in 166 object(s) allocated from:
63:     #0 0x7fb4f6b57c47 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
63:     #1 0x7fb4713f3608  (/usr/share/dotnet/shared/Microsoft.NETCore.App/7.0.2/System.Private.CoreLib.dll+0x273608)
63:     #2 0x7fb4725f1787  (/usr/share/dotnet/shared/Microsoft.NETCore.App/7.0.2/System.Reflection.Metadata.dll+0x61787)
63:     #3 0x7fb4725abbf0  (/usr/share/dotnet/shared/Microsoft.NETCore.App/7.0.2/System.Reflection.Metadata.dll+0x1bbf0)
63:     #4 0x7fb471e0a05a  (/memfd:doublemapper (deleted)+0x20b05a)
63:     #5 0x7fb471e09cf0  (/memfd:doublemapper (deleted)+0x20acf0)
63:     #6 0x7fb471e08ee9  (/memfd:doublemapper (deleted)+0x209ee9)
63:     #7 0x7fb471e08e4f  (/memfd:doublemapper (deleted)+0x209e4f)
63:     #8 0x7fb4722bac8e  (/usr/share/dotnet/shared/Microsoft.NETCore.App/7.0.2/System.Linq.dll+0x1ac8e)
63:     #9 0x7fb471dd5163  (/memfd:doublemapper (deleted)+0x1d6163)
63:     #10 0x7fb4749e3557  (/memfd:doublemapper (deleted)+0x1a54557)
63:     #11 0x7fb4749e349b  (/memfd:doublemapper (deleted)+0x1a5449b)
63:     #12 0x7fb471dd0ac6  (/memfd:doublemapper (deleted)+0x1d1ac6)
63:     #13 0x7fb4f1f98229 in netcore::load_source(char const*) /metacall-core/source/loaders/cs_loader/source/netcore.cpp:167
63:     #14 0x7fb4f1f99131 in simple_netcore_load_script_from_memory /metacall-core/source/loaders/cs_loader/source/simple_netcore.cpp:84
63:     #15 0x7fb4f1f9458d in cs_loader_impl_load_from_memory /metacall-core/source/loaders/cs_loader/source/cs_loader_impl.c:292
63:     #16 0x7fb4f6047890 in loader_impl_load_from_memory /metacall-core/source/loader/source/loader_impl.c:975
63:     #17 0x7fb4f603eeed in loader_load_from_memory /metacall-core/source/loader/source/loader.c:338
63:     #18 0x7fb4f604d59c in metacall_load_from_memory /metacall-core/source/metacall/source/metacall.c:357
63:     #19 0x55d5221c4dbc in metacall_cs_test_Fail_Test::TestBody() /metacall-core/source/tests/metacall_cs_test/source/metacall_cs_test.cpp:99
63:     #20 0x55d522217ce8 in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (/metacall-core/build/metacall-cs-testd+0x123ce8)
63:     #21 0x55d52220faa0 in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (/metacall-core/build/metacall-cs-testd+0x11baa0)
63:     #22 0x55d5221e417d in testing::Test::Run() (/metacall-core/build/metacall-cs-testd+0xf017d)
63:     #23 0x55d5221e4bbf in testing::TestInfo::Run() (/metacall-core/build/metacall-cs-testd+0xf0bbf)
63:     #24 0x55d5221e54b6 in testing::TestSuite::Run() (/metacall-core/build/metacall-cs-testd+0xf14b6)
63:     #25 0x55d5221f4ddc in testing::internal::UnitTestImpl::RunAllTests() (/metacall-core/build/metacall-cs-testd+0x100ddc)
63:     #26 0x55d5222191da in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) (/metacall-core/build/metacall-cs-testd+0x1251da)
63:     #27 0x55d522210cee in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) (/metacall-core/build/metacall-cs-testd+0x11ccee)
63:     #28 0x55d5221f354b in testing::UnitTest::Run() (/metacall-core/build/metacall-cs-testd+0xff54b)
63:     #29 0x55d5221b356e in RUN_ALL_TESTS() /metacall-core/build/source/tests/src/google-test-depends/googletest/include/gtest/gtest.h:2490
63:     #30 0x55d5221b356e in main /metacall-core/source/tests/metacall_cs_test/source/main.cpp:28
63: 
63: SUMMARY: AddressSanitizer: 53734912 byte(s) leaked in 166 allocation(s).

viferga avatar Jan 31 '23 19:01 viferga