From: fennecdjay Date: Sun, 3 Nov 2019 22:17:30 +0000 (+0100) Subject: :art: coverage X-Git-Tag: nightly~2116^2~14 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=085db78798d90a65440afe53d5f341cb9f3b262d;p=gwion.git :art: coverage --- diff --git a/src/import/enum.c b/src/import/enum.c index cd5a2b96..bce6e62c 100644 --- a/src/import/enum.c +++ b/src/import/enum.c @@ -88,11 +88,13 @@ ANN Type gwi_enum_end(const Gwi gwi) { const Gwion gwion = gwi->gwion; const Enum_Def edef = new_enum_def(gwion->mp, gwi->ck->tmpl, gwi->ck->xid, loc(gwi)); + gwi->ck->tmpl = NULL; const m_bool ret = traverse_enum_def(gwion->env, edef); import_enum_end(gwi, &edef->values); const Type t = ret > 0 ? edef->t : NULL; free_enum_def(gwion->mp, edef); vector_release(&gwi->ck->v); + gwi->ck->v.ptr = NULL; ck_end(gwi); return t; } diff --git a/src/import/internals.c b/src/import/internals.c index 904003a9..240f9d36 100644 --- a/src/import/internals.c +++ b/src/import/internals.c @@ -56,5 +56,7 @@ ANN m_bool name_valid(const Gwi gwi, const m_str a) { ANN void gwi_reset(const Gwi gwi) { if(gwi->ck) ck_clean(gwi); + mp_free2(gwi->gwion->mp, sizeof(ImportCK), gwi->ck); + gwi->ck = NULL; env_reset(gwi->gwion->env); } diff --git a/tests/import/enum_fail3.c b/tests/import/enum_fail3.c new file mode 100644 index 00000000..e74e5f63 --- /dev/null +++ b/tests/import/enum_fail3.c @@ -0,0 +1,19 @@ +#include "gwion_util.h" +#include "gwion_ast.h" +#include "oo.h" +#include "vm.h" +#include "env.h" +#include "type.h" +#include "object.h" +#include "instr.h" +#include "gwion.h" +#include "value.h" +#include "operator.h" +#include "import.h" + +GWION_IMPORT(enum_test) { + GWI_BB(gwi_enum_ini(gwi, NULL)) + GWI_BB(gwi_enum_add(gwi, "adc", 0)) + GWI_BB(gwi_enum_ini(gwi, NULL)) + return GW_OK; +} diff --git a/tests/import/test.log b/tests/import/test.log new file mode 100644 index 00000000..72896812 --- /dev/null +++ b/tests/import/test.log @@ -0,0 +1,52 @@ +coverage.gw ==219564== Memcheck, a memory error detector +==219564== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. +==219564== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info +==219564== Command: ./../../gwion -p. -m dummy -d dummy coverage.gw +==219564== Parent PID: 219275 +==219564== +==219564== Invalid read of size 8 +==219564== at 0x145464: path_valid (checker.c:67) +==219564== by 0x145774: ck2list (checker.c:172) +==219564== by 0x145813: str2decl (checker.c:226) +==219564== by 0x12CC24: make_exp (union.c:24) +==219564== by 0x12C78F: gwi_item_ini (item.c:18) +==219564== by 0x4848958: import (coverage.c:81) +==219564== by 0x11DB4E: type_engine_init (engine.c:162) +==219564== by 0x117059: gwion_engine (gwion.c:41) +==219564== by 0x117059: gwion_ini (gwion.c:84) +==219564== by 0x116502: main (main.c:23) +==219564== Address 0x0 is not stack'd, malloc'd or (recently) free'd +==219564== +==219564== +==219564== Process terminating with default action of signal 11 (SIGSEGV): dumping core +==219564== Access not within mapped region at address 0x0 +==219564== at 0x145464: path_valid (checker.c:67) +==219564== by 0x145774: ck2list (checker.c:172) +==219564== by 0x145813: str2decl (checker.c:226) +==219564== by 0x12CC24: make_exp (union.c:24) +==219564== by 0x12C78F: gwi_item_ini (item.c:18) +==219564== by 0x4848958: import (coverage.c:81) +==219564== by 0x11DB4E: type_engine_init (engine.c:162) +==219564== by 0x117059: gwion_engine (gwion.c:41) +==219564== by 0x117059: gwion_ini (gwion.c:84) +==219564== by 0x116502: main (main.c:23) +==219564== If you believe this happened as a result of a stack +==219564== overflow in your program's main thread (unlikely but +==219564== possible), you can try to increase the size of the +==219564== main thread stack using the --main-stacksize= flag. +==219564== The main thread stack size used in this run was 8388608. +==219564== +==219564== HEAP SUMMARY: +==219564== in use at exit: 9,096,690 bytes in 460 blocks +==219564== total heap usage: 893 allocs, 433 frees, 9,197,246 bytes allocated +==219564== +==219564== LEAK SUMMARY: +==219564== definitely lost: 0 bytes in 0 blocks +==219564== indirectly lost: 0 bytes in 0 blocks +==219564== possibly lost: 0 bytes in 0 blocks +==219564== still reachable: 9,096,690 bytes in 460 blocks +==219564== suppressed: 0 bytes in 0 blocks +==219564== Rerun with --leak-check=full to see details of leaked memory +==219564== +==219564== For lists of detected and suppressed errors, rerun with: -s +==219564== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) diff --git a/tests/sh/import.sh b/tests/sh/import.sh index 6edaf1a9..0d4e0450 100644 --- a/tests/sh/import.sh +++ b/tests/sh/import.sh @@ -1,5 +1,5 @@ #!/bin/bash -# [test] #60 +# [test] #61 n=0 [ "$1" ] && n="$1"