Commit 32ab088
add death-test for “create before registrationComplete()” guard (#2429)
Summary:
Pull Request resolved: #2429
# Motivation
------------------
* **Real-world failure case** – An HHVM extension recently crashed because its
global `folly::Singleton` objects were first instantiated while the vault was
still in the *registration* phase. That path calls
`singletonWarnCreateBeforeRegistrationCompleteAndAbort()` and raises
SIGABRT. The new test is a minimal repro so anyone investigating similar
traces can run `singleton_test` and see the exact behavior.
* **Document the API contract** – Folly’s design intentionally treats
“create-before-registrationComplete” as a hard logic error. A unit-test makes
this behavior explicit and discoverable. If maintainers later decide to soften or
eliminate the abort, the failing test will prompt a conscious, reviewed decision
instead of a silent behavior change.
# What the test does
------------------
1. Creates a *fresh* vault identified by a private `VaultTag`; a new vault starts
in the **REGISTRATION** state.
2. Registers a dummy singleton `<Dummy, Tag, VaultTag>` against that vault.
3. Calls `try_get()` **before** `registrationComplete()` is invoked.
4. Uses `EXPECT_DEATH` to assert that the process aborts with
`singletonWarnCreateBeforeRegistrationCompleteAndAbort`.
Reviewed By: yfeldblum
Differential Revision: D73976074
fbshipit-source-id: eaaff85669c39d4cebb9923f0de3431ea6c19f7f1 parent 55df811 commit 32ab088
2 files changed
+20
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
132 | 137 | | |
133 | 138 | | |
134 | 139 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1232 | 1232 | | |
1233 | 1233 | | |
1234 | 1234 | | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
0 commit comments