From 7cc8294252577238eb99bad42c3bc7dd92f4794d Mon Sep 17 00:00:00 2001 From: Dan Crowell Date: Sat, 23 Sep 2017 22:24:28 -0500 Subject: Debug improvements for exceptions and OOM hangs There are two main changes in this commit: 1) Forcing an assert if we cannot allocate pages after 10,000 attempts to yield. 2) Adding a backtrace for a lot of exception paths. Change-Id: I755ada753b78abed56e553f7c669f0f98ae68700 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/58224 Tested-by: Jenkins Server Tested-by: Jenkins OP Build CI Tested-by: Jenkins OP HW Tested-by: FSP CI Jenkins Reviewed-by: Prachi Gupta Reviewed-by: Thi N. Tran Reviewed-by: William G. Hoffa --- src/usr/testcore/kernel/taskwaittest.H | 6 ++++-- src/usr/testcore/kernel/vmmbasetest.H | 35 ++++++++++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 6 deletions(-) (limited to 'src/usr/testcore') diff --git a/src/usr/testcore/kernel/taskwaittest.H b/src/usr/testcore/kernel/taskwaittest.H index 2d4a39772..a929dcd9a 100644 --- a/src/usr/testcore/kernel/taskwaittest.H +++ b/src/usr/testcore/kernel/taskwaittest.H @@ -5,7 +5,9 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* COPYRIGHT International Business Machines Corp. 2011,2014 */ +/* Contributors Listed Below - COPYRIGHT 2011,2018 */ +/* [+] International Business Machines Corp. */ +/* */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); */ /* you may not use this file except in compliance with the License. */ @@ -168,7 +170,7 @@ class TaskWaitTest : public CxxTest::TestSuite static void* TaskThatCrashes(void* unused) { - printk("Test case: Expect to see uncaught exception! "); + printk("TaskThatCrashes: Expect to see uncaught exception! "); *(int64_t*)(0) = 0xDEADC0DE; return NULL; } diff --git a/src/usr/testcore/kernel/vmmbasetest.H b/src/usr/testcore/kernel/vmmbasetest.H index 5a3c0d0f8..c4d42116e 100644 --- a/src/usr/testcore/kernel/vmmbasetest.H +++ b/src/usr/testcore/kernel/vmmbasetest.H @@ -5,7 +5,9 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* COPYRIGHT International Business Machines Corp. 2011,2014 */ +/* Contributors Listed Below - COPYRIGHT 2011,2018 */ +/* [+] International Business Machines Corp. */ +/* */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); */ /* you may not use this file except in compliance with the License. */ @@ -44,7 +46,7 @@ class VmmBaseTest : public CxxTest::TestSuite { int status; - printk("Test case: Expect to see uncaught exception! "); + printk("testNullAccess1: Expect to see uncaught exception! "); tid_t child = task_create(readFromNULL, NULL); if ((child != task_wait_tid(child, &status, NULL)) || @@ -53,7 +55,7 @@ class VmmBaseTest : public CxxTest::TestSuite TS_FAIL("Write to NULL not caught."); } - printk("Test case: Expect to see uncaught exception! "); + printk("testNullAccess2: Expect to see uncaught exception! "); child = task_create(writeToNULL, NULL); if ((child != task_wait_tid(child, &status, NULL)) || (status != TASK_STATUS_CRASHED)) @@ -66,7 +68,7 @@ class VmmBaseTest : public CxxTest::TestSuite { int status; - printk("Test case: Expect to see uncaught exception! "); + printk("testWriteToKernelCode: Expect to see uncaught exception! "); tid_t child = task_create(writeToKernelCode, NULL); if ((child != task_wait_tid(child, &status, NULL)) || (status != TASK_STATUS_CRASHED)) @@ -134,6 +136,21 @@ class VmmBaseTest : public CxxTest::TestSuite } } + void testHugeMalloc() + { + int status; + + printk("testHugeMalloc: Expect to see uncaught exception! ");isync(); + + tid_t child = task_create(bigMalloc, NULL); + + if ((child != task_wait_tid(child, &status, NULL)) || + (status != TASK_STATUS_CRASHED)) + { + TS_FAIL("testHugeMalloc> Giant malloc didn't crash."); + } + } + private: static void* readFromNULL(void* unused) @@ -180,6 +197,16 @@ class VmmBaseTest : public CxxTest::TestSuite return NULL; } + static void* bigMalloc(void* unused) + { + uint8_t* ptr = (uint8_t*)malloc(VMM_MEMORY_SIZE); + for( size_t x=0; x<(VMM_MEMORY_SIZE); x+=MEGABYTE ) + { + ptr[x] = x; + } + return NULL; + } + }; msg_q_t VmmBaseTest::iv_mq = msg_q_create(); -- cgit v1.2.1