Crash in Blog.xmlrpcApi when saving a post that was deleted locally (EXC_BAD_ACCESS at 0x48, since 27.2)

未关闭
#26,318 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
ios, swift
领域
databases, mobile

调研方向

Start with PostRepository.swift (_sync, _create, and getRemoteService) and trace how a deleted post reaches Blog.swift's xmlrpcApi getter, checking the related PostServiceRemoteFactory.swift call. Build the Jetpack scheme and follow the reproduction steps using docs/simulator-sign-in.md; done means reporting whether the crash reproduces and, if confirmed, what the investigation establishes about the deleted post and blog.

由索引模型根据 Issue 内容生成。

描述

[Status] Needs Plan [Status] Needs Repro [Type] Crash Core Data Posts + Pages

Likely shares a root cause with #26316, #26317, #26319, #26320. See #26323: posts are deleted locally by a first-page list sync while still in use.

Sentry: JETPACK-IOS-1KJC

Sentry snapshot (as of Oct 30, 2026)

Fatal EXC_BAD_ACCESS: KERN_INVALID_ADDRESS at 0x48. It was first seen Aug 31, 2026, the 27.2 release; Sentry's suspect commit is the release/27.2 merge (#25916). Totals: 114 events from 79 users.

Last 30 days Events Users
27.3 62 41
27.2 7 7

27.3 has about 4.2× as many error-reporting users as 27.2, so 41 against 7 (about 5.9×) is slightly rising. All events are on iPhone, on iOS 26.5 to 27.2. Some users crash repeatedly.

Stack

PostRepository._create (PostRepository.swift:222) → getRemoteService(for: post.blog) (:393) → PostServiceRemoteFactory.forBlog (PostServiceRemoteFactory.swift:14) → Blog.xmlrpcApi.getter (Blog.swift:81) → URL? → crash.

Blog.swift:81 is if _xmlrpcApiEndpoint != endpoint, which reads a Swift stored property. Reading address 0x48 means self is nil: that's a field offset from a nil pointer.

Why it started in 27.2 (hypothesis)
  • The 27.2 change. #25869 (in 27.2) added the _xmlrpcApiEndpoint cache, a Swift stored property read inside the xmlrpcApi getter.
  • How a nil blog reaches it. post.blog is declared non-optional (@NSManaged public var blog: Blog), but Core Data returns nil for it when the post has been deleted. Objective-C calls on a nil blog, like supports(.wpComRESTAPI) and wordPressComRestApi, silently return NO/nil, so forBlog falls through to blog.xmlrpcApi.
  • Before and after. Before 27.2, that getter didn't touch Swift storage, so a nil blog probably came back as nil and PostRepository threw remoteAPIUnavailable. Now it crashes.
  • Why it's _create. A deleted post also reads postID as nil, so _sync takes the create path.
Breadcrumbs (3 events sampled)

Every time, the crash comes right after the user commits a change to a post they opened earlier:

  • Editor → Close → alert → Update (publishButtonTapped)
  • Post Settings opened from Posts search → Cancel → alert → Done
  • Posts search → editor → Close → Move to Trash alert
  • In all three the app went to the background and came back while the post was open, and Posts list syncs ran in between.
  • Two of the three started from Posts search (status=any,trash results).
Candidate code (hypothesis)
  • Same cause as #26317. The post was deleted locally, by a list sync or a trash, while the editor or Post Settings still held it.
  • Fix direction:
    • In PostRepository._sync, _create and getRemoteService, guard post.managedObjectContext != nil && !post.isDeleted.
    • Make forBlog and xmlrpcApi safe against a deleted or nil blog.
Repro to try
  1. Sign in to a self-hosted site with an application password, or to any site where forBlog reaches xmlrpcApi. Use a site with several published posts.
  2. Posts → Search → open a result in the editor, or in Post Settings.
  3. Delete the post locally while it's open: trash it on the web and pull to refresh the Posts list, or background the app long enough for a list sync to purge it.
  4. Tap Update, or Done in Post Settings.
  5. Pass: EXC_BAD_ACCESS in Blog.xmlrpcApi, or a breakpoint in _create showing post.isDeleted == true and post.blog == nil.
Events
  • af200e41c91a4ffe86ff64f393dd5d25
  • dd1b9b7460a84a048da50d1f7e64d6bc
  • c1ac90b2a8de4ec3bed82e4261ace77f
  • 223ecf228a864eaa9a6510c29461b7d3
  • bf039188011e41eaac00138c1d995844

Build the Jetpack scheme and sign in using docs/simulator-sign-in.md, with bundle ID com.automattic.jetpack.

When you're done: post the results here. If you now have reliable steps, remove [Status] Needs Repro. If you found the cause and a fix approach, remove [Status] Needs Plan and add [Status] Ready for Dev. Remove Simulator Testable when you're finished.


Generated by Claude Code

主要语言
Swift
星标
3.9k
派生
1.2k
平均合并
1 天 23 小时
30 天内合并 PR
136

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

wordpress-mobile/WordPress-iOS 的其他 Issue

查看 wordpress-mobile/WordPress-iOS 的全部 Issue

相似的 Issue

更多 Swift Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。