Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def requirements(self):
def configure(self):
if self.options.build_tests:
self.options["catch2"].with_main = True
if self.settings.os == "Macos":
if self.settings.compiler == "clang":
self.options["backward-cpp"].stack_details = "backtrace_symbol"

def generate(self):
Expand Down
8 changes: 4 additions & 4 deletions lib/resdata/rd_coarse_cell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <resdata/rd_kw_magic.hpp>
#include <resdata/rd_coarse_cell.hpp>
#include <stdexcept>

/*

Expand Down Expand Up @@ -258,10 +259,9 @@ void rd_coarse_cell_update_index(rd_coarse_cell_type *coarse_cell,
if (int_vector_size(coarse_cell->active_values) > 1) {
if (int_vector_reverse_iget(coarse_cell->active_values, -2) !=
active_value)
util_abort(
"%s: Sorry - current coarse cell implementation requires that "
"all active cells have the same active value\n",
__func__);
throw std::invalid_argument(
"Coarse cell implementation requires that "
"all active cells have the same active value");
}
}

Expand Down
8 changes: 5 additions & 3 deletions lib/resdata/rd_file_kw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,17 @@ bool rd_file_kw_equal(const rd_file_kw_type *kw1, const rd_file_kw_type *kw2) {
}

static void rd_file_kw_assert_kw(const rd_file_kw_type *file_kw) {
if (!file_kw->kw)
throw std::invalid_argument("Found invalid keyword in file");
if (!rd_type_is_equal(rd_file_kw_get_data_type(file_kw),
rd_kw_get_data_type(file_kw->kw)))
util_abort("%s: type mismatch between header and file.\n", __func__);
throw std::invalid_argument("type mismatch between header and file.");

if (file_kw->kw_size != rd_kw_get_size(file_kw->kw))
util_abort("%s: size mismatch between header and file.\n", __func__);
throw std::invalid_argument("size mismatch between header and file.");

if (strcmp(file_kw->header, rd_kw_get_header(file_kw->kw)) != 0)
util_abort("%s: name mismatch between header and file.\n", __func__);
throw std::invalid_argument("name mismatch between header and file.");
}

static void rd_file_kw_drop_kw(rd_file_kw_type *file_kw,
Expand Down
2 changes: 1 addition & 1 deletion lib/resdata/rd_file_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ rd_file_view_type *rd_file_view_alloc(ERT::FortIO *fortio, int *flags,
static int rd_file_view_get_global_index(const rd_file_view_type *rd_file_view,
const char *kw, int ith) {
const auto &index_vector = rd_file_view->kw_index.at(kw);
return index_vector[ith];
return index_vector.at(ith);
}

/**
Expand Down
5 changes: 5 additions & 0 deletions lib/resdata/rd_grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1690,8 +1690,13 @@ static void rd_grid_update_index(rd_grid_type *rd_grid) {

static rd_coarse_cell_type *
rd_grid_get_or_create_coarse_cell(rd_grid_type *rd_grid, int coarse_nr) {

if (coarse_nr < 0)
throw std::invalid_argument("Negative coarse number for cell in file");

while (static_cast<int>(rd_grid->coarse_cells.size()) <= coarse_nr)
rd_grid->coarse_cells.emplace_back(nullptr, &rd_coarse_cell_free);

if (!rd_grid->coarse_cells[coarse_nr])
rd_grid->coarse_cells[coarse_nr].reset(rd_coarse_cell_alloc());

Expand Down
5 changes: 4 additions & 1 deletion lib/resdata/rd_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
#include <cstring>
#include <cctype>

#include <fmt/core.h>
#include <fmt/format.h>

#include <ert/util/util.hpp>
#include <resdata/rd_type.hpp>
#include <stdexcept>
#include <string>

#define RD_TYPE_NAME_CHAR "CHAR"
#define RD_TYPE_NAME_FLOAT "REAL"
Expand Down Expand Up @@ -134,7 +137,7 @@ rd_data_type rd_type_create_from_name(const char *type_name) {
else if (strncmp(type_name, RD_TYPE_NAME_BOOL, RD_TYPE_LENGTH) == 0)
return RD_BOOL;
else {
util_abort("%s: unrecognized type name:%s \n", __func__, type_name);
throw std::invalid_argument(fmt::format("unrecognized type name:{}", std::string(type_name)));
}
}

Expand Down
25 changes: 25 additions & 0 deletions tests/fuzzing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Install with

```
CC=/usr/bin/clang CXX=/usr/bin/clang++
CFLAGS="-O1 -g -fno-omit-frame-pointer -fno-lto -fsanitize=address,fuzzer-no-link"
CXXFLAGS="-O1 -g -fno-omit-frame-pointer -fno-lto -fsanitize=address,fuzzer-no-link"
LDFLAGS="-fno-lto -fsanitize=address,fuzzer-no-link"
CMAKE_ARGS="-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF" pip install .
```
Run with

```
LD_PRELOAD="$(python -c
"import atheris; print(atheris.path())")/asan_with_fuzzer.so" python
tests/fuzzing/smry_fuzz_target.py -detect_leaks=0 -max_len=22000000 -r
ss_limit_mb=32000000000 tests/fuzzing/smry_corpus/
```

Its beneficial to also use

```
export ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer-18
```

to get debug symbols.
Empty file added tests/fuzzing/__init__.py
Empty file.
29 changes: 29 additions & 0 deletions tests/fuzzing/grid_corpus/002f2449086de445e69bb01436281b375bcf1ceb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/

SPECGRID
2 2 2 1 F /?

COORD
0.0 0.00000000E+02 -0.1000000,0E1 +00 01 0.10000000E+01 000Í0+0 1 0 0.00000000 01 0.101 0M@ 0ÿÿ 1.ÿÿ 00000000E -0 0.0
0.1000000 0.1 0.1000000 0.10000000E+00
0.000E+00& 0.10000000E+01 0E+01 00000E01
0.1 0 0.+ 01 00°E+ 0 0 0.0E+00 0000 0>0
0.5166ã00 0.1 0.10000000E+01 0.10000кÔÏ1
0.000E 0ÿÿÿ0000Ò0Eu01 0000 0.00000000E+00
0.0 0 0E+00 0.00000E0+00
00000000E+ 0. 000000E+00 000E
0000001E+ 00.0000000E+00
/

ZCORN
0.000-0000E+ 0.2000000Mß 5.00+00E+00 00000ÈÏ켧 0.00000001E+00 .00000 0.00000*0E+00 0.0000~+00 0. 0ic_er 000°00E 0.0000000E+00 0. 0.1000900 .1 0.10000000E+01 0000E+01
000E+01 0E+01 00000E01
00E0 0.1 0 0.+ 01 0.10%0000000E0 0 0.00000 00 0.00 0.00c 0.000°00E 0.00000+00 0Ò.
1.1ã00 0.1 0.10000000E+01 +01
0E+01 0.10000000E+21 0.10~000°0EØÏÎß 0 0.1 0 0.+ 0 1 0.%01 0.1000 0.1000000 0 0.1000E'2MAPAX1 01
0.10000000+0ÿÿ 0.1+01 0.1000000E+01 0. 0.2 0.20000000E+01 0.24199999E+01
0.20001 0.200006151 0.20000E+01 00000E+02
/

ACTNUM
0 1 1 5 1 1Š 1 1J
Binary file not shown.
Binary file not shown.
36 changes: 36 additions & 0 deletions tests/fuzzing/grid_corpus/00a15de7416923962ba3403d396506988f52f953
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
MAPU'7'
/

' ÿÿ '
/

SPECGRID
2 2 2 1 F /?

COORD
0.0 0.00000000E+00 -0.10000000E1 +00 01 0.10000000E+01 000Í0MAPA0M+0 1 0 0.00000000 01 0.101 0M@PA0?E+01 0ÿÿ 1.ÿÿ 00000000E+00 -0.10000000E++00` 0.0
0.1000000 0.1 0.1000000 0.10000000E+00
0.000E+01& 0.10000000E+01 0E+01 00000E01
0.1 0 0.+ 01 00°E+ 0 0 0.0E+00 0000 0>0
0.5166ã00 0.1 0.10000000E+01 0.10000кÔÏ1
0.000E 0ÿÿÿ0000Ò0E+01 0000 0.00000000E+00
0.0 0 0.08p0000E+00 0.00000E0+00
00000000E+ 0. 000000E+00 000E
0.0000001E+ 00.0000000E+00
/

ZCORN
0.000-0000E+00 0.2000000Mß 5.00+00E+00 00000ÈÏ켧 0.00000001E+00
.00000 0.000000*0E+00 0.0000~+00 0. 0.00St11gic_er 000°00E 0.00000000E+00 0.0
0.1000900 0.1 0.10000000E+01 0000E+01
0.000E$+ 0.100000E+01 .10000000E+01 000E0 0.1 0 0.+ 01 0.10%0000000E0 0 0.00000 00 0.00000000E;00
0.00c 0.000°00E 0.000000000+00 0Ò.
1.1ã00 0.1 0.10000000E+01 00000E+01
0E+01 0.10000000E+21 0.100000°0EØÏÎß 0 0.1 0 0.+ 0 1 0.%01 0.1000 0.1000000 0 0.1000E'2MAPAX1 0+01
0.10000000+0ÿÿ 0.100+01 0.10000000E+01 0. 0.2 0.20000000E+01 0.24199999E+01
0.20001 0.200006151 0.200000E+01 00000E+02
/

ACTNUM
0 1 1 5 1 1
1 1J
Binary file not shown.
Binary file not shown.
25 changes: 25 additions & 0 deletions tests/fuzzing/grid_corpus/01f3095d12cf870395e8d451d315755eceb44ef5
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/

SPECGRID
2 2 2 1 F /?

COORD
.5 0.E+02 -0.0,0E +00 01 0000E+01 000Í0+0 1 0 .000°00E 0 0Ò.
1.1ã00 .1 +01 +01
01 +21 0.1 0000 0.1 20.100000 00E+00& 0E+01 0E+Î1 0000 0.1 0 0.+ 01 00°E+ 0 0 0.0E+00 00 5>0
0 0.1 01000E+01 000E 00Eu02 0000 0
3.0 0 0E+00$ 3.0000E00
00000ß000E+ 0. 000d00E+00 0 0 00E
00+ 00.00
/
ZCORN
00 01 0.299E+01
41 0.200006151 15E+01 00000E+ 0.0 0.$ 0ic_000°00E +00 0. 900 .1 0.00+01 00 01
0E+01 0E+01 00E00'
0 01) 1 0 0.1 0 0.+ 0 1000E8 0 0.00000 00 0.0o 0.00c 0.000°0 .1 +01 +01
01 +21 0.1 0 0.1 0 0.+ 0 1 0.%01 0.1000 0.1000000› 0 0.MAPAXÏé 0 +00 0. 0900 .1 0.1000+01 0000E+01
000E+01 0E+0 0.2012302 15E+01 0&0000+E2
/

ACTNUM 0 1 1 5 1 0Š
0E+01 1J
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
SPECGRID 2 2 2
COORD 0 0 0 13*0 0 1 12*0 0 0 0 0 5 0 0 0 1 2 2 0 0 0 0 +0 1 2 0 0 0 1 0 0
/
ZCORN
0 1 11*0 0@ 0 0 0 1 0 1 2 0 2 2 0 0 1 32*0 0 0 0 0 0
/

ACTNUM 0 0 2 1 0 7 1 2
Binary file not shown.
32 changes: 32 additions & 0 deletions tests/fuzzing/grid_corpus/03f6412f159448f096fe4c345bfbd096cbe8d71f
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
MAPU'7'
/ÿÿ '
/

SPECGRID
2 2 2 1 F /?

COORD
0.0 0.00000000E+02 -0.1000000,0E1 +00 01 0.10000000E+01 000Í0MAPA0M+0 1 0 0.00000000 01 0.101 0M@PA0?E+01 0ÿÿ 1.ÿÿ 00000000E+00 -010000000E++00` 0.0
0.1000000 0.1 0.1000000 0.10000000E+00
0.000E+00& 0.10000000E+01 0E+01 00000E01
0.1 0 0.+ 01 00°E+ 0 0 0.0E+00 0000 0>0
0.5166ã00 0.1 0.10000000E+01 0.10000кÔÏ1
0.000E 0ÿÿÿ0000Ò0Eu01 0000 0.00000000E+00
0.0 0 0E+00 0.00000E0+00
00000000E+ 0. 000000E+00 000E
0.0000001E+ 00.0000000E+00
/

ZCORN
0.000-0000E+00 0.2000000Mß 5.00+00E+00 00000ÈÏ켧 0.00000001E+00 .00000 0.000000*0E+00 0.0000~+00 0. 0.00St11gic_er 000°00E 0.00000000E+00 0.0
0.1000900 .1 0.10000000E+01 0000E+01
0.000E$+ 0.100000E+01 .10000000E+01 000E0 0.1 0 0.+ 01 0.10%0000000E0 0 0.00000 00 0.00 0.00c 0.000°00E 0.000000000+00 0Ò.
1.1ã00 0.1 0.10000000E+01 00000E+01
0E+01 0.10000000E+21 0.100000°0EØÏÎß 0 0.1 0 0.+ 0 1 0.%01 0.1000 0.1000000 0 0.1000E'2MAPAX1 01
0.10000000+0ÿÿ 0.100+01 0.10000000E+01 0. 0.2 0.20000000E+01 0.24199999E+01
0.20001 0.200006151 0.20000E+01 00000E+02
/

ACTNUM
0 1 1 5 1 1
1 1J
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
32 changes: 32 additions & 0 deletions tests/fuzzing/grid_corpus/0517e0c40d1eb4410a3c9d85072652c856bb71d4
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
MAPU'7'
/ÿÿ '
/

SPECGRID
2 2 2 1 F /?

COORD
0.0 0.00000000E+02 -0.1000000,0E1 +00 01 0.10000000E+01 000Í0MAPA0M+0 1 0 0.00000000 01 0.101 0M@ 0ÿÿ 1.ÿÿ 00000000E+00 -010000000E++00` 0.0
0.1000000 0.1 0.1000000 0.10000000E+00
0.000E+00& 0.10000000E+01 0E+01 00000E01
0.1 0 0.+ 01 00°E+ 0 0 0.0E+00 0000 0>0
0.5166ã00 0.1 0.10000000E+01 0.10000кÔÏ1
0.000E 0ÿÿÿ0000Ò0Eu01 0000 0.00000000E+00
0.0 0 0E+00 0.00000E0+00
00000000E+ 0. 000000E+00 000E
0.0000001E+ 00.0000000E+00
/

ZCORN
0.000-0000E+00 0.2000000Mß 5.00+00E+00 00000ÈÏ켧 0.00000001E+00 .00000 0.000000*0E+00 0.0000~+00 0. 0.00St11gic_er 000°00E 0.0000000E+00 0.0
0.1000900 .1 0.10000000E+01 0000E+01
0.000E$+ 0.100000E+01 .10000000E+01 00E0 0.1 0 0.+ 01 0.10%0000000E0 0 0.00000 00 0.00 0.00c 0.000°00E 0.000000000+00 0Ò.
1.1ã00 0.1 0.10000000E+01 00000E+01
0E+01 0.10000000E+21 0.100000°0EØÏÎß 0 0.1 0 0.+ 0 1 0.%01 0.1000 0.1000000 0 0.1000E'2MAPAX1 01
0.10000000+0ÿÿ 0.100+01 0.10000000E+01 0. 0.2 0.20000000E+01 0.24199999E+01
0.20001 0.200006151 0.20000E+01 00000E+02
/

ACTNUM
0 1 1 5 1 1
1 1J
38 changes: 38 additions & 0 deletions tests/fuzzing/grid_corpus/052615e01d9b95abee90bd5b3942a7d247116553
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
MAPU'7'
/

' ÿÿ '
/

SPECGRID
2 2 2 1 F /?

COORD
0.0 0.00000000E+00 -0.10000000E1 0.00000
0.000000E+00 01 0.10000000E+01 00E00Í0MAPA0M+01 0 0.00000000E+00 01 0.101 0M@PA0?E+01 0ÿÿ 1.ÿÿ 00000000E+00 -0.10000000E++00 0.0
0.1000000 0.1 0.1000000 0.10000000E+00
0.000E+01& 0.10000000E+01 0.10000000E+01 00000E01
0.1 0 0.+ 01 000E+ 0 0 0.0E+00 0000 0>0
0.5166ã00 0.1 0.10000000E+01 0.10000кÔÏ1
0.000E 0ÿÿÿ000000E+01 0000 0.00000000E+00
0.0 0 0.08p0000E+00 0.00000E0+00
00000000E+00 0. 000000E+00 000E
0.00000001E+ 00.0000000E+00
/

ZCORN
0.000-0000E+00 0.2000000MAPAXß 5.00+00E+00 00000ÈÏϺÔÏÏß 0.00000001E+00
.00000 0.000000*0E+00 0.0000~+00 0. 0.00St11gic_er 000°00E 0.00000000E+00 0.0
0.1000900 0.1 0.10000000E+01 0000E+01
0.000E+ 0.100000E+01 .10000000E+01 000E01
0.1 0 0.+ 01 0.10%0000000E+ 0 0 0.000005+00 0000 0.00000000E;00
0.00c 0.00000°00E 0.000000000+00 0Ò.
0.1ã00 0.1 0.10000000E+01 00000E+01
0E+01 0.10000000E+21 0.10000000EØÏÎß 0 0.1 0 0.+ 01 0.10%01 0.1000 0.10000000E01.500 0 0.1000E'2MAPAX1 0+01
0.10000000+0ÿÿ 0.100+01 0.10000000E+01 0. 0.2 0.20000000E+01 0.20199999E+01
0.20001 0.20000615E+01 0.200000E+01 00000E+02
/

ACTNUM
0 1 1 5 1 1
1 1J
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SPECGRID 2 2 2
COORD 0 0 0 13*0 0 1 12*0 0 0 1 11*0 0 0 0 5 0 0 0 1 2 20
/
ZCORN
0 1 11*0 0@ 0 0 0 1 0 1 2 0 2 2 0 0 1 32*0 0 0 0 0 0
/
ACTNUM 0 0 2 1 0 7 1 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

SPECGRID
2
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
SPECGRID 2 2 2
COORD 0 0 0 13*0 0 1 12*0 0@ 0 0 0 5 0 0 0 1 2 2 0 0 0 0 +0 1 2 0 0 0 1 0 0
/
ZCORN
0 1 11*0 0@ 0 0 0 1 0 1 2 0 2 2 0 0 1 32*0 0 0 0 0 0
/

ACTNUM 0 0 2 1 0 7 1 2
Binary file not shown.
Binary file not shown.
Binary file not shown.
29 changes: 29 additions & 0 deletions tests/fuzzing/grid_corpus/08ee54b18ffc65b499ea7be7806ef27d4b81f88b
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/

SPECGRID
2 2 2 1 F /?

COORD
0.0 0.E+02 -0.1000000,0E1 +00 01 0!10000000E+01 000Í0+0 1 0 0.00000000 01 0.101 0M@ 0ÿÿ 1.ÿÿ 00000000E -0 0.0
0.1000000 0.1 0.1000000 0.10000000E+00
0.000E+00& 0.10000000E+01 0E+01 00000E01
0.1 0 0.+ 01 00°E+ 0 0 0.0E+00 0000 0>0
0.5166ã00 0.1 0.10000000E+01 0.10000кÔÏ1
0.000E 0ÿÿÿ0000Ò0Eu01 0000 0.00000000E+00
0.0 0 0E+00 0.00000E0+00
00000000E+ 0. 000000E+00 000E
00001E+ 00.0000000E+00
/

ZCORN
0.000-0000E+ 0.2000000Mß 5.00+00E+00 00008ÈÏ켧 0.00000001E+00 .00000 0.00000*0E+00 0.0000~+00 0. 0ic_er 000°00E 0.0000000E+00 0. 0.1000900 .1 0.10000000E+01 0000E+01
000E+01 0E+01 00E01
00E0 0.1 0 0.+ 01 0.10%0000000E0 0 0.00000 00 0.0o 0.00c 0.000°00E 0.00001+00 0Ò.
1.1ã00 .1 +01 +01
01 +21 0.10~000°0EØÏÎß, 0 0.1 0 0.+ 0 1 0.%01 0.1000 0.1000000 0 0.1000E'2MAPAX1 01
0.10000000+0ÿÿ 0.1+01 0.1000000E+01 0. 0.2 0+01 0.24199999E+01
0.20001 0.200006151 0.2615E+01 00000E+02
/

ACTNUM
0 1 1 5 1 1Š 1 1J
Loading
Loading