# Steps to resolve "unable to protect … swift-backtrace … disabling backtracing"?

**URL:** <https://forums.swift.org/t/steps-to-resolve-unable-to-protect-swift-backtrace-disabling-backtracing/72076>\
**Category:** Using Swift\
**Tags:** raspberrypi, linux, backtrace\
**Created:** [May 26, 2024, 4:49am UTC](https://forums.swift.org/t/steps-to-resolve-unable-to-protect-swift-backtrace-disabling-backtracing/72076 "2024-05-26T04:49:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_marc](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/_marc/32/11281_2.png) [@\_marc](https://forums.swift.org/u/_marc)\
**Post date:** [May 26, 2024, 4:49am UTC](https://forums.swift.org/t/steps-to-resolve-unable-to-protect-swift-backtrace-disabling-backtracing/72076/1 "2024-05-26T04:49:51Z")

</div>

What would be the steps needed to resolve "unable to protect … swift-backtrace … disabling backtracing"?

Setup: [Swift Community Apt Repository](https://swiftlang.xyz/) installation of Swift on a Raspberry Pi 5 with Raspberry Pi OS.

Steps: The command `swift --version` is sufficient to invoke the "unable to protect" messages:

```lang-sh
swift --version
#swift runtime: unable to protect path to swift-backtrace at 0x7fff2ffa7000: 22; disabling backtracing.
#swift runtime: unable to protect environment for swift-backtrace at 0x7fff2ff9f000: 22; disabling backtracing.
#swift runtime: unable to protect path to swift-backtrace at 0x7fff8a907000: 22; disabling backtracing.
#swift runtime: unable to protect environment for swift-backtrace at 0x7fff8a8ff000: 22; disabling backtracing.
#swift runtime: unable to protect path to swift-backtrace at 0x7fffafe97000: 22; disabling backtracing.
#swift runtime: unable to protect environment for swift-backtrace at 0x7fffafe8f000: 22; disabling backtracing.
#Swift version 5.10 (swift-5.10-RELEASE)
#Target: aarch64-unknown-linux-gnu

```

Alternately, any pointers on where to reach the right expertise would be appreciated. Links are provided below for other places that I've reached out to:

- GitHub/swift-server/swift-backtrace: ["unable to protect … swift-backtrace … disabling backtracing" #72](https://github.com/swift-server/swift-backtrace/issues/72)
- StackOverflow: [How to resolve "unable to protect" "swift-backtrace"?](https://stackoverflow.com/questions/78534243/how-to-resolve-unable-to-protect-swift-backtrace)

---

<div class="post-metadata">

**Author:** ![al45tair](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/al45tair/32/17985_2.png) [@al45tair](https://forums.swift.org/u/al45tair)\
**Post date:** [July 16, 2024, 9:19am UTC](https://forums.swift.org/t/steps-to-resolve-unable-to-protect-swift-backtrace-disabling-backtracing/72076/2 "2024-07-16T09:19:41Z")

</div>

:-) I'm probably the person to talk to about this. It's happening because the code in the runtime tries to work out at compile time what the page size will be, so that it can declare some static buffers that are page aligned (which they need to be so that `mprotect()` will work on them).

Unfortunately Raspberry Pi OS sets its page size (well, granule size) to 16KB, not the usual 4KB, hence the `mprotect()` calls fail, and without them it isn't safe to use the runtime's backtracer — enabling it would create a security hole — so we emit a message and turn it off.

Equally unfortunately, this isn't exactly trivial to fix. We could make it work for Raspberry Pi OS perhaps by simply pretending that the page size is 16KB for all ARM64 Linux platforms (that won't hurt _too_ much), but it'll still be broken if someone has their system set for 64KB pages. The right fix here might be a custom linker script for the `libswiftCore.so`, not sure.

If you're doing a custom build of Swift just for Raspberry Pi OS, of course, you could just update `SWIFT_PAGE_SIZE` in `swift/include/swift/Runtime/Config.h`.

---

<div class="post-metadata">

**Author:** ![smittytone](https://avatars.discourse-cdn.com/v4/letter/s/9fc348/32.png) [@smittytone](https://forums.swift.org/u/smittytone)\
**Post date:** [February 15, 2025, 2:02pm UTC](https://forums.swift.org/t/steps-to-resolve-unable-to-protect-swift-backtrace-disabling-backtracing/72076/3 "2025-02-15T14:02:19Z")

</div>

FWIW, I compile Swift on the RPi 5 with the `--static-swift-stdlib` flag and while I get runtime grumbling about the backtrace thing during compilation, I don't see the messages when running the generated binary. Better user experience, that, IMHO.

Of course I _now_ get compile warnings like this:

`/home/smitty/.local/usr/lib/swift_static/linux/libFoundationEssentials.a(Data+Writing.swift.o):_ThreadLocal.swift.o:function $s20FoundationEssentials19createTemporaryFile33_FC9EC52B075D2ACCFF86F1C9F84293BELL2at6inPath6prefix7options7variants5Int32V_SStSS_AA0Q5OrURLOSSAA4DataV14WritingOptionsVSSSgtKFTf4nnndn_n: warning: the use of 'mktemp' is dangerous, better use 'mkstemp' or 'mkdtemp'`

---

<div class="post-metadata">

**Author:** ![xtremekforever](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/xtremekforever/32/43018_2.png) [@xtremekforever](https://forums.swift.org/u/xtremekforever)\
**Post date:** [March 16, 2025, 2:07am UTC](https://forums.swift.org/t/steps-to-resolve-unable-to-protect-swift-backtrace-disabling-backtracing/72076/4 "2025-03-16T02:07:56Z")

</div>

We should do a custom build of Swift for Raspberry Pi OS, then! 😃

---

<div class="post-metadata">

**Author:** ![xtremekforever](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/xtremekforever/32/43018_2.png) [@xtremekforever](https://forums.swift.org/u/xtremekforever)\
**Post date:** [December 16, 2025, 2:04am UTC](https://forums.swift.org/t/steps-to-resolve-unable-to-protect-swift-backtrace-disabling-backtracing/72076/5 "2025-12-16T02:04:13Z")

</div>

> [@al45tair](#):
>
> swift/include/swift/Runtime/Config.h

I could probably come up with some builds for Raspberry PI OS versions on aarch64! Just for fun…

---

<div class="post-metadata">

**Author:** ![craig-miller](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/craig-miller/32/45776_2.png) [@craig-miller](https://forums.swift.org/u/craig-miller)\
**Post date:** [June 23, 2026, 1:15am UTC](https://forums.swift.org/t/steps-to-resolve-unable-to-protect-swift-backtrace-disabling-backtracing/72076/6 "2026-06-23T01:15:55Z")

</div>

@al45tair Thanks for the hint!

Confirming your SWIFT\_PAGE\_SIZE suggestion works on Asahi-Gentoo (M1 Pro under linux-asahi,  
CONFIG\_ARM64\_16K\_PAGES=y).

Super simple, just widened the ifdef to cover aarch64 Linux as well:

#if (defined( **APPLE** ) && defined( **arm64** )) ||  
(defined( **linux** ) && defined( **aarch64** ))  
#define SWIFT\_PAGE\_SIZE 16384  
#else  
#define SWIFT\_PAGE\_SIZE 4096  
#endif

After rebuilding Gentoo's source-built Swift (dev-lang/swift) with that applied, swift --version is silent and fatalError() produces a full backtrace.

Packaged as a downstream overlay ebuild so other Asahi-Gentoo users can emerge directly:

- Patch: [zentoo-overlay/dev-lang/swift/files/swift-6.3.1-r1/swift-page-size-aarch64-linux.patch at main · craig-miller/zentoo-overlay · GitHub](https://github.com/craig-miller/zentoo-overlay/blob/main/dev-lang/swift/files/swift-6.3.1-r1/swift-page-size-aarch64-linux.patch)
- Ebuild: [zentoo-overlay/dev-lang/swift/swift-6.3.1-r1.ebuild at main · craig-miller/zentoo-overlay · GitHub](https://github.com/craig-miller/zentoo-overlay/blob/main/dev-lang/swift/swift-6.3.1-r1.ebuild)

Same change should also help Raspberry Pi OS 64-bit and RHEL 9 arm64 if they find this thread like I did.

---

<div class="post-metadata">

**Author:** ![xtremekforever](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/xtremekforever/32/43018_2.png) [@xtremekforever](https://forums.swift.org/u/xtremekforever)\
**Post date:** [July 11, 2026, 8:37pm UTC](https://forums.swift.org/t/steps-to-resolve-unable-to-protect-swift-backtrace-disabling-backtracing/72076/7 "2026-07-11T20:37:42Z")

</div>

It would be sweet to have Swift compiled for arm64 with the 16KB page size...precompiled I mean!
