Thanks to visit codestin.com
Credit goes to github.com

Skip to content

mono_jit_init on macOS 10.14 has graphics corruption due to mprotect invocation #10802

@chamons

Description

@chamons

This issue comes from the investigation of: dotnet/macios#4509

There is a regression in macOS 10.14 where if all the following are true for me:

  • Building with Xcode10GM
  • Running on macOS 10.14
  • Launching from Finder or via "open" on the command line
  • In a project with a xib not a storyboard as the main entry point

AppKit starts drawing corrupted graphics.

If any of those preconditions are false, say launching from Xcode instead of Finder\open, everything appears to draw fine but sometimes later strange drawing behavior creeps in anyway.

I've tracked it down to a single mprotect call in startup after @lemonmojo did some amazing work and tracked it down to just mono_jit_init ().

I've filed radar://44763485 on this, but mono may need to implement some sort of work around.

Steps to Reproduce

  1. Unzip MProtectMadness_WithMono.zip
  2. cd MProtectMadness
    2 (a). You may need to open MProtectMadness.xcodeproj and change signing keys
  3. rm -fr build/ && xcodebuild -project MProtectMadness.xcodeproj/
  4. open ./build/Release/MProtectMadness.app

The built in screenshot tool doesn't correctly capture what's on the screen, but you should see a ghost outline of a modal dialog that is not painting correctly.

Hitting escape will break you out of it and let you close the main window \ quit.

A single mono_jit_init call or mprotect with some math I stole from the mono startup sequence both trigger it exactly the same. See USE_MONO define in sample.

MProtectMadness_WithMono.zip

Current Behavior

Trigger strange AppKit drawing bug.

Expected Behavior

Work around said brokeness

On which platforms did you notice this

[x] macOS
[ ] Linux
[ ] Windows

Version Used:

I've reproduced this on mono 5.12, 5.16, and 5.19 (master 3 commits ago today), and a local mono build at a90249f.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions