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

Skip to content

Conversation

@akoeplinger
Copy link
Member

As of XCode 11 beta6 the MacOSX SDK defines the MAP_32BIT symbol:

--- /Applications/Xcode11-beta5.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/mman.h    2019-07-25 17:43:49.000000000 -0400
+++ /Applications/Xcode11-beta6.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/mman.h    2019-08-06 21:03:07.000000000 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2019 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  *
@@ -145,6 +145,10 @@
 #define MAP_RESILIENT_CODESIGN  0x2000 /* no code-signing failures */
 #define MAP_RESILIENT_MEDIA     0x4000 /* no backing-store failures */

+#if !defined(CONFIG_EMBEDDED)
+#define MAP_32BIT       0x8000          /* Return virtual addresses <4G only: Requires entitlement */
+#endif  /* !defined(CONFIG_EMBEDDED) */
+
 #endif  /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */

 /*

This causes the mono_valloc() function to try to use the MAP_32BIT flag for mmap().

However as mentioned in the comment for the symbol in mman.h it seems to require a special entitlement which isn't available/documented anywhere yet.
This in turn causes the mmap call to fail presumably because we're missing that entitlement.

Instead we now skip setting this flag on Apple platforms to make mmap() behave like it did before.

…e 11 beta6

As of XCode 11 beta6 the MacOSX SDK defines the MAP_32BIT symbol:

```diff
--- /Applications/Xcode11-beta5.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/mman.h    2019-07-25 17:43:49.000000000 -0400
+++ /Applications/Xcode11-beta6.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/mman.h    2019-08-06 21:03:07.000000000 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2019 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  *
@@ -145,6 +145,10 @@
 #define MAP_RESILIENT_CODESIGN  0x2000 /* no code-signing failures */
 #define MAP_RESILIENT_MEDIA     0x4000 /* no backing-store failures */

+#if !defined(CONFIG_EMBEDDED)
+#define MAP_32BIT       0x8000          /* Return virtual addresses <4G only: Requires entitlement */
+#endif  /* !defined(CONFIG_EMBEDDED) */
+
 #endif  /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */

 /*
```

This causes the mono_valloc() function to try to use the MAP_32BIT flag for mmap().

However as mentioned in the comment for the symbol in mman.h it seems to require a special entitlement
which isn't available/documented anywhere yet.
This in turn causes the mmap call to fail presumably because we're missing that entitlement.

Instead we now skip setting this flag on Apple platforms to make mmap() behave like it did before.
@jaykrell
Copy link
Contributor

Is this 32bit stuff worth much?
Seems like a compat hack to support
Inconplete ports, that truncate pointers.

@lewurm
Copy link
Contributor

lewurm commented Aug 23, 2019

Not sure. We specifically use it on amd64 in the code manager:

#ifdef __x86_64__
#define ARCH_MAP_FLAGS MONO_MMAP_32BIT
#else
#define ARCH_MAP_FLAGS 0
#endif

I guess the idea is to keep it within the 4gb range, so calls/jumps between code can be in a certain limited distance. Removing that could lead to a slight performance regression.

Probably not much, but if it's easily avoidable (that is, we can use the entitlement), we should rather do that.

Is this blocking something or can we wait for Xcode 11 beta 7 (hopefully next week) and see if something has changed?

@lewurm
Copy link
Contributor

lewurm commented Aug 23, 2019

Hmm, maybe it isn't too bad either way:

/* Try to allocate code chunks next to each other to help the VM */
ptr = NULL;
if (last)
ptr = codechunk_valloc ((guint8*)last->data + last->size, chunk_size);
if (!ptr)
ptr = codechunk_valloc (NULL, chunk_size);

We try to keep chunks together anyway.

@akoeplinger
Copy link
Member Author

akoeplinger commented Aug 23, 2019

@lewurm we can certainly wait for beta7, but note that we weren't using this flag on Apple platforms before since earlier Xcode didn't define it and so we defined it to 0, so this should be a no-op.

edit using the hypothetical entitlement would be bad since we'd need to codesign the binary during the build which is a PITA.

@jaykrell
Copy link
Contributor

Agreed no-op and the right direction.

@akoeplinger akoeplinger merged commit 2f2771f into mono:master Aug 26, 2019
@akoeplinger
Copy link
Member Author

@monojenkins backport 2019-08
@monojenkins backport 2019-06
@monojenkins backport 2019-02

@akoeplinger akoeplinger deleted the fix-xcode11beta6 branch August 26, 2019 11:54
@mono mono deleted a comment from monojenkins Aug 26, 2019
@mono mono deleted a comment from monojenkins Aug 26, 2019
@mono mono deleted a comment from monojenkins Aug 26, 2019
@mono mono deleted a comment from monojenkins Aug 26, 2019
akoeplinger added a commit to akoeplinger/mono that referenced this pull request Aug 26, 2019
…e 11 beta6

As of XCode 11 beta6 the MacOSX SDK defines the MAP_32BIT symbol.

This causes the `mono_valloc()` function to try to use the `MAP_32BIT` flag for `mmap()`.

However as mentioned in the comment for the symbol in mman.h it seems to require a special entitlement which isn't available/documented anywhere yet.
This in turn causes the mmap call to fail presumably because we're missing that entitlement.

Instead we now skip setting this flag on Apple platforms to make `mmap()` behave like it did before.

Backport of mono#16441
monojenkins pushed a commit to monojenkins/mono that referenced this pull request Aug 26, 2019
…e 11 beta6

As of XCode 11 beta6 the MacOSX SDK defines the MAP_32BIT symbol.

This causes the `mono_valloc()` function to try to use the `MAP_32BIT` flag for `mmap()`.

However as mentioned in the comment for the symbol in mman.h it seems to require a special entitlement which isn't available/documented anywhere yet.
This in turn causes the mmap call to fail presumably because we're missing that entitlement.

Instead we now skip setting this flag on Apple platforms to make `mmap()` behave like it did before.

Backport of mono#16441
monojenkins pushed a commit to monojenkins/mono that referenced this pull request Aug 26, 2019
…e 11 beta6

As of XCode 11 beta6 the MacOSX SDK defines the MAP_32BIT symbol.

This causes the `mono_valloc()` function to try to use the `MAP_32BIT` flag for `mmap()`.

However as mentioned in the comment for the symbol in mman.h it seems to require a special entitlement which isn't available/documented anywhere yet.
This in turn causes the mmap call to fail presumably because we're missing that entitlement.

Instead we now skip setting this flag on Apple platforms to make `mmap()` behave like it did before.

Backport of mono#16441
akoeplinger added a commit that referenced this pull request Aug 26, 2019
…e 11 beta6 (#16480)

As of XCode 11 beta6 the MacOSX SDK defines the MAP_32BIT symbol.

This causes the `mono_valloc()` function to try to use the `MAP_32BIT` flag for `mmap()`.

However as mentioned in the comment for the symbol in mman.h it seems to require a special entitlement which isn't available/documented anywhere yet.
This in turn causes the mmap call to fail presumably because we're missing that entitlement.

Instead we now skip setting this flag on Apple platforms to make `mmap()` behave like it did before.

Backport of #16441
steveisok pushed a commit that referenced this pull request Aug 26, 2019
…e 11 beta6 (#16482)

As of XCode 11 beta6 the MacOSX SDK defines the MAP_32BIT symbol.

This causes the `mono_valloc()` function to try to use the `MAP_32BIT` flag for `mmap()`.

However as mentioned in the comment for the symbol in mman.h it seems to require a special entitlement which isn't available/documented anywhere yet.
This in turn causes the mmap call to fail presumably because we're missing that entitlement.

Instead we now skip setting this flag on Apple platforms to make `mmap()` behave like it did before.

Backport of #16441
akoeplinger pushed a commit that referenced this pull request Aug 26, 2019
…e 11 beta6 (#16481)

As of XCode 11 beta6 the MacOSX SDK defines the MAP_32BIT symbol.

This causes the `mono_valloc()` function to try to use the `MAP_32BIT` flag for `mmap()`.

However as mentioned in the comment for the symbol in mman.h it seems to require a special entitlement which isn't available/documented anywhere yet.
This in turn causes the mmap call to fail presumably because we're missing that entitlement.

Instead we now skip setting this flag on Apple platforms to make `mmap()` behave like it did before.

Backport of #16441
ManickaP pushed a commit to ManickaP/runtime that referenced this pull request Jan 20, 2020
…e 11 beta6 (mono/mono#16441)

As of XCode 11 beta6 the MacOSX SDK defines the MAP_32BIT symbol:

```diff
--- /Applications/Xcode11-beta5.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/mman.h    2019-07-25 17:43:49.000000000 -0400
+++ /Applications/Xcode11-beta6.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/mman.h    2019-08-06 21:03:07.000000000 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2019 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  *
@@ -145,6 +145,10 @@
 #define MAP_RESILIENT_CODESIGN  0x2000 /* no code-signing failures */
 #define MAP_RESILIENT_MEDIA     0x4000 /* no backing-store failures */

+#if !defined(CONFIG_EMBEDDED)
+#define MAP_32BIT       0x8000          /* Return virtual addresses <4G only: Requires entitlement */
+#endif  /* !defined(CONFIG_EMBEDDED) */
+
 #endif  /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */

 /*
```

This causes the mono_valloc() function to try to use the MAP_32BIT flag for mmap().

However as mentioned in the comment for the symbol in mman.h it seems to require a special entitlement
which isn't available/documented anywhere yet.
This in turn causes the mmap call to fail presumably because we're missing that entitlement.

Instead we now skip setting this flag on Apple platforms to make mmap() behave like it did before.

Commit migrated from mono/mono@2f2771f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants