Skip to content

Commit

Permalink
ENH: make sure that segfaults always happen
Browse files Browse the repository at this point in the history
Increase a lot the size of the overflow, to make sure that the memory
lookup falls out of the program memory.
  • Loading branch information
GaelVaroquaux committed Nov 10, 2012
1 parent c27489c commit 9ec4232
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions advanced/debugging/segfault.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
""" Simple code that creates a segfault using numpy. Used to learn
debugging segfaults with GDB.
"""

import numpy as np
from numpy.lib import stride_tricks

def make_big_array(small_array):
big_array = stride_tricks.as_strided(small_array,
shape=(20000, 20000), strides=(32, 32))
big_array = stride_tricks.as_strided(small_array,
shape=(2e6, 2e6), strides=(32, 32))
return big_array

def print_big_array(small_array):
Expand All @@ -16,4 +20,3 @@ def print_big_array(small_array):
for i in range(10):
a = np.arange(8)
l.append(print_big_array(a))

0 comments on commit 9ec4232

Please sign in to comment.