Commit 4519036
authored
Route Module.loadMethod through makeExecutorchException for native log enrichment (pytorch#20191)
Summary:
`Module.loadMethod` directly constructs `ExecutorchRuntimeException`,
bypassing the `makeExecutorchException` factory that enriches error
details with the native log tail (added in D107196396). As a result, the
high-volume SceneX XNNPACK 0x12 `loadMethod` failures (`[ExecuTorch
Error 0x12] Invalid argument: Failed to load method: forward`) never
capture native diagnostic context — `nativeLog=` never appears in
Scuba/QPL data.
Route the throw through the factory so these failures get the native log
tail for triage. The change is applied to both the `xplat` and `fbcode`
copies of `Module.kt` to keep them in sync, mirroring how D107196396
edited both copies of `ExecutorchRuntimeException.kt`.
For error code 0x12 (`INVALID_ARGUMENT`), `makeExecutorchException`
returns `ExecutorchInvalidArgumentException`, a subclass of
`ExecutorchRuntimeException` that carries the same `errorCode`, so
existing `catch (ExecutorchRuntimeException)` and `getErrorCode()`
consumers are unaffected. The enrichment runs only on the failure path
(not per-call) and uses the static `readLogBufferStatic` JNI read, which
takes a separate native mutex, so it does not re-enter the `mLock` held
by `loadMethod`. The change is additive: when no native logs are
available the message is byte-identical to today's.
This was authored with assistance from Claude.
Reviewed By: SS-JIA
Differential Revision: D1081546061 parent 97c153f commit 4519036
1 file changed
Lines changed: 2 additions & 1 deletion
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
| 92 | + | |
| 93 | + | |
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
| |||
0 commit comments