remember, op amps act as an active inductor, all by themselves. at 40khz, you only have 30db or so of negative feedback headroom left, so the amp is having some difficulty controlling it's output. with a 90 degree phase shift, this allows some "slop", which shows up as overshoot. if you were driving with sine waves, this wouldn't be so obvious, but you're driving with square waves and the amp takes a few microseconds to regain control of it's output after what might be a slew rate limited voltage swing, during which the feedback has no control whatsoever over the output. if you slew rate limit the input waveform so that the output is not slew rate limited (by the amplifier), the overshoot might clear up a bit.