[ python-Bugs-1681762 ] too long string causes segmentation fault

SourceForge.net noreply at sourceforge.net
Tue Mar 20 09:07:05 CET 2007


Bugs item #1681762, was opened at 2007-03-15 23:12
Message generated for change (Settings changed) made by gbrandl
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1681762&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: L (llukas11)
Assigned to: Martin v. Löwis (loewis)
Summary: too long string causes segmentation fault

Initial Comment:
consider running this on machine with 16GB of ram:

line = "x"

for i in range(40):
        line = line + line
        print len(line)

and it's output:
2
4
8
16
32
64
128
256
512
1024
2048
4096
8192
16384
32768
65536
131072
262144
524288
1048576
2097152
4194304
8388608
16777216
33554432
67108864
134217728
268435456
536870912
1073741824
-2147483648
Segmentation fault

[lligo at kwaw-b1 0.1.x]$ python
Python 2.4.4 (#1, Oct 23 2006, 13:58:18)
[GCC 4.1.1 20061011 (Red Hat 4.1.1-30)] on linux2

I'll can try to chceck if it fails with python 2.5 but I need to compile one.

I have stumlbed on this bug when reading line by line 3GB file and forgetting to clear string after I processed data. 

----------------------------------------------------------------------

Comment By: Žiga Seilnacht (zseil)
Date: 2007-03-16 11:17

Message:
Logged In: YES 
user_id=1326842
Originator: NO

This looks like a duplicate of bug #1526585:
http://www.python.org/sf/1526585

That bug was fixed in Python 2.5, but it didn't get
backported to the 2.4 branch (string_concatenate()
in ceval.c is still missing an overflow check).


----------------------------------------------------------------------

Comment By: Georg Brandl (gbrandl)
Date: 2007-03-16 08:30

Message:
Logged In: YES 
user_id=849994
Originator: NO

Martin, do you think the Py_ssize_t changes prevent this in Py2.5?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1681762&group_id=5470


More information about the Python-bugs-list mailing list