summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@well-typed.com>2022-02-06 10:58:34 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-02-13 03:26:14 -0500
commiteeead9fc9bdb5e1add09a9c3aa40df9a77d9eac3 (patch)
treea6385fd90fa76c222b6dcccef27663c59508c19c
parent744f8a1196d5853d507f2751fd39fe35395684e1 (diff)
downloadhaskell-eeead9fc9bdb5e1add09a9c3aa40df9a77d9eac3.tar.gz
rts/Adjustor: Ensure that allocateExecPage succeeded
Previously we failed to handle the case that `allocateExecPage` failed.
-rw-r--r--rts/adjustor/NativeAlpha.c3
-rw-r--r--rts/adjustor/NativeAmd64.c12
-rw-r--r--rts/adjustor/NativePowerPC.c6
-rw-r--r--rts/adjustor/Nativei386.c6
4 files changed, 27 insertions, 0 deletions
diff --git a/rts/adjustor/NativeAlpha.c b/rts/adjustor/NativeAlpha.c
index 0e1e257983..63343cabd5 100644
--- a/rts/adjustor/NativeAlpha.c
+++ b/rts/adjustor/NativeAlpha.c
@@ -67,6 +67,9 @@ TODO: Depending on how much allocation overhead stgMallocBytes uses for
{
ASSERT(((StgWord64)wptr & 3) == 0);
ExecPage *page = allocateExecPage();
+ if (page == NULL) {
+ barf("createAdjustor: failed to allocate executable page\n");
+ }
StgWord64 *const code = (StgWord64 *) page;
code[0] = 0x4610041246520414L;
diff --git a/rts/adjustor/NativeAmd64.c b/rts/adjustor/NativeAmd64.c
index 391661539f..2d59bd0bc0 100644
--- a/rts/adjustor/NativeAmd64.c
+++ b/rts/adjustor/NativeAmd64.c
@@ -145,6 +145,9 @@ createAdjustor(int cconv, StgStablePtr hptr,
(typeString[3] == '\0')) {
ExecPage *page = allocateExecPage();
+ if (page == NULL) {
+ barf("createAdjustor: failed to allocate executable page\n");
+ }
StgWord8 *adj_code = (StgWord8*) page;
*(StgInt32 *)adj_code = 0x49c1894d;
@@ -167,6 +170,9 @@ createAdjustor(int cconv, StgStablePtr hptr,
{
bool fourthFloating = (typeString[3] == 'f' || typeString[3] == 'd');
ExecPage *page = allocateExecPage();
+ if (page == NULL) {
+ barf("createAdjustor: failed to allocate executable page\n");
+ }
StgWord8 *adj_code = (StgWord8*) page;
*(StgInt32 *)adj_code = 0x08ec8348;
@@ -266,6 +272,9 @@ createAdjustor(int cconv, StgStablePtr hptr,
if (i < 6) {
ExecPage *page = allocateExecPage();
+ if (page == NULL) {
+ barf("createAdjustor: failed to allocate executable page\n");
+ }
StgWord8 *adj_code = (StgWord8*) page;
*(StgInt32 *)adj_code = 0x49c1894d;
@@ -284,6 +293,9 @@ createAdjustor(int cconv, StgStablePtr hptr,
else
{
ExecPage *page = allocateExecPage();
+ if (page == NULL) {
+ barf("createAdjustor: failed to allocate executable page\n");
+ }
StgWord8 *adj_code = (StgWord8*) page;
*(StgInt32 *)adj_code = 0x35ff5141;
diff --git a/rts/adjustor/NativePowerPC.c b/rts/adjustor/NativePowerPC.c
index 31d89ee510..c5c4f6374b 100644
--- a/rts/adjustor/NativePowerPC.c
+++ b/rts/adjustor/NativePowerPC.c
@@ -151,6 +151,9 @@ createAdjustor(int cconv, StgStablePtr hptr,
// allocate space for at most 4 insns per parameter
// plus 14 more instructions.
ExecPage *page = allocateExecPage();
+ if (page == NULL) {
+ barf("createAdjustor: failed to allocate executable page\n");
+ }
unsigned *code = adjustor;
*code++ = 0x48000008; // b *+8
@@ -303,6 +306,9 @@ createAdjustor(int cconv, StgStablePtr hptr,
adjustorStub = stgMallocBytes(sizeof(AdjustorStub), "createAdjustor");
#else
ExecPage *page = allocateExecPage();
+ if (page == NULL) {
+ barf("createAdjustor: failed to allocate executable page\n");
+ }
adjustorStub = (AdjustorStub *) page;
#endif /* defined(FUNDESCS) */
adjustor = adjustorStub;
diff --git a/rts/adjustor/Nativei386.c b/rts/adjustor/Nativei386.c
index 2cf69bd800..c613d361b3 100644
--- a/rts/adjustor/Nativei386.c
+++ b/rts/adjustor/Nativei386.c
@@ -53,6 +53,9 @@ createAdjustor(int cconv, StgStablePtr hptr,
{
ExecPage *page = allocateExecPage();
+ if (page == NULL) {
+ barf("createAdjustor: failed to allocate executable page\n");
+ }
uint8_t *adj_code = (uint8_t *) page;
adj_code[0x00] = 0x58; /* popl %eax */
@@ -83,6 +86,9 @@ createAdjustor(int cconv, StgStablePtr hptr,
We offload most of the work to AdjustorAsm.S.
*/
ExecPage *page = allocateExecPage();
+ if (page == NULL) {
+ barf("createAdjustor: failed to allocate executable page\n");
+ }
AdjustorStub *adjustorStub = (AdjustorStub *) page;
int sz = totalArgumentSize(typeString);