os/kernelhwsrv/kerneltest/e32test/system/t_prot.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// e32test\system\t_prot.cpp
sl@0
    15
// Overview:
sl@0
    16
// Tests that the kernel panics the user rather than dying in 
sl@0
    17
// various situations
sl@0
    18
// API Information:
sl@0
    19
// N/A
sl@0
    20
// Details:
sl@0
    21
// - Verify that printing a long string does not panic.
sl@0
    22
// - Verify that a stack overflow in a thread causes a panic.
sl@0
    23
// - Create the thread which panics a dead thread, verify that 
sl@0
    24
// it isn't panicked for doing this.
sl@0
    25
// - Create the thread which panics a bad handle, verify that 
sl@0
    26
// it isn't panicked for doing this.
sl@0
    27
// - Verify that an RSession send from an uninitialised handle
sl@0
    28
// causes a panic.
sl@0
    29
// - Verify that the thread causing an exception, for a variety
sl@0
    30
// of reasons, is panicked.
sl@0
    31
// - Verify thread writing to kernel data is panicked.
sl@0
    32
// - Verify that RAM disk access either causes a panic or is
sl@0
    33
// denied, based on the platform security settings.
sl@0
    34
// - Verify that an RThread::RequestComplete() with an invalid
sl@0
    35
// address causes a panic. Verify results are as expected.
sl@0
    36
// Platforms/Drives/Compatibility:
sl@0
    37
// All.
sl@0
    38
// Assumptions/Requirement/Pre-requisites:
sl@0
    39
// Failures and causes:
sl@0
    40
// Base Port information:
sl@0
    41
// 
sl@0
    42
//
sl@0
    43
sl@0
    44
#include <e32test.h>
sl@0
    45
#include "u32std.h"
sl@0
    46
#include <e32panic.h>
sl@0
    47
#include "../mmu/mmudetect.h"
sl@0
    48
sl@0
    49
void DoUndefinedInstruction();
sl@0
    50
sl@0
    51
const TInt KHeapSize=0x200;
sl@0
    52
const TInt KThreadReturnValue=9999;
sl@0
    53
sl@0
    54
_LIT(KLitKernExec,"KERN-EXEC");
sl@0
    55
sl@0
    56
class RSessionTest : public RSessionBase
sl@0
    57
	{
sl@0
    58
public:
sl@0
    59
	void DoSend();
sl@0
    60
	};
sl@0
    61
sl@0
    62
sl@0
    63
void RSessionTest::DoSend()
sl@0
    64
	{
sl@0
    65
    Send(34,TIpcArgs(78));
sl@0
    66
	//Send(34,(TAny*)78);
sl@0
    67
	};
sl@0
    68
sl@0
    69
LOCAL_D RTest test(_L("T_PROT"));
sl@0
    70
LOCAL_D RTest t(_L("T_PROT thread"));
sl@0
    71
sl@0
    72
enum TAction
sl@0
    73
	{
sl@0
    74
	EDataAbort=0,
sl@0
    75
	EPrefetchAbort=1,
sl@0
    76
	EUndefinedInstruction=2,
sl@0
    77
	};
sl@0
    78
sl@0
    79
typedef void (*PFV)(void);
sl@0
    80
sl@0
    81
#ifndef __MARM__
sl@0
    82
void DoUndefinedInstruction()
sl@0
    83
	{
sl@0
    84
#ifdef __GCC32__	
sl@0
    85
	asm("int 6");
sl@0
    86
#else
sl@0
    87
	_asm int 6;
sl@0
    88
#endif
sl@0
    89
	}
sl@0
    90
#endif
sl@0
    91
sl@0
    92
LOCAL_C TInt ExceptionThread(TAny* anAction)
sl@0
    93
	{
sl@0
    94
	TAction action=(TAction)((TInt) anAction);
sl@0
    95
	switch (action)
sl@0
    96
		{
sl@0
    97
		case EDataAbort:
sl@0
    98
			*(TInt*)0=0;
sl@0
    99
			break;
sl@0
   100
		case EPrefetchAbort:
sl@0
   101
			{
sl@0
   102
//			PFV f=(PFV)NULL;
sl@0
   103
			PFV f=(PFV)0x80000;	// don't use NULL since it is readable on Snowdrop
sl@0
   104
			(*f)();
sl@0
   105
			break;
sl@0
   106
			}
sl@0
   107
		case EUndefinedInstruction:
sl@0
   108
			DoUndefinedInstruction();
sl@0
   109
			break;
sl@0
   110
		};
sl@0
   111
	return 0;
sl@0
   112
	}
sl@0
   113
sl@0
   114
LOCAL_C void RunTestThread(TAction anAction)
sl@0
   115
	{
sl@0
   116
	RThread t;
sl@0
   117
	TInt r=t.Create(_L("TestThread"),ExceptionThread,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)anAction);
sl@0
   118
	test(r==KErrNone);
sl@0
   119
	TRequestStatus s;
sl@0
   120
	t.Logon(s);
sl@0
   121
	test(s==KRequestPending);
sl@0
   122
	t.Resume();
sl@0
   123
	User::WaitForRequest(s);
sl@0
   124
	test(t.ExitType()==EExitPanic);
sl@0
   125
	test(t.ExitCategory()==_L("KERN-EXEC"));
sl@0
   126
	test(t.ExitReason()==ECausedException);
sl@0
   127
	CLOSE_AND_WAIT(t);
sl@0
   128
	}
sl@0
   129
sl@0
   130
LOCAL_C TInt UnintThread(TAny* )
sl@0
   131
	{
sl@0
   132
sl@0
   133
	RSessionTest rsb;
sl@0
   134
	rsb.DoSend();
sl@0
   135
	FOREVER
sl@0
   136
		;
sl@0
   137
	}
sl@0
   138
sl@0
   139
void testSession()
sl@0
   140
//
sl@0
   141
// Test 1
sl@0
   142
//
sl@0
   143
	{
sl@0
   144
	
sl@0
   145
	RThread thread;
sl@0
   146
	TRequestStatus stat;
sl@0
   147
sl@0
   148
	test.Next(_L("Create UnintThread"));
sl@0
   149
	TInt r=thread.Create(_L("UnintThread"),UnintThread,KDefaultStackSize,KHeapSize,KHeapSize,0);
sl@0
   150
	test(r==KErrNone);
sl@0
   151
sl@0
   152
	thread.Logon(stat);
sl@0
   153
	test(thread.ExitType()==EExitPending);
sl@0
   154
	test.Next(_L("Resume UnintThread"));
sl@0
   155
	thread.Resume();
sl@0
   156
	User::WaitForRequest(stat);
sl@0
   157
	test.Next(_L("Check UnintThread panicked"));
sl@0
   158
	test(thread.ExitCategory()==_L("KERN-EXEC"));
sl@0
   159
//	test(thread.ExitReason()==EBadHandle);
sl@0
   160
	test(thread.ExitType()==EExitPanic);
sl@0
   161
	CLOSE_AND_WAIT(thread);
sl@0
   162
	}
sl@0
   163
sl@0
   164
TInt dummy(TAny*)
sl@0
   165
	{
sl@0
   166
	return(KErrNone);
sl@0
   167
	}
sl@0
   168
sl@0
   169
// Dennis - modified this to panic a dead thread rather than a bad handle
sl@0
   170
TInt pdThread(TAny*)
sl@0
   171
	{
sl@0
   172
	RThread thread;
sl@0
   173
	TRequestStatus stat;
sl@0
   174
	TInt r=thread.Create(_L("dummy"),dummy,KDefaultStackSize,KHeapSize,KHeapSize,0);
sl@0
   175
	test(r==KErrNone);
sl@0
   176
	thread.Logon(stat);
sl@0
   177
	test(thread.ExitType()==EExitPending);
sl@0
   178
	thread.Resume();
sl@0
   179
	User::WaitForRequest(stat);
sl@0
   180
	test(thread.ExitType()==EExitKill);
sl@0
   181
	test(stat.Int()==KErrNone);
sl@0
   182
	thread.Panic(_L("MYPANIC"),0x666); // this shouldn't panic pdThread
sl@0
   183
	test(thread.ExitType()==EExitKill);
sl@0
   184
	test(thread.ExitReason()==KErrNone);
sl@0
   185
	CLOSE_AND_WAIT(thread);
sl@0
   186
	return(KErrNone);
sl@0
   187
	}
sl@0
   188
sl@0
   189
void testPanicDeadThread()
sl@0
   190
//
sl@0
   191
// Dennis - modified this to panic a dead thread rather than a bad handle
sl@0
   192
// Create the thread which panics a dead thread /*bad handle*/
sl@0
   193
// Check that it isn't panicked for doing this
sl@0
   194
//
sl@0
   195
	{
sl@0
   196
	RThread thread;
sl@0
   197
	TRequestStatus stat;
sl@0
   198
	test.Next(_L("Create PanicDeadThread"));
sl@0
   199
	TInt r=thread.Create(_L("PanicDeadThread"),pdThread,KDefaultStackSize,KHeapSize,KHeapSize,0);
sl@0
   200
	test(r==KErrNone);
sl@0
   201
	thread.Logon(stat);
sl@0
   202
	test(thread.ExitType()==EExitPending);
sl@0
   203
	test.Next(_L("Resume PanicDeadThread"));
sl@0
   204
	thread.Resume();
sl@0
   205
	User::WaitForRequest(stat);
sl@0
   206
	test.Next(_L("Check PanicDeadThread did not panic"));
sl@0
   207
	test(thread.ExitReason()==KErrNone);
sl@0
   208
	test(thread.ExitType()==EExitKill);
sl@0
   209
	test(thread.ExitCategory()==_L("Kill"));
sl@0
   210
	CLOSE_AND_WAIT(thread);
sl@0
   211
	}
sl@0
   212
sl@0
   213
TInt doDeadThreadStuff(TAny*)
sl@0
   214
	{
sl@0
   215
	RThread thread;
sl@0
   216
	TRequestStatus stat;
sl@0
   217
	TInt r=thread.Create(_L("dummy2"),dummy,KDefaultStackSize,KHeapSize,KHeapSize,0);
sl@0
   218
	test(r==KErrNone);
sl@0
   219
	thread.Logon(stat);
sl@0
   220
	test(thread.ExitType()==EExitPending);
sl@0
   221
	thread.Resume();
sl@0
   222
	User::WaitForRequest(stat);
sl@0
   223
sl@0
   224
	thread.SetPriority(EPriorityNormal);
sl@0
   225
sl@0
   226
	CLOSE_AND_WAIT(thread);
sl@0
   227
	return(KErrNone);
sl@0
   228
	}
sl@0
   229
sl@0
   230
void testDeadThread()
sl@0
   231
//
sl@0
   232
// Create the thread which panics a bad handle
sl@0
   233
// Check that it isn't panicked for doing this
sl@0
   234
//
sl@0
   235
	{
sl@0
   236
	RThread thread;
sl@0
   237
	TRequestStatus stat;
sl@0
   238
	test.Next(_L("Create doDeadThreadStuff"));
sl@0
   239
	TInt r=thread.Create(_L("doDeadThreadStuff"),doDeadThreadStuff,KDefaultStackSize,KHeapSize,KHeapSize,0);
sl@0
   240
	test(r==KErrNone);
sl@0
   241
	thread.Logon(stat);
sl@0
   242
	test(thread.ExitType()==EExitPending);
sl@0
   243
	test.Next(_L("Resume doDeadThreadStuff"));
sl@0
   244
	thread.Resume();
sl@0
   245
	User::WaitForRequest(stat);
sl@0
   246
	test.Next(_L("Check doDeadThreadStuff did not panic"));
sl@0
   247
	test(thread.ExitReason()==KErrNone);
sl@0
   248
	test(thread.ExitType()==EExitKill);
sl@0
   249
	test(thread.ExitCategory()==_L("Kill"));
sl@0
   250
	CLOSE_AND_WAIT(thread);
sl@0
   251
	}
sl@0
   252
sl@0
   253
TInt MinimalThread(TAny*)
sl@0
   254
//
sl@0
   255
// Minimal thread, used in test 5
sl@0
   256
//
sl@0
   257
	{
sl@0
   258
	return(KErrNone);
sl@0
   259
	}
sl@0
   260
sl@0
   261
LOCAL_C TInt ExceptThread(TAny* )
sl@0
   262
	{
sl@0
   263
sl@0
   264
	TUint* nullPtr=0;
sl@0
   265
	*nullPtr=0xdead; // BANG!!
sl@0
   266
	return KErrNone;
sl@0
   267
	}
sl@0
   268
sl@0
   269
sl@0
   270
void testExcept()
sl@0
   271
//
sl@0
   272
// Test thread causing exception is panicked
sl@0
   273
//
sl@0
   274
	{
sl@0
   275
	
sl@0
   276
	RThread thread;
sl@0
   277
	TRequestStatus stat;
sl@0
   278
sl@0
   279
	test.Next(_L("Create ExceptThread"));
sl@0
   280
	TInt r=thread.Create(_L("ExceptThread"),ExceptThread,KDefaultStackSize,KHeapSize,KHeapSize,0);
sl@0
   281
	test(r==KErrNone);
sl@0
   282
sl@0
   283
	thread.Logon(stat);
sl@0
   284
	test(thread.ExitType()==EExitPending);
sl@0
   285
	test.Next(_L("Resume ExceptThread"));
sl@0
   286
	thread.Resume();
sl@0
   287
	User::WaitForRequest(stat);
sl@0
   288
	test.Next(_L("Check ExceptThread panicked"));
sl@0
   289
	test(thread.ExitCategory()==_L("KERN-EXEC"));
sl@0
   290
	test(thread.ExitReason()==ECausedException);
sl@0
   291
	test(thread.ExitType()==EExitPanic);
sl@0
   292
	CLOSE_AND_WAIT(thread);
sl@0
   293
	}
sl@0
   294
sl@0
   295
LOCAL_C TInt StackThread(TAny* )
sl@0
   296
	{
sl@0
   297
sl@0
   298
	TFileName heresAnotherOne;
sl@0
   299
	StackThread((TAny*)heresAnotherOne.Ptr()); // go recursive
sl@0
   300
	return KErrNone;
sl@0
   301
	}
sl@0
   302
sl@0
   303
void testStackOverflow()
sl@0
   304
//
sl@0
   305
// Thread overflowing its stack is panicked
sl@0
   306
//
sl@0
   307
	{
sl@0
   308
sl@0
   309
	RThread thread;
sl@0
   310
	TRequestStatus stat;
sl@0
   311
sl@0
   312
	test.Next(_L("Create StackThread"));
sl@0
   313
	TInt r=thread.Create(_L("StackThread"),StackThread,KDefaultStackSize,KHeapSize,KHeapSize,0);
sl@0
   314
	test(r==KErrNone);
sl@0
   315
sl@0
   316
	thread.Logon(stat);
sl@0
   317
	test(thread.ExitType()==EExitPending);
sl@0
   318
	test.Next(_L("Resume StackThread"));
sl@0
   319
	thread.Resume();
sl@0
   320
	User::WaitForRequest(stat);
sl@0
   321
	test.Next(_L("Check StackThread panicked"));
sl@0
   322
	test(thread.ExitCategory()==_L("KERN-EXEC"));
sl@0
   323
	test(thread.ExitReason()==ECausedException);
sl@0
   324
	test(thread.ExitType()==EExitPanic);
sl@0
   325
	CLOSE_AND_WAIT(thread);
sl@0
   326
	}
sl@0
   327
sl@0
   328
LOCAL_C TInt KernWriter(TAny* )
sl@0
   329
	{
sl@0
   330
sl@0
   331
	TUint* kernPtr=(TUint*)KernData();
sl@0
   332
	*kernPtr=0xdead; // BANG!!
sl@0
   333
	return KErrNone;
sl@0
   334
	}
sl@0
   335
sl@0
   336
LOCAL_C TInt RamDiskWriter(TAny* )
sl@0
   337
	{
sl@0
   338
sl@0
   339
	TFindChunk fChunk(_L("*TheRamDriveChunk*"));
sl@0
   340
	TFullName n;
sl@0
   341
	TInt r=fChunk.Next(n);
sl@0
   342
	RChunk ch;
sl@0
   343
	r=ch.Open(fChunk);
sl@0
   344
	if(r!=KErrNone)
sl@0
   345
		return r;
sl@0
   346
	TUint8* rdPtr=ch.Base();
sl@0
   347
	*rdPtr=0xaa; // BANG!!
sl@0
   348
	return KErrNone;
sl@0
   349
	}
sl@0
   350
sl@0
   351
sl@0
   352
void testKernelWriter()
sl@0
   353
//
sl@0
   354
// Thread writing to kernel data is panicked
sl@0
   355
//
sl@0
   356
	{
sl@0
   357
sl@0
   358
	RThread thread;
sl@0
   359
	TRequestStatus stat;
sl@0
   360
sl@0
   361
	test.Next(_L("Create KernWriter"));
sl@0
   362
	TInt r=thread.Create(_L("KernWriter"),KernWriter,KDefaultStackSize,KHeapSize,KHeapSize,0);
sl@0
   363
	test(r==KErrNone);
sl@0
   364
sl@0
   365
	thread.Logon(stat);
sl@0
   366
	test(thread.ExitType()==EExitPending);
sl@0
   367
	test.Next(_L("Resume KernWriter"));
sl@0
   368
	thread.Resume();
sl@0
   369
	User::WaitForRequest(stat);
sl@0
   370
	test.Next(_L("Check KernWriter panicked"));
sl@0
   371
	test(thread.ExitCategory()==_L("KERN-EXEC"));
sl@0
   372
	test(thread.ExitReason()==ECausedException);
sl@0
   373
	test(thread.ExitType()==EExitPanic);
sl@0
   374
	CLOSE_AND_WAIT(thread);
sl@0
   375
	}
sl@0
   376
sl@0
   377
void testRamDiskAccess()
sl@0
   378
	{
sl@0
   379
sl@0
   380
	RThread thread;
sl@0
   381
	TRequestStatus stat;
sl@0
   382
sl@0
   383
	test.Next(_L("Create RamDiskWriter"));
sl@0
   384
	TInt r=thread.Create(_L("RamDiskWriter"),RamDiskWriter,KDefaultStackSize,KHeapSize,KHeapSize,0);
sl@0
   385
	test(r==KErrNone);
sl@0
   386
sl@0
   387
	thread.Logon(stat);
sl@0
   388
	test(thread.ExitType()==EExitPending);
sl@0
   389
	test.Next(_L("Resume RamDiskWriter"));
sl@0
   390
	thread.Resume();
sl@0
   391
	User::WaitForRequest(stat);
sl@0
   392
	if((!PlatSec::ConfigSetting(PlatSec::EPlatSecProcessIsolation))||(!PlatSec::ConfigSetting(PlatSec::EPlatSecEnforcement)))
sl@0
   393
		{
sl@0
   394
		test.Next(_L("Check RamDiskWriter panicked"));
sl@0
   395
		test(thread.ExitCategory()==_L("KERN-EXEC"));
sl@0
   396
		test(thread.ExitReason()==ECausedException);
sl@0
   397
		test(thread.ExitType()==EExitPanic);
sl@0
   398
		}
sl@0
   399
	else
sl@0
   400
		{
sl@0
   401
		test.Next(_L("Check RamDiskWriter was refused access"));
sl@0
   402
		test(thread.ExitReason()==KErrPermissionDenied);
sl@0
   403
		test(thread.ExitType()==EExitKill);
sl@0
   404
		}
sl@0
   405
	CLOSE_AND_WAIT(thread);
sl@0
   406
	}
sl@0
   407
sl@0
   408
RThread MainThread;
sl@0
   409
sl@0
   410
TInt RequestCompleteThread(TAny* aPtr)
sl@0
   411
	{
sl@0
   412
	TRequestStatus** pS=(TRequestStatus**)aPtr;
sl@0
   413
	MainThread.RequestComplete(*pS,123);
sl@0
   414
	return 0;
sl@0
   415
	}
sl@0
   416
sl@0
   417
_LIT(KReqCompThreadName,"ReqCompThread");
sl@0
   418
void StartRequestCompleteThread(RThread& aThread, TRequestStatus** aStatus)
sl@0
   419
	{
sl@0
   420
	TInt r=aThread.Create(KReqCompThreadName,RequestCompleteThread,0x1000,0x1000,0x10000,aStatus);
sl@0
   421
	test (r==KErrNone);
sl@0
   422
	aThread.SetPriority(EPriorityMore);
sl@0
   423
	TRequestStatus s;
sl@0
   424
	aThread.Logon(s);
sl@0
   425
	aThread.Resume();
sl@0
   426
	User::WaitForRequest(s);
sl@0
   427
	}
sl@0
   428
sl@0
   429
_LIT(KLitUserCBase,"E32USER-CBase");
sl@0
   430
GLDEF_C TInt E32Main()
sl@0
   431
//
sl@0
   432
// Main
sl@0
   433
//
sl@0
   434
	{	
sl@0
   435
sl@0
   436
	// don't want just in time debugging as we trap panics
sl@0
   437
	TBool justInTime=User::JustInTime(); 
sl@0
   438
	User::SetJustInTime(EFalse); 
sl@0
   439
sl@0
   440
	test.Title();
sl@0
   441
	test.Start(_L("Test protection & panicking"));
sl@0
   442
sl@0
   443
#if defined(__EPOC32__)
sl@0
   444
	// this next test doesn't work under WINS because the string needs to be converted
sl@0
   445
	// from UNICODE to ascii for printing to STDOUT, and that requires the string to be
sl@0
   446
	// zero-terminated which panics because the string is too long.
sl@0
   447
	test.Next(_L("Printing long string doesn't get me shot"));
sl@0
   448
	test.Printf(_L("012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"));
sl@0
   449
	test.Printf(_L("\n"));
sl@0
   450
#endif
sl@0
   451
sl@0
   452
	if (HaveVirtMem())
sl@0
   453
		{
sl@0
   454
		test.Next(_L("Stack overflow shoots the thread not the kernel"));
sl@0
   455
		testStackOverflow();
sl@0
   456
		}
sl@0
   457
sl@0
   458
	test.Next(_L("Panicking a closed thread doesn't panic the panicker!!"));
sl@0
   459
	testPanicDeadThread();
sl@0
   460
sl@0
   461
	test.Next(_L("Dead thread tests"));
sl@0
   462
	testDeadThread();
sl@0
   463
sl@0
   464
	test.Next(_L("RSession send from uninitialised handle"));
sl@0
   465
	testSession();
sl@0
   466
sl@0
   467
	test.Next(_L("Thread causing exception is killed"));
sl@0
   468
	if (HaveVirtMem())
sl@0
   469
		{
sl@0
   470
		testExcept();
sl@0
   471
		RunTestThread(EDataAbort);
sl@0
   472
		RunTestThread(EPrefetchAbort);
sl@0
   473
		}
sl@0
   474
#ifndef __WINS__
sl@0
   475
	RunTestThread(EUndefinedInstruction);
sl@0
   476
#endif
sl@0
   477
sl@0
   478
#if defined(__EPOC32__)
sl@0
   479
	if (HaveDirectKernProt())
sl@0
   480
		{
sl@0
   481
		test.Next(_L("Thread writing to kernel data is killed"));
sl@0
   482
		testKernelWriter();
sl@0
   483
		}
sl@0
   484
sl@0
   485
	if (HaveProcessProt())
sl@0
   486
		{
sl@0
   487
		test.Next(_L("Check access to RamDisk is denied"));
sl@0
   488
		testRamDiskAccess();
sl@0
   489
		}
sl@0
   490
sl@0
   491
	if (HaveMMU())
sl@0
   492
		{
sl@0
   493
		test.Next(_L("RequestComplete() with bad address"));
sl@0
   494
		TInt rqc=RThread().RequestCount();
sl@0
   495
		test(MainThread.Duplicate(RThread())==KErrNone);
sl@0
   496
		RThread t;
sl@0
   497
		TRequestStatus s=KRequestPending;
sl@0
   498
		TRequestStatus* pS=&s;
sl@0
   499
		StartRequestCompleteThread(t,&pS);
sl@0
   500
		test(t.ExitType()==EExitKill);
sl@0
   501
		test(t.ExitReason()==KErrNone);
sl@0
   502
		CLOSE_AND_WAIT(t);
sl@0
   503
		test(s==123);
sl@0
   504
		test(pS==NULL);
sl@0
   505
		test(RThread().RequestCount()==rqc+1);
sl@0
   506
		TRequestStatus** bad=(TRequestStatus**)0x80000000;	// kernel space
sl@0
   507
		StartRequestCompleteThread(t,bad);
sl@0
   508
		test(t.ExitType()==EExitPanic);
sl@0
   509
		test(t.ExitReason()==ECausedException);
sl@0
   510
		test(t.ExitCategory()==KLitKernExec);
sl@0
   511
		CLOSE_AND_WAIT(t);
sl@0
   512
		test(RThread().RequestCount()==rqc+1);
sl@0
   513
		pS=(TRequestStatus*)0x80000000;
sl@0
   514
		StartRequestCompleteThread(t,&pS);
sl@0
   515
		// Request status poked user side, so we expect a KERN-EXEC 3...
sl@0
   516
		test(t.ExitType()==EExitPanic);
sl@0
   517
		test(t.ExitReason()==ECausedException);
sl@0
   518
		test(t.ExitCategory()==KLitKernExec);
sl@0
   519
		CLOSE_AND_WAIT(t);
sl@0
   520
		test(pS==NULL);
sl@0
   521
		test(RThread().RequestCount()==rqc+1);
sl@0
   522
		pS=(TRequestStatus*)(((TUint8*)&s)+0x80000);		// aligned, within chunk max size but invalid
sl@0
   523
		StartRequestCompleteThread(t,&pS);
sl@0
   524
		// Request status poked user side, so we expect a KERN-EXEC 3...
sl@0
   525
		test(t.ExitType()==EExitPanic);
sl@0
   526
		test(t.ExitReason()==ECausedException);
sl@0
   527
		test(t.ExitCategory()==KLitKernExec);
sl@0
   528
		CLOSE_AND_WAIT(t);
sl@0
   529
		test(pS==NULL);
sl@0
   530
		test(RThread().RequestCount()==rqc+1);
sl@0
   531
		}
sl@0
   532
#endif
sl@0
   533
sl@0
   534
	test.End();
sl@0
   535
sl@0
   536
	User::SetJustInTime(justInTime);
sl@0
   537
	return(KErrNone);
sl@0
   538
	}
sl@0
   539