Segfault when using type hints in return value, i.e. ts[Optional[float]]
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 441
- Forks
- 90
- Avg merge
- 1d 12m
- Merged PRs (30d)
- 5
Description
Describe the bug
Trying to run this node will segault, though it's not immediately clear you shouldn't do stuff like this.
import csp
from typing import Optional
@csp.node
def foo(x: csp.ts[object]) -> csp.ts[Optional[float]]:
if csp.ticked(x):
return 0.
To Reproduce
from datetime import datetime
csp.run(foo, csp.const(True), start_Time=datetime(2020,1,1))
Expected behavior
Error message without segfault
Error Message
[bt]: (0) printBacktrace()
[bt]: (1) sigabrt_handler(int, siginfo*, void*)
[bt]: (2) /lib64/libpthread.so.0(+0x12cf0) [0x7f366a7e2cf0]
[bt]: (3) /home/.conda/envs/csp39/bin/python(PyType_IsSubtype+0x10) [0x55e17f5ad100]
[bt]: (4) csp::python::CspTypeFactory::typeFromPyType(_object*)
[bt]: (5) /home_local/pt10597/github/csp/csp/lib/_cspimpl.so(+0x175831) [0x7f3629eda831]
[bt]: (6) /home/.conda/envs/csp39/bin/python(+0x1e7838) [0x55e17f5b7838]
[bt]: (7) /home/.conda/envs/csp39/bin/python(PyObject_Vectorcall+0x2c) [0x55e17f5ca5ac]
[bt]: (8) /home/.conda/envs/csp39/bin/python(_PyEval_EvalFrameDefault+0x716) [0x55e17f5bda36]
[bt]: (9) /home/.conda/envs/csp39/bin/python(_PyFunction_Vectorcall+0x181) [0x55e17f5e1031]
[bt]: (10) /home/.conda/envs/csp39/bin/python(PyObject_Call+0x130) [0x55e17f5ead30]
[bt]: (11) /home/.conda/envs/csp39/bin/python(_PyEval_EvalFrameDefault+0x47fc) [0x55e17f5c1b1c]
[bt]: (12) /home/.conda/envs/csp39/bin/python(+0x2a48bd) [0x55e17f6748bd]
[bt]: (13) /home/.conda/envs/csp39/bin/python(PyEval_EvalCode+0x9f) [0x55e17f673f4f]
[bt]: (14) /home/.conda/envs/csp39/bin/python(+0x2c2eaa) [0x55e17f692eaa]
[bt]: (15) /home/.conda/envs/csp39/bin/python(+0x2bea23) [0x55e17f68ea23]
[bt]: (16) /home/.conda/envs/csp39/bin/python(+0x2d3de0) [0x55e17f6a3de0]
[bt]: (17) /home/.conda/envs/csp39/bin/python(_PyRun_SimpleFileObject+0x1ae) [0x55e17f6a377e]
[bt]: (18) /home/.conda/envs/csp39/bin/python(_PyRun_AnyFileObject+0x44) [0x55e17f6a34a4]
[bt]: (19) /home/.conda/envs/csp39/bin/python(Py_RunMain+0x374) [0x55e17f69db94]
[bt]: (20) /home/.conda/envs/csp39/bin/python(Py_BytesMain+0x37) [0x55e17f663f47]
[bt]: (21) /lib64/libc.so.6(__libc_start_main+0xe5) [0x7f3669cbbd85]
[bt]: (22) /home/.conda/envs/csp39/bin/python(+0x293ded) [0x55e17f663ded]
Runtime Environment
0.0.1
3.11.7 | packaged by conda-forge | (main, Dec 23 2023, 14:43:09) [GCC 12.3.0]
linux
Additional context
I may fix this in python as I look at/refactor the type checking. However, posting this in case we want to fix at the C++ level instead (or want a quicker fix than what I'm working on).
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the provided csp.node and csp.run example, then start at CspTypeFactory::typeFromPyType, the entry point named in the stack trace. Trace how Optional[float] is handled across the Python and C++ type-checking boundary; done means the example reports an error without segfaulting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- stream-processing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100