title: Raspberry Pi segmentation fault - Python
body: <p>I have a program on my Raspberry Pi written on Python that I use to control 2 motors. Here is some of the code :</p>
  
  <pre><code>def fullLeft() :
      speed1 = motor1Speed
      speed2 = motor2Speed
      setMotor1Speed(100)
      setMotor2Speed(-100)
      while io.input(forward1Control) and io.input(backward2Control) :
              print( "%d : %d" %(motor1Speed,motor2Speed))
      stop()
      setMotor1Speed(speed1)
      setMotor2Speed(speed2)
      print("Left Done")
  
  def fullRight() :
      speed1 = motor1Speed
      speed2 = motor2Speed
      setMotor1Speed(-100)
      setMotor2Speed(100)
      while io.input(forward2Control) and io.input(backward1Control) :
              print( "%d : %d" %(motor1Speed,motor2Speed))
      stop()
      setMotor1Speed(speed1)
      setMotor2Speed(speed2)
      print("Right  Done")
  
  def stop () :
      io.output(forward1Out,False)
      motor1Forward.stop()
      io.output(backward1Out, False)
      motor1Backward.stop()
      io.output(forward2Out, False)
      motor2Forward.stop()
      io.output(backward2Out, False)
      motor2Backward.stop()
      global motor1Speed
      motor1Speed = 0
      global motor2Speed
      motor2Speed = 0
  </code></pre>
  
  <p>Everything worked well before I introduce the <code>stop()</code> function on the <code>fullRight()</code> method. The problem is that <code>fullLeft()</code> works perfectly but after the 2nd while loop on the <code>fullRight()</code> function, I have the error <code>Segmentation Fault</code> and the program crashes. I don't know what to do and why is this happening. Can someone help me to figure out what the problem is...</p>