Most production sailboats are made in 4 big pieces, the hull, the liner, the ceiling liner and the deck. There is a gap between the deck and the ceiling liner. This looks like a crack in the filler between the 2 pieces. Over time, polyester resin and putties tend to shrink a little, that may be at the cause of the crack. Boats also twist and bend due to the forces developed while sailing, that too could cause the crack. The crack is not abnormal nor necessarily indicative of an accident. I wouldn't walk away just because of this crack.
If the boat is otherwise in suitable condition for the price and one you would be interested in, get a survey.