Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

segfault in PythonAwaitable_Check moving dates back and forth #107

Closed
wesgarland opened this issue Jul 14, 2023 · 1 comment · Fixed by #122
Closed

segfault in PythonAwaitable_Check moving dates back and forth #107

wesgarland opened this issue Jul 14, 2023 · 1 comment · Fixed by #122

Comments

@wesgarland
Copy link
Collaborator

Repro from pmjs:

python.eval('(lambda x: throughJS(x))', { throughJS: x=>x })(new Date())

Version:
0.0.1.dev1024+117d00f
932a3ce

Stack:

Thread 1 "python" received signal SIGSEGV, Segmentation fault.
PythonAwaitable_Check (obj=obj@entry=<datetime.datetime at remote 0x7ffff2b3bc30>) at /home/wes/git/PythonMonkey/src/PromiseType.cc:150
150	  Py_DECREF(inspect);
(gdb) bt
#0  PythonAwaitable_Check (obj=obj@entry=<datetime.datetime at remote 0x7ffff2b3bc30>) at /home/wes/git/PythonMonkey/src/PromiseType.cc:150
#1  0x00007ffff6a26710 in jsTypeFactory (cx=cx@entry=0x555555cb4090, object=<datetime.datetime at remote 0x7ffff2b3bc30>) at /home/wes/git/PythonMonkey/src/jsTypeFactory.cc:167
#2  0x00007ffff6a277c4 in callJSFunc (jsCxThisFuncTuple=<optimized out>, args=(<datetime.datetime at remote 0x7ffff2b3bc30>,)) at /home/wes/git/PythonMonkey/src/pyTypeFactory.cc:178
#3  0x00005555556b0cc8 in cfunction_call (func=<built-in method JSFunctionCallable of tuple object at remote 0x7ffff2b67b40>, args=<optimized out>, kwargs=<optimized out>)
    at ../Objects/methodobject.c:552
#4  0x00005555556a772b in _PyObject_MakeTpCall (tstate=0x555555b5bf80, callable=<built-in method JSFunctionCallable of tuple object at remote 0x7ffff2b67b40>, args=<optimized out>, 
    nargs=<optimized out>, keywords=0x0) at ../Objects/call.c:215
#5  0x000055555569fb2c in _PyObject_VectorcallTstate (kwnames=0x0, nargsf=<optimized out>, args=0x7ffff6b7bea0, callable=<optimized out>, tstate=<optimized out>)
    at ../Include/cpython/abstract.h:112
#6  _PyObject_VectorcallTstate (kwnames=0x0, nargsf=<optimized out>, args=0x7ffff6b7bea0, callable=<optimized out>, tstate=<optimized out>) at ../Include/cpython/abstract.h:99
#7  PyObject_Vectorcall (kwnames=0x0, nargsf=<optimized out>, args=0x7ffff6b7bea0, callable=<optimized out>) at ../Include/cpython/abstract.h:123
#8  call_function (kwnames=0x0, oparg=<optimized out>, pp_stack=<synthetic pointer>, trace_info=0x7fffffffca70, tstate=<optimized out>) at ../Python/ceval.c:5891
#9  _PyEval_EvalFrameDefault (tstate=<optimized out>, f=<optimized out>, throwflag=<optimized out>) at ../Python/ceval.c:4213
#10 0x00005555556b14ec in _PyEval_EvalFrame (throwflag=0, f=Frame 0x7ffff6b7bd30, for file <string>, line 1, in <lambda> (x=<datetime.datetime at remote 0x7ffff2b3bc30>), 
    tstate=0x555555b5bf80) at ../Include/internal/pycore_ceval.h:46
#11 _PyEval_Vector (kwnames=<optimized out>, argcount=<optimized out>, args=<optimized out>, locals=0x0, con=0x7ffff2b71490, tstate=0x555555b5bf80) at ../Python/ceval.c:5065
#12 _PyFunction_Vectorcall (func=<function at remote 0x7ffff2b71480>, stack=<optimized out>, nargsf=<optimized out>, kwnames=<optimized out>) at ../Objects/call.c:342
#13 0x00007ffff6a26b4f in callPyFunc (cx=0x555555cb4090, argc=<optimized out>, vp=0x555555dd2a90) at /home/wes/git/PythonMonkey/src/jsTypeFactory.cc:231
#14 0x00007ffff4b55ed9 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct, js::CallReason) ()
   from /home/wes/git/PythonMonkey/python/pythonmonkey/libmozjs-102.so
#15 0x00007ffff4b501a4 in Interpret(JSContext*, js::RunState&) () from /home/wes/git/PythonMonkey/python/pythonmonkey/libmozjs-102.so
#16 0x00007ffff4b4731a in js::RunScript(JSContext*, js::RunState&) () from /home/wes/git/PythonMonkey/python/pythonmonkey/libmozjs-102.so
#17 0x00007ffff4b57187 in js::ExecuteKernel(JSContext*, JS::Handle<JSScript*>, JS::Handle<JSObject*>, js::AbstractFramePtr, JS::MutableHandle<JS::Value>) ()
   from /home/wes/git/PythonMonkey/python/pythonmonkey/libmozjs-102.so
#18 0x00007ffff4b79e4c in EvalKernel(JSContext*, JS::Handle<JS::Value>, EvalType, js::AbstractFramePtr, JS::Handle<JSObject*>, unsigned char*, JS::MutableHandle<JS::Value>) ()
   from /home/wes/git/PythonMonkey/python/pythonmonkey/libmozjs-102.so
#19 0x00007ffff4b79562 in js::IndirectEval(JSContext*, unsigned int, JS::Value*) () from /home/wes/git/PythonMonkey/python/pythonmonkey/libmozjs-102.so
#20 0x00007ffff4b55ed9 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct, js::CallReason) ()
   from /home/wes/git/PythonMonkey/python/pythonmonkey/libmozjs-102.so
#21 0x00007ffff4b501a4 in Interpret(JSContext*, js::RunState&) () from /home/wes/git/PythonMonkey/python/pythonmonkey/libmozjs-102.so
#22 0x00007ffff4b4731a in js::RunScript(JSContext*, js::RunState&) () from /home/wes/git/PythonMonkey/python/pythonmonkey/libmozjs-102.so
#23 0x00007ffff4b561cf in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct, js::CallReason) ()
   from /home/wes/git/PythonMonkey/python/pythonmonkey/libmozjs-102.so
#24 0x00007ffff4b56817 in js::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, js::AnyInvokeArgs const&, JS::MutableHandle<JS::Value>, js::CallReason) ()
   from /home/wes/git/PythonMonkey/python/pythonmonkey/libmozjs-102.so
#25 0x00007ffff4bedeb7 in JS_CallFunctionValue(JSContext*, JS::Handle<JSObject*>, JS::Handle<JS::Value>, JS::HandleValueArray const&, JS::MutableHandle<JS::Value>) ()
   from /home/wes/git/PythonMonkey/python/pythonmonkey/libmozjs-102.so
#26 0x00007ffff6a27878 in callJSFunc (jsCxThisFuncTuple=<optimized out>, args=<optimized out>) at /usr/local/include/mozjs-102/js/RootingAPI.h:1216
#27 0x00005555556b0cc8 in cfunction_call (func=<built-in method JSFunctionCallable of tuple object at remote 0x7ffff2b67d00>, args=<optimized out>, kwargs=<optimized out>)
    at ../Objects/methodobject.c:552
#28 0x00005555556a772b in _PyObject_MakeTpCall (tstate=0x555555b5bf80, callable=<built-in method JSFunctionCallable of tuple object at remote 0x7ffff2b67d00>, args=<optimized out>, 
    nargs=<optimized out>, keywords=0x0) at ../Objects/call.c:215
#29 0x00005555556a00e7 in _PyObject_VectorcallTstate (kwnames=0x0, nargsf=<optimized out>, args=<optimized out>, 
    callable=<built-in method JSFunctionCallable of tuple object at remote 0x7ffff2b67d00>, tstate=<optimized out>) at ../Include/cpython/abstract.h:112
#30 _PyObject_VectorcallTstate (kwnames=0x0, nargsf=<optimized out>, args=0x555555ef18c0, callable=<built-in method JSFunctionCallable of tuple object at remote 0x7ffff2b67d00>, 
    tstate=<optimized out>) at ../Include/cpython/abstract.h:99
#31 PyObject_Vectorcall (kwnames=0x0, nargsf=<optimized out>, args=0x555555ef18c0, callable=<built-in method JSFunctionCallable of tuple object at remote 0x7ffff2b67d00>)
    at ../Include/cpython/abstract.h:123
#32 call_function (kwnames=0x0, oparg=<optimized out>, pp_stack=<synthetic pointer>, trace_info=0x7fffffffdf20, tstate=<optimized out>) at ../Python/ceval.c:5891
#33 _PyEval_EvalFrameDefault (tstate=<optimized out>, f=<optimized out>, throwflag=<optimized out>) at ../Python/ceval.c:4181
#34 0x00005555556b14ec in _PyEval_EvalFrame (throwflag=0, 
--Type <RET> for more, q to quit, c to continue without paging--
    f=Frame 0x555555ef16f0, for file /home/wes/git/PythonMonkey/tests/js/../../pmjs, line 203, in repl (save_history=<function at remote 0x7ffff2b712d0>, atexit=<module at remote 0x7ffff2b864d0>, sigint_handler=<function at remote 0x7ffff2b713f0>), tstate=0x555555b5bf80) at ../Include/internal/pycore_ceval.h:46
#35 _PyEval_Vector (kwnames=<optimized out>, argcount=<optimized out>, args=<optimized out>, locals=0x0, con=0x7ffff6d63da0, tstate=0x555555b5bf80) at ../Python/ceval.c:5065
#36 _PyFunction_Vectorcall (func=<function at remote 0x7ffff6d63d90>, stack=<optimized out>, nargsf=<optimized out>, kwnames=<optimized out>) at ../Objects/call.c:342
#37 0x0000555555699a1d in _PyObject_VectorcallTstate (kwnames=0x0, nargsf=<optimized out>, args=0x555555ddeb18, callable=<function at remote 0x7ffff6d63d90>, tstate=0x555555b5bf80)
    at ../Include/cpython/abstract.h:114
#38 PyObject_Vectorcall (kwnames=0x0, nargsf=<optimized out>, args=0x555555ddeb18, callable=<function at remote 0x7ffff6d63d90>) at ../Include/cpython/abstract.h:123
#39 call_function (kwnames=0x0, oparg=<optimized out>, pp_stack=<synthetic pointer>, trace_info=0x7fffffffe0f0, tstate=<optimized out>) at ../Python/ceval.c:5891
#40 _PyEval_EvalFrameDefault (tstate=<optimized out>, f=<optimized out>, throwflag=<optimized out>) at ../Python/ceval.c:4213
#41 0x00005555556b14ec in _PyEval_EvalFrame (throwflag=0, 
    f=Frame 0x555555dde960, for file /home/wes/git/PythonMonkey/tests/js/../../pmjs, line 309, in main (enterRepl=True, forceRepl=False, globalInitModule={}, opts=[], args=[], output=None, verbose=False), tstate=0x555555b5bf80) at ../Include/internal/pycore_ceval.h:46
#42 _PyEval_Vector (kwnames=<optimized out>, argcount=<optimized out>, args=<optimized out>, locals=0x0, con=0x7ffff2b71250, tstate=0x555555b5bf80) at ../Python/ceval.c:5065
#43 _PyFunction_Vectorcall (func=<function at remote 0x7ffff2b71240>, stack=<optimized out>, nargsf=<optimized out>, kwnames=<optimized out>) at ../Objects/call.c:342
#44 0x0000555555699a1d in _PyObject_VectorcallTstate (kwnames=0x0, nargsf=<optimized out>, args=0x7ffff6d29da8, callable=<function at remote 0x7ffff2b71240>, tstate=0x555555b5bf80)
    at ../Include/cpython/abstract.h:114
#45 PyObject_Vectorcall (kwnames=0x0, nargsf=<optimized out>, args=0x7ffff6d29da8, callable=<function at remote 0x7ffff2b71240>) at ../Include/cpython/abstract.h:123
#46 call_function (kwnames=0x0, oparg=<optimized out>, pp_stack=<synthetic pointer>, trace_info=0x7fffffffe2c0, tstate=<optimized out>) at ../Python/ceval.c:5891
#47 _PyEval_EvalFrameDefault (tstate=<optimized out>, f=<optimized out>, throwflag=<optimized out>) at ../Python/ceval.c:4213
#48 0x0000555555696176 in _PyEval_EvalFrame (throwflag=0, f=Frame 0x7ffff6d29c40, for file /home/wes/git/PythonMonkey/tests/js/../../pmjs, line 312, in <module> (), tstate=0x555555b5bf80)
    at ../Include/internal/pycore_ceval.h:46
#49 _PyEval_Vector (tstate=0x555555b5bf80, con=<optimized out>, locals=<optimized out>, args=<optimized out>, argcount=<optimized out>, kwnames=<optimized out>) at ../Python/ceval.c:5065
#50 0x000055555578bc56 in PyEval_EvalCode (co=<code at remote 0x7ffff6c72c30>, 
    globals={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/wes/git/PythonMonkey/tests/js/../../pmjs') at remote 0x7ffff6c010f0>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff6d905e0>, '__file__': '/home/wes/git/PythonMonkey/tests/js/../../pmjs', '__cached__': None, 'sys': <module at remote 0x7ffff6d7e250>, 'os': <module at remote 0x7ffff6c24720>, 'readline': <module at remote 0x7ffff6ccd800>, 'signal': <module at remote 0x7ffff6cce660>, 'getopt': <module at remote 0x7ffff6cce930>, 'pm': <module at remote 0x7ffff6add620>, 'globalThis': {}, 'requirePath': False, 'repl': <function at remote 0x7ffff6d63d90>, 'usage': <function at remote 0x7ffff2b71090>, 'initGlobalThis': <function at remote 0x7ffff2b711b0>, 'main': <function at remote 0x7ffff2b71240>}, locals=<optimized out>) at ../Python/ceval.c:1134
#51 0x00005555557b8b18 in run_eval_code_obj (tstate=0x555555b5bf80, co=0x7ffff6c72c30, 
    globals={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/wes/git/PythonMonkey/tests/js/../../pmjs') at remote 0x7ffff6c010f0>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff6d905e0>, '__file__': '/home/wes/git/PythonMonkey/tests/js/../../pmjs', '__cached__': None, 'sys': <module at remote 0x7ffff6d7e250>, 'os': <module at remote 0x7ffff6c24720>, 'readline': <module at remote 0x7ffff6ccd800>, 'signal': <module at remote 0x7ffff6cce660>, 'getopt': <module at remote 0x7ffff6cce930>, 'pm': <module at remote 0x7ffff6add620>, 'globalThis': {}, 'requirePath': False, 'repl': <function at remote 0x7ffff6d63d90>, 'usage': <function at remote 0x7ffff2b71090>, 'initGlobalThis': <function at remote 0x7ffff2b711b0>, 'main': <function at remote 0x7ffff2b71240>}, 
    locals={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/wes/git/PythonMonkey/tests/js/../../pmjs') at remote 0x7ffff6c010f0>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff6d905e0>, '__file__': '/home/wes/git/PythonMonkey/tests/js/../../pmjs', '__cached__': None, 'sys': <module at remote 0x7ffff6d7e250>, 'os': <module at remote 0x7ffff6c24720>, 'readline': <module at remote 0x7ffff6ccd800>, 'signal': <module at remote 0x7ffff6cce660>, 'getopt': <module at remote 0x7ffff6cce930>, 'pm': <module at remote 0x7ffff6add620>, 'globalThis': {}, 'requirePath': False, 'repl': <function at remote 0x7ffff6d63d90>, 'usage': <function at remote 0x7ffff2b71090>, 'initGlobalThis': <function at remote 0x7ffff2b711b0>, 'main': <function at remote 0x7ffff2b71240>}) at ../Python/pythonrun.c:1291
#52 0x00005555557b196b in run_mod (mod=<optimized out>, filename=<optimized out>, 
    globals={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/wes/git/PythonMonkey/tests/js/../../pmjs') at remote 0x7ffff6c010f0>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff6d905e0>, '__file__': '/home/wes/git/PythonMonkey/tests/js/../../pmjs', '__cached__': None, 'sys': <module at remote 0x7ffff6d7e250>, 'os': <module at remote 0x7ffff6c24720>, 'readline': <module at remote 0x7ffff6ccd800>, 'signal': <module at remote 0x7ffff6cce660>, 'getopt': <module at remote 0x7ffff6cce930>, 'pm': <module at remote 0x7ffff6add620>, 'globalThis': {}, 'requirePath': False, 'repl': <function at remote 0x7ffff6d63d90>, 'usage': <function at remote 0x7ffff2b71090>, 'initGlobalThis': <function at remote 0x7ffff2b711b0>, 'main': <function at remote 0x7ffff2b71240>}, 
    locals={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/wes/git/PythonMonkey/tests/js/../../pmjs') at remote 0x7ffff6c010f0>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff6d905e0>, '__file__': '/home/wes/git/PythonMonkey/tests/js/../../pmjs', '__cached__': None, 'sys': <module at remote 0x7ffff6d7e250>, 'os': <module at remote 0x7ffff6c24720>, 'readline': <module at remote 0x7ffff6ccd800>, 'signal': <module at remote 0x7ffff6cce660>, 'getopt': <module at remote 0x7ffff6cce930>, 'pm': <module at remote 0x7ffff6add620>, 'globalThis': {}, 'requirePath': False, 'repl': <function at remote 0x7ffff6d63d90>, 'usage': <function at remote 0x7ffff2b71090>, 'initGlobalThis': <function at remote 0x7ffff2b711b0>, 'main': <function at remote 0x7ffff2b71240>}, flags=<optimized out>, arena=<optimized out>)
    at ../Python/pythonrun.c:1312
--Type <RET> for more, q to quit, c to continue without paging--
#53 0x00005555557b8865 in pyrun_file (fp=fp@entry=0x555555b5e350, filename=filename@entry='/home/wes/git/PythonMonkey/tests/js/../../pmjs', start=start@entry=257, 
    globals=globals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/wes/git/PythonMonkey/tests/js/../../pmjs') at remote 0x7ffff6c010f0>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff6d905e0>, '__file__': '/home/wes/git/PythonMonkey/tests/js/../../pmjs', '__cached__': None, 'sys': <module at remote 0x7ffff6d7e250>, 'os': <module at remote 0x7ffff6c24720>, 'readline': <module at remote 0x7ffff6ccd800>, 'signal': <module at remote 0x7ffff6cce660>, 'getopt': <module at remote 0x7ffff6cce930>, 'pm': <module at remote 0x7ffff6add620>, 'globalThis': {}, 'requirePath': False, 'repl': <function at remote 0x7ffff6d63d90>, 'usage': <function at remote 0x7ffff2b71090>, 'initGlobalThis': <function at remote 0x7ffff2b711b0>, 'main': <function at remote 0x7ffff2b71240>}, 
    locals=locals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/wes/git/PythonMonkey/tests/js/../../pmjs') at remote 0x7ffff6c010f0>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff6d905e0>, '__file__': '/home/wes/git/PythonMonkey/tests/js/../../pmjs', '__cached__': None, 'sys': <module at remote 0x7ffff6d7e250>, 'os': <module at remote 0x7ffff6c24720>, 'readline': <module at remote 0x7ffff6ccd800>, 'signal': <module at remote 0x7ffff6cce660>, 'getopt': <module at remote 0x7ffff6cce930>, 'pm': <module at remote 0x7ffff6add620>, 'globalThis': {}, 'requirePath': False, 'repl': <function at remote 0x7ffff6d63d90>, 'usage': <function at remote 0x7ffff2b71090>, 'initGlobalThis': <function at remote 0x7ffff2b711b0>, 'main': <function at remote 0x7ffff2b71240>}, closeit=closeit@entry=1, flags=0x7fffffffe568)
    at ../Python/pythonrun.c:1208
#54 0x00005555557b7d48 in _PyRun_SimpleFileObject (fp=0x555555b5e350, filename='/home/wes/git/PythonMonkey/tests/js/../../pmjs', closeit=1, flags=0x7fffffffe568)
    at ../Python/pythonrun.c:456
#55 0x00005555557b7a43 in _PyRun_AnyFileObject (fp=0x555555b5e350, filename='/home/wes/git/PythonMonkey/tests/js/../../pmjs', closeit=1, flags=0x7fffffffe568) at ../Python/pythonrun.c:90
#56 0x00005555557a8c3e in pymain_run_file_obj (skip_source_first_line=0, filename='/home/wes/git/PythonMonkey/tests/js/../../pmjs', 
    program_name='/home/wes/.cache/pypoetry/virtualenvs/pythonmonkey-NiDIb4WW-py3.10/bin/python') at ../Modules/main.c:353
#57 pymain_run_file (config=0x555555b40400) at ../Modules/main.c:372
#58 pymain_run_python (exitcode=0x7fffffffe564) at ../Modules/main.c:587
#59 Py_RunMain () at ../Modules/main.c:666
#60 0x000055555577ebcd in Py_BytesMain (argc=<optimized out>, argv=<optimized out>) at ../Modules/main.c:720
#61 0x00007ffff7c29d90 in __libc_start_call_main (main=main@entry=0x55555577eb90 <main>, argc=argc@entry=2, argv=argv@entry=0x7fffffffe778) at ../sysdeps/nptl/libc_start_call_main.h:58
#62 0x00007ffff7c29e40 in __libc_start_main_impl (main=0x55555577eb90 <main>, argc=2, argv=0x7fffffffe778, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, 
    stack_end=0x7fffffffe768) at ../csu/libc-start.c:392
#63 0x000055555577eac5 in _start ()
@wesgarland wesgarland changed the title segfault moving dates back and forth segfault in PythonAwaitable_Check moving dates back and forth Jul 14, 2023
@wesgarland
Copy link
Collaborator Author

@Xmader @caleb-distributive

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant