diff --git a/repos/base/recipes/pkg/test-sanitizer/README b/repos/base/recipes/pkg/test-sanitizer/README new file mode 100644 index 0000000000..4d92afd803 --- /dev/null +++ b/repos/base/recipes/pkg/test-sanitizer/README @@ -0,0 +1 @@ +Test for sanitizer runtime error detection diff --git a/repos/base/recipes/pkg/test-sanitizer/archives b/repos/base/recipes/pkg/test-sanitizer/archives new file mode 100644 index 0000000000..0983fcb91c --- /dev/null +++ b/repos/base/recipes/pkg/test-sanitizer/archives @@ -0,0 +1,3 @@ +_/src/init +_/src/sanitizer +_/src/test-sanitizer diff --git a/repos/base/recipes/pkg/test-sanitizer/hash b/repos/base/recipes/pkg/test-sanitizer/hash new file mode 100644 index 0000000000..47a0e4143b --- /dev/null +++ b/repos/base/recipes/pkg/test-sanitizer/hash @@ -0,0 +1 @@ +2018-12-06-t c5ea39e824451955b77f5a1e832ee639a52497bf diff --git a/repos/base/recipes/pkg/test-sanitizer/runtime b/repos/base/recipes/pkg/test-sanitizer/runtime new file mode 100644 index 0000000000..749932e527 --- /dev/null +++ b/repos/base/recipes/pkg/test-sanitizer/runtime @@ -0,0 +1,33 @@ + + + + + + [init -> test-sanitizer]*runtime error: *index 2 out of bounds* + [init -> test-sanitizer]*runtime error: *store to null pointer + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/repos/base/recipes/src/test-sanitizer/content.mk b/repos/base/recipes/src/test-sanitizer/content.mk new file mode 100644 index 0000000000..63d393b0ce --- /dev/null +++ b/repos/base/recipes/src/test-sanitizer/content.mk @@ -0,0 +1,2 @@ +SRC_DIR = src/test/sanitizer +include $(GENODE_DIR)/repos/base/recipes/src/content.inc diff --git a/repos/base/recipes/src/test-sanitizer/hash b/repos/base/recipes/src/test-sanitizer/hash new file mode 100644 index 0000000000..525f35d8ec --- /dev/null +++ b/repos/base/recipes/src/test-sanitizer/hash @@ -0,0 +1 @@ +2018-11-27 4280725b29c79fbd31df0f9f96028206055d9142 diff --git a/repos/base/recipes/src/test-sanitizer/used_apis b/repos/base/recipes/src/test-sanitizer/used_apis new file mode 100644 index 0000000000..114c1f8638 --- /dev/null +++ b/repos/base/recipes/src/test-sanitizer/used_apis @@ -0,0 +1,2 @@ +base +sanitizer diff --git a/repos/base/src/test/sanitizer/main.cc b/repos/base/src/test/sanitizer/main.cc new file mode 100644 index 0000000000..accc3c0fee --- /dev/null +++ b/repos/base/src/test/sanitizer/main.cc @@ -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 +#include + +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; +} diff --git a/repos/base/src/test/sanitizer/target.mk b/repos/base/src/test/sanitizer/target.mk new file mode 100644 index 0000000000..97d98d802f --- /dev/null +++ b/repos/base/src/test/sanitizer/target.mk @@ -0,0 +1,4 @@ +TARGET = test-sanitizer +SRC_CC = main.cc +LIBS = base +SANITIZE_UNDEFINED = yes diff --git a/repos/gems/run/depot_autopilot.run b/repos/gems/run/depot_autopilot.run index 99346df259..3c587af358 100644 --- a/repos/gems/run/depot_autopilot.run +++ b/repos/gems/run/depot_autopilot.run @@ -603,6 +603,7 @@ set default_test_pkgs { test-rom_blk test-rom_filter test-rust + test-sanitizer test-sequence test-signal test-slab