ID:2490364
 
Resolved
Reading initial() failed for some vars, resulting in major runtime errors.
BYOND Version:512
Operating System:Linux
Web Browser:Firefox 68.0
Applies to:Dream Daemon
Status: Resolved (512.1475)

This issue has been resolved.
Upon updating the baystation ss13 server to build 1473 (from 1472), we observed many errors with uses of `initial()`, which I summarize below. I do not know how to produce a minimal working example causing these, as at least some uses of initial seem to work correctly.

BYOND Error: bad instruction: 65500
relevant line of code: storage.w_class = initial(storage.w_class)
Here storage is an instance of an /obj subtype, and w_class is an /obj var which is always a number or possibly null. The initial value on the subtype in question is a nonzero number; the initial value on /obj is null.

BYOND Error: bad instruction: 13256
relevant line of code: C.handcuffed = initial(C.handcuffed)
Here C is an instance of a /mob subtype, and handcuffed is a var on the mob subtype which is set to either an obj instance or null (the initial value is null).

BYOND Error: bad instruction: 3600
relevant line of code: w_class = initial(w_class)
Here src is an /obj subtype, and w_class is as in the first example.

BYOND Error: bad instruction: 3601
relevant code:
force = initial(force)
throwforce = initial(throwforce)
sharp = initial(sharp)
The second line triggers the error, not the first (the third isn't reached). `throwforce` is an obj var, always a number. `force` is an obj subtype var, always a number. src is an obj subtype here.

(runtime error): undefined variable /area/space/var/North
relevant code:
```
for(var/area/A in world)
if((A.z in GLOB.using_map.station_levels) && initial(A.has_gravity))
A.gravitychange(gravity_is_on)
```
Error is in the middle line. There is no area var (or any var, in fact) in the codebase named `North`. `North` is present as a (text) entry in some lists elsewhere in the code.

I can provide more explanation or examples if that would be helpful. Full stack traces (and further occurrences) can be found here: https://github.com/Baystation12/Baystation12/issues, where they are automatically reported.

The server is running on Ubuntu 18.04.
hello, more bad instructions here from Goonstation/SS13

Caused by updating server to 1472 -> 1474

Funnily enough, we get the initial() errors on our storage procs as well, and a similarly named var(p_class) even though the code is quite diverged from baystation.

BYOND Error: bad instruction: 13298
Cause: setting a var equal to the initial of itself plus an int, on a mob proc
Example: src.number = initial(src.number) + src.int

BYOND Error: bad instruction: 13297
Cause/Example: Exact same as above, in a different location.

BYOND Error: bad instruction: 65498
Cause/Example: Exact same as above, in a different location.



BYOND Error: bad instruction: 5183
Cause: setting a var equal to the initial of itself, within a proc on an obj
Example: number = initial(number)

BYOND Error: bad instruction: 5180
Cause/Example: Exact same line as above.

BYOND Error: bad instruction: 5186
Cause/Example: Exact same line as above.



We also get a similar runtime to their 'North' example:

undefined variable /datum/loot_crate_lock/hangman/seven/var/y

The referenced line of code does not access a variable named "y", it simply is int = initial(int)



These bad instruction numbers seem to be within ranges.
We also suspect it might be with some weird initial() arithmetic.
Lummox JR resolved issue with message:
Reading initial() failed for some vars, resulting in major runtime errors.