Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Use 'B' instead of 'b' to parse/build char value. #305

Open
wants to merge 1 commit into
base: 3.8-slp
Choose a base branch
Loading
from

Conversation

masamitsu-murase
Copy link

@masamitsu-murase masamitsu-murase commented Sep 18, 2021

Issue:

  • pickle.load raises OverflowError if loaded content includes PyFrameObject, whose f_executing is set to SLP_FRAME_EXECUTING_INVALID, i.e. -1.

Solution:

  • Use 'B' instead of 'b' to parse/build char value when frame object is pickled.

How to reproduce this issue:

  • The following code causes OverflowError unexpectedly.
     import pickle
     import stackless
     import sys
    
    
     try:
         raise RuntimeError()
     except:
         traceback_object = sys.exc_info()[2]
     a = pickle.dumps(traceback_object)
     b = pickle.loads(a)
     c = pickle.dumps(b)
     d = pickle.loads(c)
     # => This raises "OverflowError: unsigned byte integer is less than minimum".

Details:

  • f_executing in PyFrameObject is declared as char, which might be signed depending on implementation.
    Therefore, 'B' should be specified when Py_BuildValue and PyArg_ParseTuple is called.
  • If 'b' is specified instead of 'B' and f_executing is set to SLP_FRAME_EXECUTING_INVALID, PyArg_ParseTuple in frame_setstate in Stackless\pickling\prickelpit.c raises OverflowError.
    This is raised in convertsimple in Python\getargs.c because SLP_FRAME_EXECUTING_INVALID is less than 0.

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

Successfully merging this pull request may close these issues.

1 participant
Morty Proxy This is a proxified and sanitized view of the page, visit original site.