Repository navigation
Commit 00c3ee2
Stop OpenSfM feature bindings killing the interpreter on a C++ throw
Summary:
An exception escaping these bindings reaches `std::terminate` and takes the whole
process down. There is no Python unwinding, so a caller cannot record the failure:
the work is simply lost rather than retried.
That is currently the top source of stranded Mapillary clusters (T234633115).
`mapillary_initial_worker` crashes ~224x/day and **210 of 224 (94%) have
`__cxxabiv1::__terminate` -> `std::terminate()` in the stack** -- uncaught C++
exceptions, not memory corruption; the signal is a consequence of `terminate`, not
its cause. 139 of them (62%) are in this module. Coredumps show the process dying
at 12.7 GB average and 44.6 GB peak RSS, which is the shape an allocation failure
takes, and `__clang_call_terminate` is exactly what clang emits when an exception
escapes a `noexcept` frame.
`guarded()` funnels everything -- including exception types pybind11 cannot
translate -- into a `std::runtime_error` that pybind reliably turns into a Python
exception. Argument types are deduced from the wrapped function, so reference
parameters stay references and nothing is copied that was not copied before. For
the two `gil_scoped_release` bindings the catch sits inside the released region, so
the exception is already translatable by the time the guard's destructor
re-acquires the GIL during unwinding.
This does not stop the underlying failure. It converts an instant, invisible
process kill into an ordinary Python exception that the caller can log, retry with
a smaller batch, and report -- which is what closes the leak.
`compute_vlad_descriptor` gives a directly reachable case: it throws
`std::runtime_error("Zero VLAD centers or zero length VLAD words.")`, and its
signature `VecXf(const MatXf&, const MatXf&)` matches one of the sampled crash
stacks exactly.
___
Differential Revision: D118622746
fbshipit-source-id: c19955cebe38b1209913b127f7cae33e5bff0cd51 parent 1a8bfcb commit 00c3ee2
1 file changed
Lines changed: 45 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
8 | 42 | | |
9 | 43 | | |
10 | 44 | | |
| |||
50 | 84 | | |
51 | 85 | | |
52 | 86 | | |
53 | | - | |
| 87 | + | |
54 | 88 | | |
55 | | - | |
| 89 | + | |
56 | 90 | | |
57 | 91 | | |
58 | 92 | | |
59 | | - | |
60 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
61 | 100 | | |
62 | | - | |
| 101 | + | |
| 102 | + | |
63 | 103 | | |
64 | 104 | | |
0 commit comments