Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: tests/exception_test/exception_crash_test.c

Issue 14876015: Add wrapper library for the nacl_irt_exception_handling IRT interface (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Cleanup + remove minidump_generator.gyp for now because of pthread.h problem in Gyp build Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/untrusted/nacl/nacl_exception.c ('k') | tests/exception_test/exception_test.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 #include <assert.h> 7 #include <assert.h>
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <string.h> 10 #include <string.h>
11 #include <unistd.h> 11 #include <unistd.h>
12 12
13 #include "native_client/src/include/nacl/nacl_exception.h" 13 #include "native_client/src/include/nacl/nacl_exception.h"
14 #include "native_client/src/trusted/service_runtime/include/sys/nacl_test_crash. h" 14 #include "native_client/src/trusted/service_runtime/include/sys/nacl_test_crash. h"
15 #include "native_client/src/untrusted/nacl/syscall_bindings_trampoline.h" 15 #include "native_client/src/untrusted/nacl/syscall_bindings_trampoline.h"
16 16
17 17
18 typedef void (*handler_func_t)(struct NaClExceptionContext *context);
19
20 char stack_in_rwdata[0x1000]; 18 char stack_in_rwdata[0x1000];
21 19
22 /* 20 /*
23 * Note that we have to provide an initialiser here otherwise gcc 21 * Note that we have to provide an initialiser here otherwise gcc
24 * defines this using ".comm" and the variable does not get put into a 22 * defines this using ".comm" and the variable does not get put into a
25 * read-only segment. 23 * read-only segment.
26 */ 24 */
27 const char stack_in_rodata[0x1000] = "blah"; 25 const char stack_in_rodata[0x1000] = "blah";
28 26
29 27
30 void test_bad_handler(void) { 28 void test_bad_handler(void) {
31 /* 29 /*
32 * Use an address that we know contains no valid code, yet is within 30 * Use an address that we know contains no valid code, yet is within
33 * the code segment range and is well-aligned. The bottom 64k of 31 * the code segment range and is well-aligned. The bottom 64k of
34 * address space is never mapped. 32 * address space is never mapped.
35 */ 33 */
36 handler_func_t handler = (handler_func_t) 0x1000; 34 nacl_exception_handler_t handler = (nacl_exception_handler_t) 0x1000;
37 int rc = NACL_SYSCALL(exception_handler)(handler, NULL); 35 int rc = NACL_SYSCALL(exception_handler)(handler, NULL);
38 assert(rc == 0); 36 assert(rc == 0);
39 fprintf(stderr, "** intended_exit_status=untrusted_segfault\n"); 37 fprintf(stderr, "** intended_exit_status=untrusted_segfault\n");
40 /* Cause crash. */ 38 /* Cause crash. */
41 *(volatile int *) 0 = 0; 39 *(volatile int *) 0 = 0;
42 } 40 }
43 41
44 42
45 #if defined(__i386__) || defined(__x86_64__) 43 #if defined(__i386__) || defined(__x86_64__)
46 44
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 TRY_TEST(test_bad_handler); 238 TRY_TEST(test_bad_handler);
241 TRY_TEST(test_stack_outside_sandbox); 239 TRY_TEST(test_stack_outside_sandbox);
242 TRY_TEST(test_stack_in_rwdata); 240 TRY_TEST(test_stack_in_rwdata);
243 TRY_TEST(test_stack_in_rodata); 241 TRY_TEST(test_stack_in_rodata);
244 TRY_TEST(test_stack_in_code); 242 TRY_TEST(test_stack_in_code);
245 TRY_TEST(test_crash_in_syscall); 243 TRY_TEST(test_crash_in_syscall);
246 244
247 fprintf(stderr, "Error: Unknown test: \"%s\"\n", argv[1]); 245 fprintf(stderr, "Error: Unknown test: \"%s\"\n", argv[1]);
248 return 1; 246 return 1;
249 } 247 }
OLDNEW
« no previous file with comments | « src/untrusted/nacl/nacl_exception.c ('k') | tests/exception_test/exception_test.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698