Skip to content

Commit 991924b

Browse files
committed
Bug 1465709 - Hook rust OOM handler on rustc 1.28. r=froydnj
Bug 1458161 added a rust OOM handler based on an unstable API that was removed in 1.27, replaced with something that didn't allow to get the failed allocation size. Latest 1.28 nightly (2018-06-13) has rust-lang/rust#50880, rust-lang/rust#51264 and rust-lang/rust#51241 merged, which allow to hook the OOM handler and get the failed allocation size again. Because this is still an unstable API, we explicitly depend on strict versions of rustc. We also explicitly error out if automation builds end up using a rustc version that doesn't allow us to get the allocation size for rust OOM, because we don't want that to happen without knowing. UltraBlame original commit: 5182bca90d0609f182d5a7b6b48ed2ffbbce32c2
1 parent 4a02964 commit 991924b

File tree

7 files changed

+255
-0
lines changed

7 files changed

+255
-0
lines changed

toolkit/crashreporter/nsExceptionHandler.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,11 @@ install_rust_panic_hook
901901
(
902902
)
903903
;
904+
void
905+
install_rust_oom_hook
906+
(
907+
)
908+
;
904909
bool
905910
get_rust_panic_reason
906911
(
@@ -8983,6 +8988,10 @@ install_rust_panic_hook
89838988
(
89848989
)
89858990
;
8991+
install_rust_oom_hook
8992+
(
8993+
)
8994+
;
89868995
InitThreadAnnotation
89878996
(
89888997
)

toolkit/library/gtest/rust/Cargo.toml

+11
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,17 @@ shared
143143
oom_with_global_alloc
144144
"
145145
]
146+
oom_with_hook
147+
=
148+
[
149+
"
150+
gkrust
151+
-
152+
shared
153+
/
154+
oom_with_hook
155+
"
156+
]
146157
moz_memory
147158
=
148159
[

toolkit/library/rust/Cargo.toml

+11
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,17 @@ shared
141141
oom_with_global_alloc
142142
"
143143
]
144+
oom_with_hook
145+
=
146+
[
147+
"
148+
gkrust
149+
-
150+
shared
151+
/
152+
oom_with_hook
153+
"
154+
]
144155
moz_memory
145156
=
146157
[

toolkit/library/rust/gkrust-features.mozbuild

+85
Original file line numberDiff line numberDiff line change
@@ -310,3 +310,88 @@ gkrust_features
310310
oom_with_global_alloc
311311
'
312312
]
313+
elif
314+
CONFIG
315+
[
316+
'
317+
RUSTC_VERSION
318+
'
319+
]
320+
>
321+
=
322+
"
323+
1
324+
.
325+
28
326+
"
327+
and
328+
CONFIG
329+
[
330+
'
331+
RUSTC_VERSION
332+
'
333+
]
334+
<
335+
"
336+
1
337+
.
338+
29
339+
"
340+
:
341+
gkrust_features
342+
+
343+
=
344+
[
345+
'
346+
oom_with_hook
347+
'
348+
]
349+
elif
350+
not
351+
CONFIG
352+
[
353+
'
354+
MOZ_AUTOMATION
355+
'
356+
]
357+
:
358+
#
359+
We
360+
don
361+
'
362+
t
363+
want
364+
builds
365+
on
366+
automation
367+
to
368+
unwillingly
369+
stop
370+
annotating
371+
OOM
372+
#
373+
crash
374+
reports
375+
from
376+
rust
377+
.
378+
error
379+
(
380+
'
381+
Builds
382+
on
383+
automation
384+
must
385+
use
386+
a
387+
version
388+
of
389+
rust
390+
that
391+
supports
392+
OOM
393+
'
394+
'
395+
hooking
396+
'
397+
)

toolkit/library/rust/shared/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,10 @@ oom_with_global_alloc
679679
=
680680
[
681681
]
682+
oom_with_hook
683+
=
684+
[
685+
]
682686
moz_memory
683687
=
684688
[

toolkit/library/rust/shared/build.rs

+8
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,19 @@ release
7373
[
7474
cfg
7575
(
76+
any
77+
(
7678
feature
7779
=
7880
"
7981
oom_with_global_alloc
8082
"
83+
feature
84+
=
85+
"
86+
oom_with_hook
87+
"
88+
)
8189
)
8290
]
8391
println

toolkit/library/rust/shared/lib.rs

+127
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,22 @@ allocator_api
7676
)
7777
]
7878
#
79+
!
80+
[
81+
cfg_attr
82+
(
83+
feature
84+
=
85+
"
86+
oom_with_hook
87+
"
88+
feature
89+
(
90+
oom_hook
91+
)
92+
)
93+
]
94+
#
7995
[
8096
cfg
8197
(
@@ -1557,3 +1573,114 @@ global_alloc
15571573
:
15581574
GeckoHeap
15591575
;
1576+
#
1577+
[
1578+
cfg
1579+
(
1580+
feature
1581+
=
1582+
"
1583+
oom_with_hook
1584+
"
1585+
)
1586+
]
1587+
mod
1588+
oom_hook
1589+
{
1590+
use
1591+
std
1592+
:
1593+
:
1594+
alloc
1595+
:
1596+
:
1597+
{
1598+
Layout
1599+
set_oom_hook
1600+
}
1601+
;
1602+
extern
1603+
"
1604+
C
1605+
"
1606+
{
1607+
fn
1608+
GeckoHandleOOM
1609+
(
1610+
size
1611+
:
1612+
usize
1613+
)
1614+
-
1615+
>
1616+
!
1617+
;
1618+
}
1619+
pub
1620+
fn
1621+
hook
1622+
(
1623+
layout
1624+
:
1625+
Layout
1626+
)
1627+
{
1628+
unsafe
1629+
{
1630+
GeckoHandleOOM
1631+
(
1632+
layout
1633+
.
1634+
size
1635+
(
1636+
)
1637+
)
1638+
;
1639+
}
1640+
}
1641+
pub
1642+
fn
1643+
install
1644+
(
1645+
)
1646+
{
1647+
set_oom_hook
1648+
(
1649+
hook
1650+
)
1651+
;
1652+
}
1653+
}
1654+
#
1655+
[
1656+
no_mangle
1657+
]
1658+
pub
1659+
extern
1660+
"
1661+
C
1662+
"
1663+
fn
1664+
install_rust_oom_hook
1665+
(
1666+
)
1667+
{
1668+
#
1669+
[
1670+
cfg
1671+
(
1672+
feature
1673+
=
1674+
"
1675+
oom_with_hook
1676+
"
1677+
)
1678+
]
1679+
oom_hook
1680+
:
1681+
:
1682+
install
1683+
(
1684+
)
1685+
;
1686+
}

0 commit comments

Comments
 (0)