Skip to content

Segfault when unpickling expression containing user-defined formal symbolic function #30018

Closed
@YunosukeY

Description

@YunosukeY
mannequin
sage: loads(dumps(function('f')(x)))                                                                                                                           
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
~/s/sage/sage-rebasing/worktree-gcc11/src/sage/libs/pynac/pynac.pyx in sage.libs.pynac.pynac.py_print_function_pystring()
    491         olist = [func._name]
    492     olist.extend(['(', ', '.join(map(repr, args)), ')'])
--> 493     return ''.join(olist)
    494 
    495 cdef stdstring* py_print_function(unsigned id, args):

TypeError: sequence item 0: expected str instance, bytes found
Exception ignored in: 'sage.libs.pynac.pynac.py_print_function'
Traceback (most recent call last):
  File "sage/libs/pynac/pynac.pyx", line 493, in sage.libs.pynac.pynac.py_print_function_pystring
TypeError: sequence item 0: expected str instance, bytes found
------------------------------------------------------------------------
(no backtrace available)
------------------------------------------------------------------------
Unhandled SIGSEGV: A segmentation fault occurred.

As without #32480, deepcopy goes through pickling/unpickling, this also causes a failure of deepcopy as originally reported:

When I deepcopy expression containing function, a segmentation fault occurred.

sage: var('t');
sage: x = function('x')(t);
sage: l = [[x(t) == 1]];
sage: l
[[x(t) == 1]]
sage: l2 = deepcopy(l);
sage: l2
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/Applications/SageMath-9.1.app/Contents/Resources/sage/local/lib/python3.7/site-packages/sage/libs/pynac/pynac.pyx in sage.libs.pynac.pynac.py_print_function_pystring (build/cythonized/sage/libs/pynac/pynac.cpp:7182)()
    491         olist = [func._name]
    492     olist.extend(['(', ', '.join(map(repr, args)), ')'])
--> 493     return ''.join(olist)
    494 
    495 cdef stdstring* py_print_function(unsigned id, args):

TypeError: sequence item 0: expected str instance, bytes found
Exception ignored in: 'sage.libs.pynac.pynac.py_print_function'
Traceback (most recent call last):
  File "sage/libs/pynac/pynac.pyx", line 493, in sage.libs.pynac.pynac.py_print_function_pystring (build/cythonized/sage/libs/pynac/pynac.cpp:7182)
TypeError: sequence item 0: expected str instance, bytes found
------------------------------------------------------------------------
(no backtrace available)
------------------------------------------------------------------------
Unhandled SIGSEGV: A segmentation fault occurred.
This probably occurred because a *compiled* module has a bug
in it and is not properly wrapped with sig_on(), sig_off().
Python will now terminate.
------------------------------------------------------------------------
/Applications/SageMath-9.1.app/Contents/Resources/sage/src/bin/sage-python: line 2: 14997 Segmentation fault: 11  sage -python "$@"

Is this known issue?

Depends on #32386

CC: @tscrim @rburing

Component: symbolics

Issue created by migration from https://trac.sagemath.org/ticket/30018

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions