This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: too long string causes segmentation fault
Type: Stage:
Components: None Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: loewis Nosy List: georg.brandl, llukas11, loewis, zseil
Priority: normal Keywords:

Created on 2007-03-15 23:12 by llukas11, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg31534 - (view) Author: L (llukas11) Date: 2007-03-15 23:12
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@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. 
msg31535 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-03-16 08:30
Martin, do you think the Py_ssize_t changes prevent this in Py2.5?
msg31536 - (view) Author: Ziga Seilnacht (zseil) * (Python committer) Date: 2007-03-16 11:17
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).
History
Date User Action Args
2022-04-11 14:56:23adminsetgithub: 44727
2007-03-15 23:12:40llukas11create