Skip to content

Crst Level Violation on rundown event emit #643

Closed

Description

@sywhang

Started seeing this Crst violation on rundown in debug builds of the runtime:

Assert failure(PID 23572 [0x00005c14], Thread: 18100 [0x46b4]): Consistency check failed: Crst Level violation: Can't take level 7 lock CrstEtwTypeLogHash because you already holding level 5 lock CrstSingleUseLock
FAILED: false

CORECLR! CHECK::Trigger + 0x297 (0x00007ffd`d6041ef7)
CORECLR! CrstBase::IsSafeToTake + 0x695 (0x00007ffd`d6143055)
CORECLR! CrstBase::Enter + 0x24B (0x00007ffd`d614241b)
CORECLR! CrstBase::AcquireLock + 0x2A (0x00007ffd`d60cb02a)
CORECLR! CrstBase::CrstHolder::CrstHolder + 0x3A (0x00007ffd`d60c9bda)
CORECLR! ETW::TypeSystemLog::AddTypeToGlobalCacheIfNotExists + 0x1A0 (0x00007ffd`d615e990)
CORECLR! ETW::TypeSystemLog::LookupOrCreateTypeLoggingInfo + 0x719 (0x00007ffd`d6182cd9)
CORECLR! ETW::TypeSystemLog::ShouldLogType + 0x1C7 (0x00007ffd`d6191fa7)
CORECLR! ETW::TypeSystemLog::LogTypeAndParametersIfNecessary + 0x2AD (0x00007ffd`d6180d2d)
CORECLR! ETW::MethodLog::SendMethodDetailsEvent + 0x2D7 (0x00007ffd`d618d1b7)
    File: E:\runtime\src\coreclr\src\vm\crst.cpp Line: 761

Activity

  1. self-assigned this
    on Dec 6, 2019
  2. added
    untriaged
    on Dec 6, 2019
  3. changed the title [-]Crst Level Violation on rundown[/-] [+]Crst Level Violation on rundown event emit[/+] on Dec 6, 2019
  4. removed
    untriaged
    on Dec 6, 2019
  5. sywhang commented on Jan 11, 2020

    @sywhang
    ContributorAuthor

    Updating the thread with some more info I found while investigating this issue...

    The root cause of this is dotnet/coreclr#27515. The new MethodDetails event tries to take the TypeHash lock when it tries to add a type to the cache we have for emitting type data in rundown, but it does that while holding the CodeHeapIterator lock which is a SingleUseLock, so there is this violation.

    As far as I can see, there isn't really a "good" way to fix this in the short run. A potential solution is to emit these events without storing the type in the cache, but that'll be really slow when we're not under rundown (this event will get called during assembly unload as well).

    I will come back to this later since this isn't really blocking any product development.

  6. added this to the 5.0 milestone on Feb 26, 2020
  7. janvorli commented on Mar 10, 2020

    @janvorli
    Member

    I am now hitting this locally in any attempt to run coreclr tests with a checked or debug build of runtime on OSX and Linux. I have a clean build of the current master. All tests are failing with this assert. I wonder how is it possible that we are not hitting it in the CI.

  8. sywhang commented on Mar 18, 2020

    @sywhang
    ContributorAuthor

    I am now hitting this locally in any attempt to run coreclr tests with a checked or debug build of runtime on OSX and Linux. I have a clean build of the current master. All tests are failing with this assert. I wonder how is it possible that we are not hitting it in the CI.

    Do you know if you have any eventing turned on? As far as I know there aren’t any tests that turn on the keywords necessary to hit this issue.

  9. kunalspathak commented on Mar 19, 2020

    @kunalspathak
    Contributor

    Same here. I am getting this once in a while when trying to collect profile information using perfcollect on linux arm64 and dotnet-trace on windows arm64.

  10. janvorli commented on Mar 19, 2020

    @janvorli
    Member

    @sywhang I have looked at the tests/runtest.sh and it enables event logging by default. I've just found that the tests are not failing if I execute them individually using their .sh files. But if I run them all using ./tests/runtest.sh --coreOverlayDir=/home/janvorli/git/runtime/artifacts/tests/coreclr/Linux.x64.Debug/Tests/Core_Root --testNativeBinDir=/home/janvorli/git/runtime/artifacts/obj/coreclr/Linux.x64.Debug/tests --testRootDir=/home/janvorli/git/runtime/artifacts/tests/coreclr/Linux.x64.Debug --copyNativeTestBin Debug (launched from the src/coreclr), then they fail.

  11. CarolEidt commented on May 7, 2020

    @CarolEidt
    Contributor

    I am also seeing this in my test runs on x64/ux. I had 61 instances of this in a test run with no changes.

  12. kg commented on May 15, 2020

    @kg
    Contributor

    When I do test runs on Linux right now from a clean source checkout I get a ton of these errors in various tests. I'm also using runtest.sh with the recommended arguments.

    Consistency check failed: Crst Level violation: Can't take level 7 lock CrstEtwTypeLogHash because you already holding level 5 lock CrstSingleUseLock

  13. CarolEidt commented on May 18, 2020

    @CarolEidt
    Contributor

    I see this on both x64/ux and arm64/ux. Thanks to the hint from @janvorli I added --disableEventLogging to my test run. It still reports them as failures at the end of the output, but not in the rolled-up results, making it much easier to figure out where any new failures are.
    FWIW, even though this is not "really blocking any product development", it is pretty painful to deal with.

  14. echesakov commented on May 21, 2020

    @echesakov
    Contributor

    Carol brought to my attention the question Jan asked:

    All tests are failing with this assert. I wonder how is it possible that we are not hitting it in the CI.

    I would like to answer: we never set COMPlus_EnableEventLog in our Helix runs and the CI doesn't use runtest.sh that sets this variable to 1.

    I wonder thought if want to enable the event log in our CI (maybe, in a separate test scenario) so we can catch issues like this?

  15. sywhang commented on Jun 3, 2020

    @sywhang
    ContributorAuthor

    This issue should now be fixed with #36932.

  16. ghost locked as resolved and limited conversation to collaborators on Dec 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions