<!--
{
  "documentType" : "article",
  "framework" : "Xcode",
  "identifier" : "/documentation/Xcode/EXC_GUARD",
  "metadataVersion" : "0.1.0",
  "role" : "article",
  "title" : "EXC_GUARD"
}
-->

# EXC_GUARD

The process violated a guarded resource protection, often related to file descriptors.

## Discussion

There are multiple types of guarded system resources,
however most guarded resource crashes
are from guarded file descriptors, which have the `GUARD_TYPE_FD` value in the `Exception Subtype` field.
The operating system marks a file descriptor as guarded so that normal
file descriptor APIs can’t modify them. For example, if an app closes the file descriptor
used to access the SQLite file backing a <doc://com.apple.documentation/documentation/CoreData>
store, <doc://com.apple.documentation/documentation/CoreData> could mysteriously
crash much later on. The guard file description identifies these problems when they
happen, making them easier to identify and address.

The `Exception Message` field contains the specific violation:

- `CLOSE`: The process attempted to invoke `close()` on a guarded file descriptor.
- `DUP`: The process attempted to invoke `dup()`, `dup2()`, or `fcntl()` with the
  `F_DUPFD` or `F_DUPFD_CLOEXEC` commands on a guarded file descriptor.
- `NOCLOEXEC`: The process attempted to remove the `FD_CLOEXEC` flag from a guarded
  file descriptor.
- `SOCKET_IPC`: The process attempted to send a guarded file descriptor through a
  socket.
- `FILEPORT`: The process attempted to obtain a Mach send right for a guarded file
  descriptor.
- `WRITE`: The process attempted to write to a guarded file descriptor.

The `Exception Message` field also identifies the specific guarded file descriptor
that the process attempted to modify. To understand the context triggering this exception,
consult the backtrace of the crashed thread.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)