diff --git a/README.rst b/README.rst
index 9303b697a..6068ff20f 100644
--- a/README.rst
+++ b/README.rst
@@ -185,6 +185,9 @@ Table of Defects
* - `exiv2 `_
- 20
- Exiv2 is a C++ library and a command-line utility to read, write, delete and modify Exif, IPTC, XMP and ICC image metadata
+ * - `gravity `_
+ - 3
+ - Gravity is a powerful, dynamically typed, lightweight, embeddable programming language written in C without any external dependencies (except for stdlib).
* - `jerryscript `_
- 11
- JerryScript is a lightweight JavaScript engine for resource-constrained devices such as microcontrollers.
@@ -237,7 +240,7 @@ Table of Defects
- 5
- Zsh is an extended Bourne shell with many improvements, including some features of Bash, ksh, and tcsh.
* - SUM
- - 215
+ - 218
- Sum of all defects
diff --git a/bugscpp/taxonomy/gravity/Dockerfile b/bugscpp/taxonomy/gravity/Dockerfile
new file mode 100644
index 000000000..82b53c7a8
--- /dev/null
+++ b/bugscpp/taxonomy/gravity/Dockerfile
@@ -0,0 +1,3 @@
+# Copyright 2021 Suresoft Technologies Inc.
+# Licensed under the MIT
+FROM hschoe/defects4cpp-ubuntu:gravity
diff --git a/bugscpp/taxonomy/gravity/__init__.py b/bugscpp/taxonomy/gravity/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/bugscpp/taxonomy/gravity/extra/0001/.dpp/run_test.py b/bugscpp/taxonomy/gravity/extra/0001/.dpp/run_test.py
new file mode 100644
index 000000000..fc8003514
--- /dev/null
+++ b/bugscpp/taxonomy/gravity/extra/0001/.dpp/run_test.py
@@ -0,0 +1,37 @@
+import subprocess
+import sys
+import shutil
+from pathlib import Path
+
+
+if __name__ == '__main__':
+ if len(sys.argv) < 2:
+ print("Usage: python run_test.py [INDEX]")
+ sys.exit(1)
+ index = int(sys.argv[1])
+
+ root_dir = Path('test/unittest')
+ disabled_dir = Path('test/unittest/disabled')
+ all_gravity_files = list(root_dir.rglob('*.gravity'))
+ all_gravity_files.remove(Path('test/unittest/include_test.gravity'))
+
+ sorted_gravity_files = sorted([f for f in all_gravity_files if disabled_dir not in f.parents])
+
+ # for i, v in enumerate(sorted_gravity_files):
+ # print(i+1, v)
+
+ unittest_dir = Path('unittest')
+ unittest_dir.mkdir(parents=True, exist_ok=True)
+
+ test_file = sorted_gravity_files[index - 1]
+ destination = unittest_dir / test_file.name
+ shutil.copyfile(test_file, destination)
+ result = subprocess.run(['./gravity', '-t', str(unittest_dir)], capture_output=True, text=True)
+ ret = 0
+ if result.returncode != 0:
+ print(f"Failed test {destination}")
+ print(result.stdout)
+ ret = 1
+
+ shutil.rmtree(unittest_dir)
+ exit(ret)
diff --git a/bugscpp/taxonomy/gravity/extra/0002/.dpp/run_test.py b/bugscpp/taxonomy/gravity/extra/0002/.dpp/run_test.py
new file mode 100644
index 000000000..ec8988766
--- /dev/null
+++ b/bugscpp/taxonomy/gravity/extra/0002/.dpp/run_test.py
@@ -0,0 +1,35 @@
+import subprocess
+import sys
+import shutil
+from pathlib import Path
+
+
+if __name__ == '__main__':
+ if len(sys.argv) < 2:
+ print("Usage: python run_test.py [INDEX]")
+ sys.exit(1)
+ index = int(sys.argv[1])
+
+ root_dir = Path('test/unittest')
+ disabled_dir = Path('test/unittest/disabled')
+ all_gravity_files = list(root_dir.rglob('*.gravity'))
+ all_gravity_files.remove(Path('test/unittest/include_test.gravity'))
+
+ sorted_gravity_files = sorted([f for f in all_gravity_files if disabled_dir not in f.parents])
+
+ unittest_dir = Path('unittest_test')
+ unittest_dir.mkdir(parents=True, exist_ok=True)
+
+ test_file = sorted_gravity_files[index - 1]
+ destination = unittest_dir / test_file.name
+ shutil.copyfile(test_file, destination)
+ result = subprocess.run(['./unittest', str(unittest_dir)], capture_output=True, text=True)
+ ret = 0
+ if result.returncode != 0:
+ print(f"Failed test {destination}")
+ print(result.stdout)
+ ret = 1
+
+ shutil.rmtree(unittest_dir)
+ exit(ret)
+
diff --git a/bugscpp/taxonomy/gravity/extra/0003/.dpp/run_test.py b/bugscpp/taxonomy/gravity/extra/0003/.dpp/run_test.py
new file mode 100644
index 000000000..d9794fb6a
--- /dev/null
+++ b/bugscpp/taxonomy/gravity/extra/0003/.dpp/run_test.py
@@ -0,0 +1,37 @@
+import subprocess
+import sys
+import shutil
+from pathlib import Path
+
+
+if __name__ == '__main__':
+ if len(sys.argv) < 2:
+ print("Usage: python run_test.py [INDEX]")
+ sys.exit(1)
+ index = int(sys.argv[1])
+
+ root_dir = Path('test/unittest')
+ disabled_dir = Path('test/unittest/disabled')
+ all_gravity_files = list(root_dir.rglob('*.gravity'))
+ all_gravity_files.remove(Path('test/unittest/include_test.gravity'))
+
+ sorted_gravity_files = sorted([f for f in all_gravity_files if disabled_dir not in f.parents])
+
+ # for i, v in enumerate(sorted_gravity_files):
+ # print(i+1, v)
+
+ unittest_dir = Path('unittest_test')
+ unittest_dir.mkdir(parents=True, exist_ok=True)
+
+ test_file = sorted_gravity_files[index - 1]
+ destination = unittest_dir / test_file.name
+ shutil.copyfile(test_file, destination)
+ result = subprocess.run(['./unittest', str(unittest_dir)], capture_output=True, text=True)
+ ret = 0
+ if result.returncode != 0:
+ print(f"Failed test {destination}")
+ print(result.stdout)
+ ret = 1
+
+ shutil.rmtree(unittest_dir)
+ exit(ret)
diff --git a/bugscpp/taxonomy/gravity/meta.json b/bugscpp/taxonomy/gravity/meta.json
new file mode 100644
index 000000000..78cb3b130
--- /dev/null
+++ b/bugscpp/taxonomy/gravity/meta.json
@@ -0,0 +1,102 @@
+{
+ "info": {
+ "url": "https://github.com/marcobambini/gravity",
+ "short-desc": "Gravity is a powerful, dynamically typed, lightweight, embeddable programming language written in C without any external dependencies (except for stdlib).",
+ "vcs": "git"
+ },
+ "common": {
+ "build": {
+ "commands": [
+ {
+ "type": "docker",
+ "lines": [
+ "make clean",
+ "make -j @DPP_PARALLEL_BUILD@"
+ ]
+ }
+ ]
+ },
+ "build-coverage": {
+ "commands": [
+ {
+ "type": "docker",
+ "lines": [
+ "make clean",
+ "make CFLAGS=\"-Isrc/compiler/ -Isrc/runtime/ -Isrc/shared/ -Isrc/utils/ -Isrc/optionals/ -std=gnu99 -fgnu89-inline -fPIC -DBUILD_GRAVITY_API -g -O0 --coverage\" -j @DPP_PARALLEL_BUILD@"
+ ]
+ }
+ ]
+ },
+ "test-type": "ctest",
+ "test": {
+ "commands": [
+ {
+ "type": "docker",
+ "lines": [
+ "bash -c \"python .dpp/run_test.py $(cat DPP_TEST_INDEX)\""
+ ]
+ }
+ ]
+ },
+ "test-coverage": {
+ "commands": [
+ {
+ "type": "docker",
+ "lines": [
+ "bash -c \"python .dpp/run_test.py $(cat DPP_TEST_INDEX)\""
+ ]
+ }
+ ]
+ },
+ "gcov": {
+ "exclude": [],
+ "commands": [
+ {
+ "type": "docker",
+ "lines": [
+ "mkdir gcov",
+ "bash -c 'find ./src -type f -name \"*.o\" -exec gcov @DPP_ADDITIONAL_GCOV_OPTIONS@ --preserve-paths {} \\;'",
+ "bash -c 'mv *.gcov ./gcov'",
+ "bash -c 'find ./gcov -type f -name \"*.gcda\" -delete'"
+ ]
+ }
+ ]
+ }
+ },
+ "defects": [
+ {
+ "id": 1,
+ "hash": "63fa9bf0393dbbdfa1d4cb1f532df6e099f7c0b7",
+ "num_cases": 290,
+ "case": [93],
+ "tags": [
+ "single-line",
+ "modified"
+ ],
+ "description": "Fixed a possible GC issue (unit test added)"
+ },
+ {
+ "id": 2,
+ "hash": "8cf6379645f458384fc44b627662de5345696072",
+ "num_cases": 229,
+ "case": [158],
+ "tags": [
+ "multi-lines",
+ "memory-error"
+ ],
+ "description": "Fixed a crash that can occurs when an insane amount of memory is requested. Introduced a new MAX_MEMORY_BLOCK define."
+ },
+ {
+ "id": 3,
+ "hash": "9231f9e1a7d52712a06390ece55a30fe0d60677a",
+ "num_cases": 241,
+ "case": [184],
+ "tags": [
+ "multi-line",
+ "modified",
+ "added"
+ ],
+ "description": "Fixed a rare issue that can occurs in register allocation."
+ }
+ ]
+}
diff --git a/bugscpp/taxonomy/gravity/patch/0001-buggy.patch b/bugscpp/taxonomy/gravity/patch/0001-buggy.patch
new file mode 100644
index 000000000..ca16043e1
--- /dev/null
+++ b/bugscpp/taxonomy/gravity/patch/0001-buggy.patch
@@ -0,0 +1,27 @@
+From ea4f453c4141ac4787a31a9ebd2f3dee0e70a407 Mon Sep 17 00:00:00 2001
+From: Hansol Choe
+Date: Wed, 20 Dec 2023 01:58:04 +0000
+Subject: [PATCH] buggy
+
+---
+ src/runtime/gravity_vm.c | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/src/runtime/gravity_vm.c b/src/runtime/gravity_vm.c
+index c80a32a..ce159ed 100644
+--- a/src/runtime/gravity_vm.c
++++ b/src/runtime/gravity_vm.c
+@@ -1451,9 +1451,8 @@ static bool gravity_vm_exec (gravity_vm *vm) {
+ if (op != MOVE) RUNTIME_ERROR("Wrong OPCODE in CLOSURE statement");
+ closure->upvalue[i] = (p2) ? gravity_capture_upvalue (vm, fiber, &stackstart[p1]) : frame->closure->upvalue[p1];
+ }
+-
+- SETVALUE(r1, VALUE_FROM_OBJECT(closure));
+ gravity_gc_setenabled(vm, true);
++ SETVALUE(r1, VALUE_FROM_OBJECT(closure));
+ DISPATCH();
+ }
+
+--
+2.25.1
+
diff --git a/bugscpp/taxonomy/gravity/patch/0002-buggy.patch b/bugscpp/taxonomy/gravity/patch/0002-buggy.patch
new file mode 100644
index 000000000..4cd14a34b
--- /dev/null
+++ b/bugscpp/taxonomy/gravity/patch/0002-buggy.patch
@@ -0,0 +1,111 @@
+From 5f98597fa82f2c403055c3be212ad2b66d836c6a Mon Sep 17 00:00:00 2001
+From: Hansol Choe
+Date: Wed, 20 Dec 2023 04:19:16 +0000
+Subject: [PATCH] buggy
+
+---
+ src/runtime/gravity_core.c | 35 ++++++++++-------------------------
+ src/shared/gravity_value.h | 5 ++---
+ 2 files changed, 12 insertions(+), 28 deletions(-)
+
+diff --git a/src/runtime/gravity_core.c b/src/runtime/gravity_core.c
+index ffeee2e..6f569d3 100644
+--- a/src/runtime/gravity_core.c
++++ b/src/runtime/gravity_core.c
+@@ -932,12 +932,10 @@ static bool list_join (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, ui
+
+ // create a new empty buffer
+ uint32_t alloc = (uint32_t) (marray_size(list->array) * 64);
+- if (alloc > MAX_MEMORY_BLOCK) RETURN_ERROR("Maximum memory block size reached (max %d, requested %d).", MAX_MEMORY_BLOCK, alloc);
+-
+ uint32_t len = 0;
+ uint32_t seplen = (sep) ? VALUE_AS_STRING(GET_VALUE(1))->len : 0;
+- char *_buffer = mem_alloc(alloc);
+- if (!_buffer) RETURN_ERROR("Not enought memory to allocate a buffer for the join operation.");
++ char *buffer = mem_alloc(alloc);
++ assert(buffer);
+
+ register gravity_int_t n = marray_size(list->array);
+ register gravity_int_t i = 0;
+@@ -946,47 +944,34 @@ static bool list_join (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, ui
+ while (i < n) {
+ gravity_value_t value = convert_value2string(vm, marray_get(list->array, i));
+ if (VALUE_ISA_ERROR(value)) {
+- mem_free(_buffer);
++ mem_free(buffer);
+ RETURN_VALUE(value, rindex);
+ }
+
+- // compute string to appen
+ const char *s2 = VALUE_AS_STRING(value)->s;
+ uint32_t req = VALUE_AS_STRING(value)->len;
+- uint32_t free_mem = alloc - len;
++ uint32_t free = alloc - len;
+
+ // check if buffer needs to be reallocated
+- if (free_mem < req + seplen) {
+- uint64_t to_alloc = alloc + (req + seplen) * 2 + 4096;
+-
+- // sanity check
+- if (to_alloc > MAX_MEMORY_BLOCK) {
+- mem_free(_buffer);
+- RETURN_ERROR("Maximum memory block size reached (max %d, requested %lld).", MAX_MEMORY_BLOCK, to_alloc);
+- }
+-
+- _buffer = mem_realloc(_buffer, (uint32_t)to_alloc);
+- if (!_buffer) {
+- mem_free(_buffer);
+- RETURN_ERROR("Not enought memory to re-allocate a buffer for the join operation.");
+- }
+- alloc = (uint32_t)to_alloc;
++ if (free < req + seplen) {
++ buffer = mem_realloc(buffer, (alloc * 2) + req + seplen);
++ alloc += alloc + req + seplen;
+ }
+
+ // copy s2 to into buffer
+- memcpy(_buffer+len, s2, req);
++ memcpy(buffer+len, s2, req);
+ len += req;
+
+ // check for separator string
+ if (i+1 < n && seplen) {
+- memcpy(_buffer+len, sep, seplen);
++ memcpy(buffer+len, sep, seplen);
+ len += seplen;
+ }
+
+ ++i;
+ }
+
+- gravity_string_t *result = gravity_string_new(vm, _buffer, len, alloc);
++ gravity_string_t *result = gravity_string_new(vm, buffer, len, alloc);
+ RETURN_VALUE(VALUE_FROM_OBJECT(result), rindex);
+ }
+
+diff --git a/src/shared/gravity_value.h b/src/shared/gravity_value.h
+index 57f97c0..26e6167 100644
+--- a/src/shared/gravity_value.h
++++ b/src/shared/gravity_value.h
+@@ -66,8 +66,8 @@
+ extern "C" {
+ #endif
+
+-#define GRAVITY_VERSION "0.2.8" // git tag 0.2.8
+-#define GRAVITY_VERSION_NUMBER 0x000208 // git push --tags
++#define GRAVITY_VERSION "0.2.8"
++#define GRAVITY_VERSION_NUMBER 0x000208
+ #define GRAVITY_BUILD_DATE __DATE__
+
+ #define GRAVITY_ENABLE_DOUBLE 1 // if 1 enable gravity_float_t to be a double (instead of a float)
+@@ -113,7 +113,6 @@ extern "C" {
+ #define MAX_IVARS 768 // 2^10 - 2^8
+ #define MAX_ALLOCATION 4194304 // 1024 * 1024 * 4 (about 4 millions entry)
+ #define MAX_CCALLS 100 // default maximum number of nested C calls
+-#define MAX_MEMORY_BLOCK 157286400 // 150MB
+
+ #define DEFAULT_CONTEXT_SIZE 256 // default VM context entries (can grow)
+ #define DEFAULT_MINSTRING_SIZE 32 // minimum string allocation size
+--
+2.25.1
+
diff --git a/bugscpp/taxonomy/gravity/patch/0003-buggy.patch b/bugscpp/taxonomy/gravity/patch/0003-buggy.patch
new file mode 100644
index 000000000..35afc7373
--- /dev/null
+++ b/bugscpp/taxonomy/gravity/patch/0003-buggy.patch
@@ -0,0 +1,103 @@
+From 632ec81aae87dc6af03e0dfe182fdfecd7495704 Mon Sep 17 00:00:00 2001
+From: Hansol Choe
+Date: Wed, 20 Dec 2023 04:09:36 +0000
+Subject: [PATCH] buggy
+
+---
+ src/compiler/gravity_codegen.c | 15 +++------------
+ src/compiler/gravity_ircode.c | 12 +-----------
+ src/compiler/gravity_ircode.h | 1 -
+ src/shared/gravity_value.h | 4 ++--
+ 4 files changed, 6 insertions(+), 26 deletions(-)
+
+diff --git a/src/compiler/gravity_codegen.c b/src/compiler/gravity_codegen.c
+index 8f4fa46..f1fc6b2 100644
+--- a/src/compiler/gravity_codegen.c
++++ b/src/compiler/gravity_codegen.c
+@@ -1223,7 +1223,7 @@ static void visit_unary_expr (gvisitor_t *self, gnode_unary_expr_t *node) {
+ }
+
+ static void visit_postfix_expr (gvisitor_t *self, gnode_postfix_expr_t *node) {
+- DEBUG_CODEGEN("visit_postfix_expr");
++ DEBUG_CODEGEN("visit_call_expr");
+
+ // node->list usually cannot be NULL, it is NULL only as a result of a static enum transformation (see semacheck2.c)
+ if (node->list == NULL) {
+@@ -1462,16 +1462,7 @@ static void visit_postfix_expr (gvisitor_t *self, gnode_postfix_expr_t *node) {
+ marray_destroy(self_list);
+ ircode_pop_context(code);
+
+- // temp fix for not optimal register allocation algorithm generated code
+- uint32_t temp_register = ircode_register_first_temp_available(code);
+- if (temp_register < dest_register) {
+- // free dest register
+- ircode_register_pop(code);
+- // allocate a new register (that I am now sure does not have holes)
+- temp_register = ircode_register_push_temp(code);
+- ircode_add(code, MOVE, temp_register, dest_register, 0);
+- ircode_register_clear(code, dest_register);
+- }
++
+
+ CODEGEN_COUNT_REGISTERS(n2);
+ CODEGEN_ASSERT_REGISTERS(n1, n2, (is_assignment) ? -1 : 1);
+diff --git a/src/compiler/gravity_ircode.c b/src/compiler/gravity_ircode.c
+index baa7ca6..7987371 100644
+--- a/src/compiler/gravity_ircode.c
++++ b/src/compiler/gravity_ircode.c
+@@ -95,7 +95,7 @@ static inst_t *inst_new (opcode_t op, uint32_t p1, uint32_t p2, uint32_t p3, opt
+ #if GRAVITY_OPCODE_DEBUG
+ if (tag == LABEL_TAG) {
+ DEBUG_OPCODE("LABEL %d", p1);
+- } else if (tag != PRAGMA_MOVE_OPTIMIZATION){
++ } else {
+ const char *op_name = opcode_name(op);
+
+ if (op == LOADI) {
+@@ -475,16 +475,6 @@ uint32_t ircode_register_push (ircode_t *code, uint32_t nreg) {
+ return nreg;
+ }
+
+-uint32_t ircode_register_first_temp_available (ircode_t *code) {
+- for (uint32_t i=0; istate[i] == false) {
+- return i;
+- }
+- }
+- // 0 means no registers available
+- code->error = true;
+- return 0;
+-}
+
+ uint32_t ircode_register_push_temp (ircode_t *code) {
+ uint32_t value = ircode_register_new(code);
+diff --git a/src/compiler/gravity_ircode.h b/src/compiler/gravity_ircode.h
+index cd56ecb..13ab752 100644
+--- a/src/compiler/gravity_ircode.h
++++ b/src/compiler/gravity_ircode.h
+@@ -103,7 +103,6 @@ bool ircode_register_istemp (ircode_t *code, uint32_t n);
+ uint32_t ircode_register_push_temp (ircode_t *code);
+ uint32_t ircode_register_push (ircode_t *code, uint32_t nreg);
+ uint32_t ircode_register_pop (ircode_t *code);
+-uint32_t ircode_register_first_temp_available (ircode_t *code);
+ uint32_t ircode_register_pop_context_protect (ircode_t *code, bool protect);
+ bool ircode_register_protect_outside_context (ircode_t *code, uint32_t nreg);
+ void ircode_register_protect_in_context (ircode_t *code, uint32_t nreg);
+diff --git a/src/shared/gravity_value.h b/src/shared/gravity_value.h
+index 4bda567..091fcc7 100644
+--- a/src/shared/gravity_value.h
++++ b/src/shared/gravity_value.h
+@@ -66,8 +66,8 @@
+ extern "C" {
+ #endif
+
+-#define GRAVITY_VERSION "0.3.6" // git tag 0.3.6
+-#define GRAVITY_VERSION_NUMBER 0x000306 // git push --tags
++#define GRAVITY_VERSION "0.3.5" // git tag 0.3.5
++#define GRAVITY_VERSION_NUMBER 0x000305 // git push --tags
+ #define GRAVITY_BUILD_DATE __DATE__
+
+ #ifndef GRAVITY_ENABLE_DOUBLE
+--
+2.25.1
+