Skip to content

Hanging test in System.Reflection.Emit.Tests #32177

Closed
mono/mono
#18918

Description

@ViktorHofer

https://dnceng.visualstudio.com/public/_build/results?buildId=517242&view=ms.vss-test-web.build-test-results-tab&runId=16366188&paneView=attachments&resultId=172855

Unsure which test causes the hang.

netcoreapp5.0-OSX-Release-x64-Mono_release-OSX.1014.Amd64.Open

===========================================================================================================
/private/tmp/helix/working/B2510962/w/BAE50A30/e /private/tmp/helix/working/B2510962/w/BAE50A30/e
  Discovering: System.Reflection.Emit.Tests (method display = ClassAndMethod, method display options = None)
  Discovered:  System.Reflection.Emit.Tests (found 399 of 500 test cases)
  Starting:    System.Reflection.Emit.Tests (parallel test collections = on, max threads = 12)

cc @akoeplinger Mono related?

Activity

  1. added
    untriaged
    on Feb 12, 2020
  2. akoeplinger commented on Feb 12, 2020

    @akoeplinger
    Member

    Hard to say whether it's Mono related without more context.

  3. added
    runtime-mono
    on Feb 12, 2020
  4. safern commented on Feb 12, 2020

    @safern
    Member

    Hard to say whether it's Mono related without more context.

    By downloading the test payload, does it repro locally?

  5. akoeplinger commented on Feb 12, 2020

    @akoeplinger
    Member

    Yeah I was able to repro locally with the downloaded payload. It looks like it hangs randomly on different tests though so disabling will be a bit tricky.

    Repro:

    1. Download and unzip https://helixde107v0xdeko0k025g8.blob.core.windows.net/helix-job-34c645ef-68ba-4987-adc2-c4a3edc9f79f3decab90ac24f5da3/System.Reflection.Emit.Tests.zip
    2. Download and unzip https://helixde107v0xdeko0k025g8.blob.core.windows.net/helix-job-34c645ef-68ba-4987-adc2-c4a3edc9f79f3decab90ac24f5da3/test-runtime-netcoreapp5.0-OSX-Release-x64.zip
    3. cd System.Reflection.Emit.Tests && chmod +x RunTests.sh
    4. while [ $? -eq 0 ]; do ./RunTests.sh --runtime-path ../test-runtime-netcoreapp5.0-OSX-Release-x64.zip/ --rsp-file mono.issues.rsp ; done

    Here's a lldb backtrace: https://gist.github.com/akoeplinger/263781cf9b924ef6dcb9b6f9778e9780

    @lambdageek does anthing in that trace look suspicious?

  6. safern commented on Feb 12, 2020

    @safern
    Member

    Can we disable the whole assembly on Mono for the time being? While investigation goes on?

  7. akoeplinger commented on Feb 12, 2020

    @akoeplinger
    Member

    Sure, I can send a PR tomorrow or feel free to do it :)

  8. safern commented on Feb 12, 2020

    @safern
    Member

    I put up: #32201

  9. added
    disabled-test
    on Feb 13, 2020
  10. removed
    untriaged
    on Feb 13, 2020
  11. lambdageek commented on Feb 13, 2020

    @lambdageek
    Member

    @CoffeeFlux Look at @akoeplinger's gist https://gist.github.com/akoeplinger/263781cf9b924ef6dcb9b6f9778e9780

    I think there's a deadlock between thread 12 and thread 16 and the gc initiator (thread 9) because mono_domain_assemblies_lock uses an OS mutex, not a coop mutex. It's near here:

    mono_domain_assemblies_lock (domain);
    domain->domain_assemblies = g_slist_append (domain->domain_assemblies, assembly);
    #ifdef ENABLE_NETCORE
    // TODO: potentially relax the locking here?
    mono_alc_assemblies_lock (alc);
    alc->loaded_assemblies = g_slist_append (alc->loaded_assemblies, assembly);
    mono_alc_assemblies_unlock (alc);
    #endif
    mono_domain_assemblies_unlock (domain);
    register_assembly (mono_object_domain (assemblyb), &assemblyb->assembly, &assembly->assembly);
    MONO_PROFILER_RAISE (assembly_loaded, (&assembly->assembly));
    mono_assembly_invoke_load_hook_internal (alc, (MonoAssembly*)assembly);

    Thread 16 is on line 1382 it is holding the domain lock (an os mutex) and it cooperatively suspended trying to take the ALC lock (a coop mutex).
    Thread 12 is on line 1378 it wants to take the domain lock (an os mutex) and we're in GC Unsafe mode here so we're trying to cooperatively suspend it. But it's stuck because 16 is already suspended and won't let go of the mutex.

    The domain lock should be a coop mutex.

    Also, semi-related in dynamic-image.c

    static mono_mutex_t dynamic_images_mutex;
    static void
    dynamic_images_lock (void)
    {
    mono_os_mutex_lock (&dynamic_images_mutex);
    }
    static void
    dynamic_images_unlock (void)
    {
    mono_os_mutex_unlock (&dynamic_images_mutex);
    }

    The dynamic images lock should also be a coop mutex.

  12. added this to the 5.0 milestone on Feb 13, 2020
  13. CoffeeFlux commented on Feb 14, 2020

    @CoffeeFlux
    Contributor

    We maaaaay have to delay its initialization if so... I need to look through the startup code and see how to handle that. At least if it's initialized too early it should very obviously fail, so it could be worse. Surprised I didn't notice this earlier.

  14. karelz commented on Feb 22, 2020

    @karelz
    Member

    @lambdageek please only 1 area label per issue - see why. Thanks!

  15. added a commit that references this issue on Mar 2, 2020
    80ff881
  16. ghost locked as resolved and limited conversation to collaborators on Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-VM-threading-monodisabled-testruntime-mono

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions