From 01620fe9f0752e5257f19ecb35f58fd2fe2839f9 Mon Sep 17 00:00:00 2001 From: Antonio Cuni Date: Fri, 26 Mar 2021 10:53:19 +0100 Subject: [PATCH 1/6] add a todo --- hpy/debug/src/dhqueue.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hpy/debug/src/dhqueue.c b/hpy/debug/src/dhqueue.c index 1b319d698..00f7472bb 100644 --- a/hpy/debug/src/dhqueue.c +++ b/hpy/debug/src/dhqueue.c @@ -1,5 +1,7 @@ #include "debug_internal.h" +// TODO: we need to make DHQueue thread-safe if we want to use the same +// context in multiple threads void DHQueue_init(DHQueue *q) { q->head = NULL; q->tail = NULL; @@ -46,7 +48,7 @@ DebugHandle *DHQueue_popfront(DHQueue *q) void DHQueue_remove(DHQueue *q, DebugHandle *h) { #ifndef NDEBUG - // if we are debugging, let's check that h it's effectively in the queue + // if we are debugging, let's check that h is effectively in the queue DebugHandle *it = q->head; bool found = false; while(it != NULL) { From a9701aa0d90cad698995bf445c425ee3ba85a76d Mon Sep 17 00:00:00 2001 From: Antonio Cuni Date: Fri, 26 Mar 2021 10:59:33 +0100 Subject: [PATCH 2/6] we can simply pass HPy_NULL instead of an empty tuple when calling HPy_CallTupleDict. This simplifies a lot the code --- hpy/debug/src/debug_handles.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/hpy/debug/src/debug_handles.c b/hpy/debug/src/debug_handles.c index 9d3eda840..386652247 100644 --- a/hpy/debug/src/debug_handles.c +++ b/hpy/debug/src/debug_handles.c @@ -74,23 +74,10 @@ void DHPy_invalid_handle(HPyContext *dctx, DHPy dh) the callback and let the execution to continue, so that people can fix the warnings one by one. */ - // XXX: so far the only call API that we have is CallTupleDict, we - // should use a more C-friendly variant as soon as we have it. - UHPy uh_args = HPy_NULL; UHPy uh_res = HPy_NULL; - uh_args = HPyTuple_Pack(uctx, 0); - if (HPy_IsNull(uh_args)) { - print_error(uctx, "Error when preparing args to call the on_invalid_handle callback"); - goto exit; - } - uh_res = HPy_CallTupleDict(uctx, info->uh_on_invalid_handle, uh_args, HPy_NULL); - if (HPy_IsNull(uh_res)) { + uh_res = HPy_CallTupleDict(uctx, info->uh_on_invalid_handle, HPy_NULL, HPy_NULL); + if (HPy_IsNull(uh_res)) print_error(uctx, "Error when executing the on_invalid_handle callback"); - goto exit; - } - exit: - HPy_Close(uctx, uh_args); - HPy_Close(uctx, uh_res); } void DHPy_close(HPyContext *dctx, DHPy dh) From cf0f327030fad663ad6f5a9afefab4f33e17384e Mon Sep 17 00:00:00 2001 From: Antonio Cuni Date: Fri, 26 Mar 2021 15:12:41 +0100 Subject: [PATCH 3/6] ouch, this needs to be closed --- hpy/debug/src/debug_handles.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hpy/debug/src/debug_handles.c b/hpy/debug/src/debug_handles.c index 386652247..bfa9bc9cb 100644 --- a/hpy/debug/src/debug_handles.c +++ b/hpy/debug/src/debug_handles.c @@ -78,6 +78,7 @@ void DHPy_invalid_handle(HPyContext *dctx, DHPy dh) uh_res = HPy_CallTupleDict(uctx, info->uh_on_invalid_handle, HPy_NULL, HPy_NULL); if (HPy_IsNull(uh_res)) print_error(uctx, "Error when executing the on_invalid_handle callback"); + HPy_Close(uctx, uh_res); } void DHPy_close(HPyContext *dctx, DHPy dh) From 32df80ec4342800cd2b58371404b4554b6cd8083 Mon Sep 17 00:00:00 2001 From: Antonio Cuni Date: Fri, 26 Mar 2021 15:28:43 +0100 Subject: [PATCH 4/6] try to debug cppcheck: print the version and remove this option which seems unknown --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c9df51b8d..359b0ffbb 100644 --- a/Makefile +++ b/Makefile @@ -16,13 +16,13 @@ cppcheck-build-dir: cppcheck: cppcheck-build-dir # azure pipelines doesn't show stderr, so we write the errors to a file and cat it later :( + cppcheck --version cppcheck \ --error-exitcode=1 \ --cppcheck-build-dir=$(or ${CPPCHECK_BUILD_DIR}, .cppcheck) \ --output-file=$(or ${CPPCHECK_BUILD_DIR}, .cppcheck)/output.txt \ --enable=warning,performance,portability,information,missingInclude \ --inline-suppr \ - --suppress=allocaCalled \ -I hpy/devel/include/ \ -I hpy/devel/include/common/ \ -I hpy/devel/include/cpython/ \ From 9b6683a2ee7e35df135d07e0964746be44e0ab80 Mon Sep 17 00:00:00 2001 From: Antonio Cuni Date: Fri, 26 Mar 2021 15:45:34 +0100 Subject: [PATCH 5/6] try to reintroduce again this suppression --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 359b0ffbb..22edb8b8e 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,7 @@ cppcheck: cppcheck-build-dir --output-file=$(or ${CPPCHECK_BUILD_DIR}, .cppcheck)/output.txt \ --enable=warning,performance,portability,information,missingInclude \ --inline-suppr \ + --suppress=allocaCalled \ -I hpy/devel/include/ \ -I hpy/devel/include/common/ \ -I hpy/devel/include/cpython/ \ From a91f8f9eabf9ff14f1bf99b2567ea28f6e0551d5 Mon Sep 17 00:00:00 2001 From: Antonio Cuni Date: Fri, 26 Mar 2021 16:02:00 +0100 Subject: [PATCH 6/6] Disable cppcheck, it fails for no good reason :( See e.g. this run: https://dev.azure.com/pyhandle/hpy/_build/results?buildId=1327&view=logs&j=71490d96-a242-5f1c-bb38-546ccf5abc39&t=31ff8806-cfa1-5f20-3b24-e9367d546093 it fails with: nofile:0:0: information: Unmatched suppression: allocaCalled [unmatchedSuppression] which seems to suggest that --suppress=allocaCalled is not a valid option. However: 1) it worked until today 2) it works on my machine with the VERY SAME VERSION of cppcheck (1.90) 3) if I remove it, I get a bunch of errors called exactly "allocaCalled" --- azure-pipelines.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 14144a1c4..f28865ebf 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -129,15 +129,15 @@ jobs: python test/check_py27_compat.py displayName: 'check_py27_compat.py' -- job: CPPCheck - pool: - vmImage: 'ubuntu-latest' - displayName: "Run CPPCheck" - steps: - - template: azure-templates/cppcheck.yml - - template: azure-templates/python.yml - - script: make cppcheck - displayName: Run CPPCheck +# - job: CPPCheck +# pool: +# vmImage: 'ubuntu-latest' +# displayName: "Run CPPCheck" +# steps: +# - template: azure-templates/cppcheck.yml +# - template: azure-templates/python.yml +# - script: make cppcheck +# displayName: Run CPPCheck - job: infer pool: