# Unicorn pHAT throws segfault at end of program

**URL:** <https://forums.pimoroni.com/t/unicorn-phat-throws-segfault-at-end-of-program/5902>\
**Category:** Support\
**Created:** [September 8, 2017, 8:59pm UTC](https://forums.pimoroni.com/t/unicorn-phat-throws-segfault-at-end-of-program/5902 "2017-09-08T20:59:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![wpns](https://avatars.discourse-cdn.com/v4/letter/w/e99b99/32.png) [@wpns](https://forums.pimoroni.com/u/wpns)\
**Post date:** [September 8, 2017, 8:59pm UTC](https://forums.pimoroni.com/t/unicorn-phat-throws-segfault-at-end-of-program/5902/1 "2017-09-08T20:59:44Z")

</div>

The simplest possible program:  
import unicornhat as uh

crashes with a segfault:  
root@h2opi31:/home/Display# python D.py  
Segmentation fault

As do the example programs (that terminate):

> root@h2opi31:~/Pimoroni/unicornhat/examples# python detect.py  
> Detect
> 
> Note: Your Unicorn HAT must be plugged in before boot to detect properly!
> 
> Trying to detect if you have a Unicorn HAT or Unicorn pHAT  
> Autodetection finished, let’s see the result…
> 
> Your height is NOT equal to your width, so you must have a pHAT.
> 
> If your hardware has been properly detected, it should be safe to use the following in your code:  
> unicorn.set\_layout(unicorn.AUTO)
> 
> Otherwise use one of the following in our code:
> 
> unicorn.set\_layout(unicorn.PHAT)  
> unicorn.set\_layout(unicorn.HAT)
> 
> Segmentation fault  
> root@h2opi31:~/Pimoroni/unicornhat/examples#

Do I have out-of-date drivers or something? I just built a Raspberry Pi Zero W with a Unicorn pHAT and installed Raspian Lite using NOOBS Lite, so I’m running Raspbian GNU/Linux 9 (stretch).

I had to modify the install script because I’m running as the root user, but it seems to work, all the demos work, and my code works, but I get a segfault on program termination, and that just doesn’t feel right…

Am I doing something wrong?

Thanks!

---

<div class="post-metadata">

**Author:** ![shaunmaclean](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@shaunmaclean](https://forums.pimoroni.com/u/shaunmaclean)\
**Post date:** [September 10, 2017, 9:47am UTC](https://forums.pimoroni.com/t/unicorn-phat-throws-segfault-at-end-of-program/5902/2 "2017-09-10T09:47:24Z")

</div>

I don’t recall mine saying that before Stretch, but it certainly does now. Mine is also acting batty, but I assume that’s unrelated. So, since you’re not alone, it seems like there is something a bit off about how it runs on Stretch.
