[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC 5/8] static-analyzer: Enforce coroutine_fn restrictions on func
From: |
Víctor Colombo |
Subject: |
Re: [RFC 5/8] static-analyzer: Enforce coroutine_fn restrictions on function pointers |
Date: |
Mon, 4 Jul 2022 11:16:57 -0300 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 |
On 02/07/2022 08:33, Alberto Faria wrote:
Alberto, hello. I was testing this patch as follows:
./static-analyzer.py build target/ppc/mmu-hash64.c
<snip>
@@ -627,9 +744,31 @@ def is_coroutine_fn(node: Cursor) -> bool:
else:
break
- return node.kind == CursorKind.FUNCTION_DECL and is_annotated_with(
- node, "coroutine_fn"
- )
+ if node.kind in [CursorKind.DECL_REF_EXPR, CursorKind.MEMBER_REF_EXPR]:
+ node = node.referenced
+
+ # ---
+
+ if node.kind == CursorKind.FUNCTION_DECL:
And I receive an exception on the line above saying that node is of type
NoneType. Seems that `node = node.referenced` is setting `node` to None
in this case.
I was unable to understand the root cause of it. Is this an incorrect
usage of the tool from my part? Full error message below
Traceback (most recent call last):
File "./static-analyzer.py", line 327, in analyze_translation_unit
checker(tu, context.absolute_path, log)
File "./static-analyzer.py", line 613, in check_coroutine_pointers
and is_coroutine_fn(right)
File "./static-analyzer.py", line 781, in is_coroutine_fn
if node.kind == CursorKind.FUNCTION_DECL:
AttributeError: 'NoneType' object has no attribute 'kind'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker
result = (True, func(*args, **kwds))
File "/usr/lib/python3.8/multiprocessing/pool.py", line 48, in mapstar
return list(map(*args))
File "./static-analyzer.py", line 329, in analyze_translation_unit
raise RuntimeError(f"Error analyzing {relative_path}") from e
RuntimeError: Error analyzing target/ppc/mmu-hash64.c
"""
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "./static-analyzer.py", line 893, in <module>
main()
File "./static-analyzer.py", line 123, in main
analyze_translation_units(args, contexts)
File "./static-analyzer.py", line 240, in analyze_translation_units
results = pool.map(analyze_translation_unit, contexts)
File "/usr/lib/python3.8/multiprocessing/pool.py", line 364, in map
return self._map_async(func, iterable, mapstar, chunksize).get()
File "/usr/lib/python3.8/multiprocessing/pool.py", line 771, in get
raise self._value
RuntimeError: Error analyzing target/ppc/mmu-hash64.c
> + return is_annotated_with(node, "coroutine_fn")
+
+ if node.kind in [
+ CursorKind.FIELD_DECL,
+ CursorKind.VAR_DECL,
+ CursorKind.PARM_DECL,
+ ]:
+
+ if is_annotated_with(node, "coroutine_fn"):
+ return True
+
+ # TODO: If type is typedef or pointer to typedef, follow typedef.
+
+ return False
+
+ if node.kind == CursorKind.TYPEDEF_DECL:
+ return is_annotated_with(node, "coroutine_fn")
+
+ return False
Best regards,
--
Víctor Cora Colombo
Instituto de Pesquisas ELDORADO
Aviso Legal - Disclaimer <https://www.eldorado.org.br/disclaimer.html>
- [RFC 0/8] Introduce an extensible static analyzer, Alberto Faria, 2022/07/02
- [RFC 1/8] Add an extensible static analyzer, Alberto Faria, 2022/07/02
- [RFC 2/8] Drop some unused static function return values, Alberto Faria, 2022/07/02
- [RFC 3/8] static-analyzer: Enforce coroutine_fn restrictions for direct calls, Alberto Faria, 2022/07/02
- [RFC 4/8] Fix some direct calls from non-coroutine_fn to coroutine_fn, Alberto Faria, 2022/07/02
- [RFC 5/8] static-analyzer: Enforce coroutine_fn restrictions on function pointers, Alberto Faria, 2022/07/02
- Re: [RFC 5/8] static-analyzer: Enforce coroutine_fn restrictions on function pointers,
Víctor Colombo <=
[RFC 6/8] Fix some coroutine_fn indirect calls and pointer assignments, Alberto Faria, 2022/07/02
[RFC 7/8] block: Add no_coroutine_fn marker, Alberto Faria, 2022/07/02
[RFC 8/8] Avoid calls from coroutine_fn to no_coroutine_fn, Alberto Faria, 2022/07/02
Re: [RFC 0/8] Introduce an extensible static analyzer, Paolo Bonzini, 2022/07/02
Re: [RFC 0/8] Introduce an extensible static analyzer, Daniel P . Berrangé, 2022/07/04