in switzerland you aren't allowed to have a train with exactly 256 axles because of an integer overflow in the axle counting machine

i wish i could fix my software bugs by making it illegal to cause them

the source everyone reports for this PDF is gone, and it's not exactly easy to find swiss train law documentation when you don't even speak german

but here's a current link: https://www.hech.ch/wp-content/uploads/2018/07/I-30111_09122018_Anhoerung.pdf

page 123, section 4.8.4 "Zugbildung"

die züge können keine 256 achsen haben! wie lächerlich!

"gnädige frau, das ist ein mcdonalds."

Queen - Sweet lady (1975)

YouTube
@Nikolai_Kingsley is is entirely possible that my two months of duolingo courses i did two years ago, combined with google translate, is not enough to produce a german sentence that doesn't sound weird

@lynnesbian

German is a good language. any language that has a single word that means "a face in search of a backhand" is a good language.

Backpfeifengesicht

@Nikolai_Kingsley @lynnesbian it also forces you to binarily gender most nouns applied to a person (Backpfeifengesicht is an exception).
@lynnesbian 256 Achsen wären dann 64 4achsige Wagen - solche Züge gibt es nicht,
@hikerus5 @lynnesbian nicht in Europa, aber es fahren regelmäßig Güterzüge mit mehr als 200 *Wagen* in den Vereinigten Staaten und anderen Ländern https://en.m.wikipedia.org/wiki/Longest_trains
Longest trains - Wikipedia

@hikerus5 @lynnesbian Es gibt die Rollende Landstraße, deren Wagen haben 12 Achsen (Sdmmrs).
21 von diesen Wagen plus eine Lok mit 4 Achsen und du hast genau die 256 Achsen auf rund 400m Zuglänge
@Aglaia89 @hikerus5 @lynnesbian die haben zum Glück immer(?) noch hinten dran einen Schlafwagen :D

@dingens @hikerus5 @lynnesbian Ein RoLa Wagen weniger und 3 Schlafwägen oder 2 Schlafwägen und Doppeltraktion und schon ist das Problem wieder da.
Aber ja, da ist schon eine besondere Konstelation aber nicht komplett ausgeschlossen.

Theoretisch könnte man das auch mit 6-Achsigen Schwerlast Flachwagen passieren, da wird aber das Zuggewicht von ~5500t zum Problem.

@lynnesbian Hard to find? Who's your Swiss train law documentation guy?
@lynnesbian But then a) You'd let everyone know how to break your software, and b) Unruly teens would constantly break your software, because of Crimes
@RedFuture ah but, it's illegal to break the law, so they simply would not do it
@RedFuture @lynnesbian gathering with my friends after school to build a train with exactly 256 axles, as a prank
@operand @lynnesbian Building a train with -1 axles to block out huge sections of track
@lynnesbian
There should be the same integer overflow at every multiple of 256 axles. There is a bug in the law.
@hambach18 i imagine that as soon as someone builds a train with that many axles they'll update the law
@hambach18
At 65536 axles all train stations spontaneously explode...
@lynnesbian
@lynnesbian proposed fix: mandate the ETD (https://en.m.wikipedia.org/wiki/End-of-train_device) must be mounted on a little cart with 3 axles. Every train will need exactly one
End-of-train device - Wikipedia

@lynnesbian can't happen to us in Germany. We still have things like manual or mechanical operation of these things ;)

Only a fraction is electric ;)

@Drezil Really? That would explain why nothing train related works in Germany. 😆
@sindastra yes, really. There is still Hardware from the kaiserreich in use today ;)
@Drezil @lynnesbian you can still have an integer overflow in a mechanical counter. it's just more likely to be a decimal limit at rollover, not a binary one. automotive mechanical odometers were susceptible to this, as a 5+1 decimal digit mechanical counter. so you'd hit rollover at 100,000 DISTUNIT. my family has a car that's done it. our newer car has a digital Trip-O + Odometer with 6 digits, no tenths for the Odometer, just the Trip-O, so it'll hit rollover at 1,000,000 DISTUNIT
@Drezil @lynnesbian There's still a limit of 250 axles (with possible exceptions of up to 252 axles) for similar reasons defined at Ril 408.2711: https://fahrweg.dbnetze.com/resource/blob/1355870/d9d741385d4312e1ef4bb183858e4c0a/rw_408-21-27_Aktualisierung-02-data.pdf#page=247
@lynnesbian this is like if BeamNG.Drive somehow overflowed into real life...

@lynnesbian

become a government. they're allowed to do whatever they want, like Googzilla or Microsofthra can

@lynnesbian
It's not a feature.

*IT'S THE LAW.*

@lynnesbian so they could have 512 axles
@a_breakin_glass @lynnesbian that's why I always use `-fsanitize=axle-overflow` 
@lynnesbian it's like that xkcd comic where the guy named his kid DropTable.Student except better because it's real and involves trains
@lynnesbian Fixing problems by making them illegal does have an especially Swiss ring to it...

@lynnesbian Oh hey! I'm the person who originally submitted this to reddit.

As far as I know, this rule is no longer in place. It still shows up in some recent-ish documents (like [1]), but a train driver I know showed me a screenshot of a document explicitly stating that this paragraph was made obsolete.

It also doesn't show up in the current R 300.5 anymore. [2]

[1]: https://www.bav.admin.ch/bav/de/home/rechtliches/rechtsgrundlagen-vorschriften/fdv.html

[2]: https://www.bav.admin.ch/bav/de/home/rechtliches/rechtsgrundlagen-vorschriften/fdv.html

Fahrdienstvorschriften (FDV)

Die FDV gelten für alle schweizerischen Eisenbahnen sowie für alle Bahnen, die schweizerische Eisenbahninfrastrukturen benützen. Sie umfassen die sicherheits-relevanten Regeln für alle Fahrten auf Schienen. Das Bundesamt für Verkehr erlässt gestützt auf Art. 11a der Eisenbahnverordnung vom 23. November 1983 EBV (742.141.1) die Schweizerischen Fahrdienstvorschriften FDV.

@lynnesbian I think the original limitation was caused by mechanical counters with eight physical bits (so, not actually software), which have now been phased out.
@draemmli @lynnesbian
Otoh, the German LZB linear train control is 8-bit to its core. One sector is up to 12.7 km long, 127 × 100 m loop sections, for signed 8-bit position counters.
@draemmli thanks for clearing this up! i managed to find a slightly more recent document mentioning it, but you're right, it seems to have disappeared now
@lynnesbian In Switzerland you will never have a trains with 64 railway cars with 4 axles.

@lynnesbian
This makes me think of the swedish law that forced transgendered people to be sterilized, and their semen/eggs to be destroyed.

The law was only removed in 2016 or so, long after the old "sterilize anyone that the nazis wouldn't want to breed" mentality went out of style.

No-one talked much about why they were still doing this, since the reasons were rather obvious. But I did find one person blaming paperwork.
"See, on this parenthood form, we have a mother square and a father square, and if you trans lot went and muddled it all up, the system would just break".

@lynnesbian Shouldn't it be "equals or exceeds"?

Like, if it hits 256 on the counter and resets to zero, wouldn't it then be under-reporting the length of the train as L-256, which could still lead to issues?

(I dunno, maybe I'm not parsing this right, much like a Swiss axle-counter. Time for another eggnog latte.)

@drimplausible @lynnesbian IIRC it's perfectly okay to have 255 or 257 axles, because the relevant bit of code is only worried about if there is a train there or no train there. That 257 overflows to become 1 still shows up as a train
@bellinghman @lynnesbian Interesting! Thanks for the answer! :)

@drimplausible @lynnesbian Axle Counters are not about reporting the length. They are about "The same number of axles and thus cars that went in on the beginning of the block left it at the end of the block". (Or even, on either side, in case of reversing / split trains). Which is equivalent to what we're interested in, namely, "There are no cars left in the block, and we can leave the next train in at full speed".

So as long as the counter doesn't remain at 0 when the full train is in, an overflow isn't much of a problem. (Bad edge case: The train stops after exactly 256 axles have been counted in)

@drimplausible Yes, but that doesn’t matter. The next counter has the same bug and thus counts the same number of axles, so the result will be correct.

Let’s say it has 258 axles. First sensor will report “train with 2 axles has entered the segment”. Second sensor will report “train with 2 axles has left the segment, clear the signals.” Everything is fine.

@drimplausible @lynnesbian It says "To avoid signalling a section of track as clear" so I think the issue is that at 256 it rolls over to 0 and thus "there's zero axles in this section, so it is empty and safe for a new train to enter." At 257+ it would show as one or more axles, and wouldn't mistakenly show the section as clear.

Presumably the problem would also occur at multiples of 256, but I guess they don't have a trains long enough to have 512 axles.

@lynnesbian could it be a hardware issue? The sensor on the track only having one byte for counting.
@palinor5
What about more than 256 axles? In the original instructions, there is no hint of an overflow, just the exact number that is not to be met.
@lynnesbian
@palinor5 According to this it was a physical device with 8 "bits", but they've been phased out, so the no 256-axle train rule has been removed.
Draemmli/5.0, like Gecko (@draemmli@chaos.social)

@lynnesbian@fedi.lynnesbian.space I think the original limitation was caused by mechanical counters with eight physical bits (so, not actually software), which have now been phased out.

chaos.social
@lynnesbian that explains why the RISC-V people like trains so much!
@lynnesbian 257 is OK?
@dougschuler @lynnesbian Presumably yes. It seems like it would be counted as one axle on the track. I hope that doesn't trigger another error in their code :-)

@compfu @dougschuler @lynnesbian See, now I'm going to be up all night thinking about those 1-axle trains.

I'm pretty sure it's impossible, but that won't stop me wondering what such a thing could even look like.

(...A unicycle handcar, maybe...?)

@Gorfram @compfu @dougschuler @lynnesbian

What about a 1 rail train?

The 1910 Brennan gyroscopic monorail :