pageauc
Posts: 224
Joined: Fri Jan 04, 2013 10:52 pm

sense hat rainbow.py stack smaching error

Fri Nov 13, 2015 5:02 pm

I ran the demo rainbow.py on my new Jessie imaged Raspbian RPI B2 with latest updates and upgrades. The gui desktop was disabled and the code was run from an SSH session as pi user. A sensehat is attached and was tested successfully with the various sensehat demos. I ran the rainbow.py script and left it running. When I came back after several hours the following message was displayed with no other python errors. I am rerunning to see if the problem is repeatable.
This is the console error message

Code: Select all

pi@raspberrypi ~/sensehat $ python ./rainbow.py
*** stack smashing detected ***: python terminated
Aborted
pi@raspberrypi ~/sensehat $
Should this happen or is there some underlying library or code problem.

This is the code that was running

Code: Select all

#!/usr/bin/python
import time
from sense_hat import SenseHat

sense = SenseHat()

pixels = [
    [255, 0, 0], [255, 0, 0], [255, 87, 0], [255, 196, 0], [205, 255, 0], [95, 255, 0], [0, 255, 13], [0, 255, 122],
    [255, 0, 0], [255, 96, 0], [255, 205, 0], [196, 255, 0], [87, 255, 0], [0, 255, 22], [0, 255, 131], [0, 255, 240],
    [255, 105, 0], [255, 214, 0], [187, 255, 0], [78, 255, 0], [0, 255, 30], [0, 255, 140], [0, 255, 248], [0, 152, 255],
    [255, 223, 0], [178, 255, 0], [70, 255, 0], [0, 255, 40], [0, 255, 148], [0, 253, 255], [0, 144, 255], [0, 34, 255],
    [170, 255, 0], [61, 255, 0], [0, 255, 48], [0, 255, 157], [0, 243, 255], [0, 134, 255], [0, 26, 255], [83, 0, 255],
    [52, 255, 0], [0, 255, 57], [0, 255, 166], [0, 235, 255], [0, 126, 255], [0, 17, 255], [92, 0, 255], [201, 0, 255],
    [0, 255, 66], [0, 255, 174], [0, 226, 255], [0, 117, 255], [0, 8, 255], [100, 0, 255], [210, 0, 255], [255, 0, 192],
    [0, 255, 183], [0, 217, 255], [0, 109, 255], [0, 0, 255], [110, 0, 255], [218, 0, 255], [255, 0, 183], [255, 0, 74]
]

msleep = lambda x: time.sleep(x / 1000.0)


def next_colour(pix):
    r = pix[0]
    g = pix[1]
    b = pix[2]

    if (r == 255 and g < 255 and b == 0):
        g += 1

    if (g == 255 and r > 0 and b == 0):
        r -= 1

    if (g == 255 and b < 255 and r == 0):
        b += 1

    if (b == 255 and g > 0 and r == 0):
        g -= 1

    if (b == 255 and r < 255 and g == 0):
        r += 1

    if (r == 255 and b > 0 and g == 0):
        b -= 1

    pix[0] = r
    pix[1] = g
    pix[2] = b

try:
    while True:
        for pix in pixels:
            next_colour(pix)

        sense.set_pixels(pixels)
        msleep(2)
finally:
    print("Exiting Program")
    sense.clear()
GitHub - https://github.com/pageauc
YouTube - https://www.youtube.com/user/pageaucp

pageauc
Posts: 224
Joined: Fri Jan 04, 2013 10:52 pm

Re: sense hat rainbow.py stack smaching error

Fri Nov 13, 2015 10:31 pm

Well I have been running the second test for four (4) hours and still no stack smash error. Maybe a cosmic ray found the RPI. Anyway Looks like I cannot repeat the original stack smaching error. Let me know if anyone else encounters this problem. Not sure why this happened since the RPI is a very new and fresh build.
GitHub - https://github.com/pageauc
YouTube - https://www.youtube.com/user/pageaucp

Return to “Python”