Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
viferga opened this issue Jan 31, 2023 · 0 comments
Open

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

viferga opened this issue Jan 31, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@viferga
Copy link
Member

viferga commented Jan 31, 2023

🐛 Bug Report

This test has a suppresion, but it should be reviewed carefully:

# TODO: Implement assembly unloading with loader context

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 viferga added the bug Something isn't working label Jan 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant