somehow related:
try to avoid those sweep1-issues - see post above.
check curve quality (duplicated points ? tiny segments…) / planarity.
post a minimum .gh definition that shows the problem
(just 4 components: crv, crv, sweep1, cap )
try to keep the rail curve as simple as possible - still showing the problem
post a screenshot - so others see at least the complex profile / the geometric issue you re having.
kind regards -tom