Specifically, I won;t comment directly on your problem, but the convention was to configure "CPU Pins" as inputs on power up.
It does cause grief sometimes. The ULN200x drivers eliminated the problem because at high Z, the driver was off, at low it was OFF and at high it was ON. Tack on a conventional TTL gate and it the input floats high, so very strange behavior on power up. Look at the the enabled pull-ups and pull downs at power up, Having a pin power up as an input is usually safer.
What it's actually doing may surprise you.