base: 'sanitizer' test

Issue #3072
This commit is contained in:
Christian Prochaska 2018-12-06 05:19:19 +01:00 committed by Norman Feske
parent 5569d2ddc2
commit 9c8e76b190
10 changed files with 82 additions and 0 deletions

View File

@ -0,0 +1 @@
Test for sanitizer runtime error detection

View File

@ -0,0 +1,3 @@
_/src/init
_/src/sanitizer
_/src/test-sanitizer

View File

@ -0,0 +1 @@
2018-12-06-t c5ea39e824451955b77f5a1e832ee639a52497bf

View File

@ -0,0 +1,33 @@
<runtime ram="32M" caps="1000" binary="init">
<events>
<timeout meaning="failed" sec="10" />
<log meaning="succeeded">
[init -> test-sanitizer]*runtime error: *index 2 out of bounds*
[init -> test-sanitizer]*runtime error: *store to null pointer
</log>
</events>
<content>
<rom label="ld.lib.so"/>
<rom label="libsanitizer_common.lib.so"/>
<rom label="libubsan.lib.so"/>
<rom label="test-sanitizer"/>
</content>
<config>
<parent-provides>
<service name="CPU"/>
<service name="LOG"/>
<service name="PD"/>
<service name="ROM"/>
</parent-provides>
<default-route>
<any-service> <any-child/> <parent/> </any-service>
</default-route>
<default caps="100"/>
<start name="test-sanitizer">
<resource name="RAM" quantum="16M"/>
</start>
</config>
</runtime>

View File

@ -0,0 +1,2 @@
SRC_DIR = src/test/sanitizer
include $(GENODE_DIR)/repos/base/recipes/src/content.inc

View File

@ -0,0 +1 @@
2018-11-27 4280725b29c79fbd31df0f9f96028206055d9142

View File

@ -0,0 +1,2 @@
base
sanitizer

View File

@ -0,0 +1,34 @@
/*
* \brief Sanitizer test
* \author Christian Prochaska
* \date 2018-12-06
*/
/*
* Copyright (C) 2018 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#include <base/component.h>
#include <base/log.h>
extern void sanitizer_init(Genode::Env &);
void Component::construct(Genode::Env &env)
{
env.exec_static_constructors();
sanitizer_init(env);
/* test array out-of-bounds access detection */
int array[1];
int volatile i = 2;
Genode::log("array[", i, "] = ", array[i]);
/* test null pointer access detection */
int * volatile ptr = nullptr;
*ptr = 0x55;
}

View File

@ -0,0 +1,4 @@
TARGET = test-sanitizer
SRC_CC = main.cc
LIBS = base
SANITIZE_UNDEFINED = yes

View File

@ -603,6 +603,7 @@ set default_test_pkgs {
test-rom_blk test-rom_blk
test-rom_filter test-rom_filter
test-rust test-rust
test-sanitizer
test-sequence test-sequence
test-signal test-signal
test-slab test-slab