Ubuntu 16.04 LTS - Python 3.5 - Segmentation fault (core dumped)

Asked by SunBear

Problem:
I ran a simple code (eg_sq_serial.py) on command line and it caused a "Segmentation fault (core dumped)" error. The code could be executed successfully when the value 40000000 was reduced to 1,000,000. However, Segmentation fault (core dumped) persisted with a higher value like 2,000,000.

I rebooted Ubuntu 16.04 LTS and executed the same code on command line with a value of 10,000,000 and it could complete. However, when a value of 40,000,000 was used, Segmentation fault (core dumped) occurred again. Thereafter, using the earlier value of 10,000,000 also lead to Segmentation fault (core dumped). The code could be executed successfully for a value of 1,000,000 or less.

Expectations:
The code should be able to execute successfully with a value of 40000000.

Question:
How can I resolve/overcome the "Segmentation fault (core dumped)" error? This error should not happen.

System info:
 $ uname -a
Linux Eliot 4.4.0-22-generic #39-Ubuntu SMP Thu May 5 16:53:32 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

$ lsb_release -crid
Distributor ID: Ubuntu
Description: Ubuntu 16.04 LTS
Release: 16.04
Codename: xenial

$ dmidecode | grep -e Date -e Vendor -e Version -e Product | head -n 4
 Vendor: American Megatrends Inc.
 Version: 0504
 Release Date: 10/19/2015
 Product Name: System Product Name

$ dpkg -l python3
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-============-============-=================================
ii python3 3.5.1-3 amd64 interactive high-level object-ori

Physical memory available 32GB

Python code "eg_sq_serial.py" :
=================
def f(x): # Function that returns the square of x.
    return x*x

if __name__ == '__main__':
    i = 0
    result=[]
    while i < 40000000:
        aa=[]
        for x in range(1,5):
            aa.append(f(x))
        i += 1
        result.append(aa)
    print(result)
    print(i)

Question information

Language:
English Edit question
Status:
Expired
For:
Ubuntu python3-defaults Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Launchpad Janitor (janitor) said :
#1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.