pypy / pypy

PyPy is a very fast and compliant implementation of the Python language.
https://pypy.org
Other
1.1k stars 60 forks source link

rpython: unexpected None (causing SEGV) in metainterp.opencoder.TraceIterator #3966

Open gitlab-importer opened 1 year ago

gitlab-importer commented 1 year ago

In Heptapod by @dl on Jul 20, 2023, 17:06

There is an unexpected None occurring in metainterp.opencoder.TraceIterator. This None likely also causes an observed SEGV in the interpreter built with rpython.

To reproduce

(github branch: https://github.com/demaere-oiie/rptoy/tree/mutual-recursion-parity)

  1. execute jit.py
    $ python ${PYPYPATH}/pypy2.7-v7.3.12-src/pytest.py jit.py -s
  2. type q repeatedly in the PyGame popup windows (containing jit CFGs) to dismiss them.
  3. you will get a failure of TestLLtype.test_loop:

    
    self = <rpython.jit.metainterp.opencoder.TraceIterator object at 0x7f7898b07190>
    i = 0
    
    def _get(self, i):
        res = self._cache[i]
    >       assert res is not None
    E       assert None is not None

../pypy2.7-v7.3.12-src/rpython/jit/metainterp/opencoder.py:133: AssertionError

4. change `jit.py:20` to read `...nction_threshold=10","1"])` instead of `10`.
5. re-executing `jit.py` no longer fails in `TestLLtype.test_loop`.

Probably related
======
1. build `rptoy-c` via `rpython -O jit rptoy.py`
2. `rptoy-c hgcd function_threshold=1619` will die with (on OSX) `Segmentation fault: 11`
3. `rptoc-y hgcd function_threshold=-1` succeeds

Better trace
======
`rptoy-c hgcd function_threshold=10 10` results in actual trace output, ending with:

... 946: APP 5 4 949: RHO RPython traceback: File "rpython_jit_metainterp_1.c", line 41580, in CompileData_optimize_trace File "rpython_jit_metainterp_optimizeopt.c", line 23642, in UnrollOptimizer_optimize_preamble File "rpython_jit_metainterp_optimizeopt.c", line 21366, in Optimizer_propagate_all_forward File "rpython_jit_metainterp_1.c", line 33447, in TraceIterator_next File "rpython_jit_metainterp_1.c", line 44887, in TraceIterator__untag Fatal RPython error: AssertionError Abort trap: 6

gitlab-importer commented 1 year ago

In Heptapod by @dl on Jul 21, 2023, 11:57

There is a CutTrace which is (probably?) malformed: we try to untag one of the arguments of a binary operator, but the tagged argument is 3, which untags to 0 (probably not what was desired?) leading to the None in the cache.

mattip commented 1 month ago

Can we close this or is it still active?

cfbolz commented 1 month ago

the bug is probably still there, I just never got around to looking into it :-(