Issue 7455: cPickle: stack underflow in load_pop() (original) (raw)

Created on 2009-12-08 02:59 by vstinner, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
cpickle_load_pop-3.patch vstinner,2009-12-11 11:40
issue7455_cpickle_load_pop.diff flox,2009-12-19 00:12 Patch, apply to trunk
issue7455_cpickle_load_pop_py3k.diff flox,2009-12-19 00:13 Patch, apply to py3k
Messages (9)
msg96106 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2009-12-08 02:59
load_pop() pops a value if the stack length is >= 0. The test is wrong: if the length is zero, the stack is empty and stackUnderflow() have to be called. Example: $ ../../python -c "import cPickle; cPickle.loads('0')" Erreur de segmentation
msg96107 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2009-12-08 06:20
Can you add a test for this?
msg96121 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2009-12-08 10:48
> Can you add a test for this? I wasn't sure of the right place to add the test. I tried Lib/test/pickletester.py, but it doesn't work because UnpicklingError is not defined there. Well, here is a new version of my patch with an unit test.
msg96245 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2009-12-11 11:40
Oops, cpickle_load_pop-2.patch contains an useless variable (picklingError = pickle.UnpicklingError). Here is the version 3 of my patch.
msg96273 - (view) Author: Jack Diederich (jackdied) * (Python committer) Date: 2009-12-11 21:01
This seems to have been introduced in r72930 when the stackUnderflow() was moved from the top of the function to the bottom. It used to test for len > 0. Question, should cPickle and pickle be raising the same error here? UnpicklingError is defined in pickle.py and never used but cPickle.c uses it frequently.
msg96585 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2009-12-18 21:29
The patch works correctly on 2.7. It should be applied on trunk, and backported to other branches, too. ( is marked as duplicate of this one)
msg96593 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2009-12-19 00:12
I moved the test to test.pickletester, so that it can be used for all 3 tests: test_pickle test_cpickle test_xpickle (and backported a test which was only on py3k)
msg97361 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-01-07 18:05
Committed in all four branches. Thank you Victor and Florent!
msg97495 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-01-10 03:04
> Committed in all four branches. trunk: r77352
History
Date User Action Args
2022-04-11 14:56:55 admin set github: 51704
2010-01-22 19:54:08 eric.smith link issue7758 superseder
2010-01-10 03:04:15 vstinner set messages: +
2010-01-07 18:05:01 pitrou set status: open -> closednosy: + pitroumessages: + resolution: fixedstage: patch review -> resolved
2010-01-07 17:27:30 flox set files: - issue7455_silence_py3k_warning.diff
2009-12-21 22:24:24 flox set priority: normalstage: test needed -> patch review
2009-12-19 00:13:42 flox set files: + issue7455_silence_py3k_warning.diff
2009-12-19 00:13:10 flox set files: - issue7455_silence_py3k_warning.diff
2009-12-19 00:13:02 flox set files: + issue7455_cpickle_load_pop_py3k.diff
2009-12-19 00:12:37 flox set files: + issue7455_cpickle_load_pop.diffmessages: +
2009-12-18 21:48:31 flox set files: + issue7455_silence_py3k_warning.diff
2009-12-18 21:29:53 flox set type: crash
2009-12-18 21:29:36 flox set nosy: + floxmessages: + versions: + Python 2.6, Python 3.1, Python 3.2
2009-12-11 21:01:22 jackdied set nosy: + jackdied, collinwintermessages: +
2009-12-11 13:10:15 pitrou set nosy: + alexandre.vassalotti
2009-12-11 11:40:42 vstinner set files: + cpickle_load_pop-3.patchmessages: +
2009-12-11 11:39:53 vstinner set files: - cpickle_load_pop-2.patch
2009-12-11 11:39:47 vstinner set files: - cpickle_load_pop.patch
2009-12-08 10:49:00 vstinner set files: + cpickle_load_pop-2.patchmessages: +
2009-12-08 06:20:13 eric.smith set nosy: + eric.smithmessages: + stage: test needed
2009-12-08 02:59:17 vstinner create