Skip to content

VM #define Sleep macros break GC #7959

Closed

Description

@sdmaclea

In various places, the VM introduces #define Sleep(a) Dont_Use_Sleep(a). These are troublesome for the GC which has to introduce a workaround.

Per @jkotas "this hack made sense for full .NET Framework. It is not really valuable for CoreCLR. I would rather delete all the code to #define Sleep to prevent people from using it."

My tip has these #define for Sleep in headers...

src/gc/gc.h:// This is a funny workaround for the fact that "common.h" defines Sleep to be
src/gc/gc.h:// However, GCToOSInterface defines a function called Sleep, which (due to this define) becomes
src/inc/clrhost.h:#define Sleep(dwMilliseconds) \
src/vm/comsynchronizable.h:#define Sleep(a) Dont_Use_Sleep(a)
src/vm/ecalllist.h:#define Sleep(a) Dont_Use_Sleep(a)

Activity

  1. transferred this issue fromdotnet/coreclron Jan 31, 2020
  2. added this to the Future milestone on Jan 31, 2020
  3. mangod9 commented on Sep 22, 2020

    @mangod9
    Member

    @sdmaclea this appears to be fixed, or is this still a concern?

  4. sdmaclea commented on Sep 22, 2020

    @sdmaclea
    ContributorAuthor

    Looks like it is still a concern.

    ~/git/runtime$ git grep '#define *Sleep' origin/master
    origin/master:src/coreclr/src/vm/comsynchronizable.cpp:#define Sleep(dwMilliseconds) Dont_Use_Sleep(dwMilliseconds)
    origin/master:src/coreclr/src/vm/comsynchronizable.h:#define Sleep(a) Dont_Use_Sleep(a)
    origin/master:src/coreclr/src/vm/ecalllist.h:#define Sleep(a) Dont_Use_Sleep(a)
    origin/master:src/coreclr/src/vm/hosting.cpp:#define SleepEx(dwMilliseconds,bAlertable) \
    origin/master:src/coreclr/src/vm/threads.cpp:#define Sleep(a) Dont_Use_Sleep(a)
    origin/master:src/coreclr/src/vm/threadsuspend.cpp:#define Sleep(a) Dont_Use_Sleep(a)
    origin/master:src/coreclr/src/vm/win32threadpool.cpp:#define SleepEx(a,b) Dont_Use_SleepEx(a,b)
    origin/master:src/coreclr/src/vm/win32threadpool.cpp:                #define SleepEx(a,b) Dont_Use_SleepEx(a,b)
    origin/master:src/coreclr/src/vm/win32threadpool.cpp:#define SleepEx(a,b) Dont_Use_SleepEx(a,b)
    
  5. mangod9 commented on Sep 22, 2020

    @mangod9
    Member

    I meant I didnt see the workaround you mention in gc.h. Perhaps it should be moved to vm area then?

  6. sdmaclea commented on Sep 22, 2020

    @sdmaclea
    ContributorAuthor

    Done

  7. modified the milestones: Future, 6.0.0 on Sep 22, 2020
  8. modified the milestones: 6.0.0, 7.0.0 on Jul 21, 2021
  9. ghost added
    in-pr
    on Jun 17, 2022
  10. ghost removed
    in-pr
    on Jun 17, 2022
  11. ghost locked as resolved and limited conversation to collaborators on Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions