ID:2372146
 
Code:
/turf/simulated/wall/update_icon()
if(!material || !p_material)
update_material(1)

if(!damage_overlays[1]) //list hasn't been populated
generate_overlays()

if(r_material)
name = "[state != null ? "incomplete " : ""][r_material.display_name] reinforced [p_material.display_name] [initial(name)]"
desc = "It seems to be [state == null ? "an incomplete " : "a"] section of hull reinforced with [r_material.display_name] and plated with [p_material.display_name]."
else
name = "[state != null ? "incomplete " : ""][p_material.display_name] [initial(name)]"
desc = "It seems to be [state == null ? "an incomplete" : "a"] section of hull plated with [p_material.display_name]."

overlays.Cut()
var/image/I
for(var/i = 1 to 4)
I = image('icons/turf/wall_masks.dmi', "[r_material ? p_material.icon_reinf : p_material.icon_base][wall_connections[i]]", dir = 1<<(i-1))
I.color = p_material.icon_colour
overlays = overlays.Copy() + I

if(r_material)
if(state == null)
I = image('icons/turf/wall_masks.dmi', "reinf_over")
I.color = r_material.icon_colour
overlays = overlays.Copy() + I
else
I = image('icons/turf/wall_masks.dmi', "reinf_construct-[state]")
I.color = r_material.icon_colour
overlays = overlays.Copy() + I
if(state >= 5 || state == null)
I = image('icons/turf/wall_masks.dmi', "reinf_metal")
I.color = "#666666"
overlays = overlays.Copy() + I

if(integrity != MaxIntegrity())
var/overlay = round(damage_overlays.len * (1 / (integrity / MaxIntegrity())))
if(overlay > damage_overlays.len)
overlay = damage_overlays.len

overlays = overlays.Copy() + damage_overlays[overlay]
return

/turf/simulated/wall/proc/generate_overlays()
var/alpha_inc = 256 / damage_overlays.len

for(var/i = 1; i <= damage_overlays.len; i++)
var/image/img = image(icon = 'icons/turf/walls.dmi', icon_state = "overlay_damage")
img.blend_mode = BLEND_MULTIPLY
img.alpha = (i * alpha_inc) - 1
damage_overlays[i] = img


/turf/simulated/wall/proc/update_connections(propagate = 0)
if(!p_material)
return
var/list/dirs = list()
for(var/turf/simulated/wall/W in orange(src, 1))
if(!W.p_material)
continue
if(propagate)
W.update_connections()
if(can_join_with(W))
dirs += get_dir(src, W)

wall_connections = dirs_to_corner_states(dirs)

/turf/simulated/wall/proc/can_join_with(var/turf/simulated/wall/W)
if(state == null && W.state == null && p_material.name == W.p_material.name)
return 1
return 0


Problem description:
Apologies for the code dump, but I felt including most of this would help in getting help. We are having an issue where update_icon crashes on server load, with an "illegal operation". This is SS13 code, baystation, custom. We are having issues with figuring out why. Changing overlays from overlays += image to overlays = overlays.Copy() + image appeared to solve the issue for a while, but it has re-appeared. Any help would be appreciated.

BUG: Crashing due to an illegal operation!

Backtrace for BYOND 511.1385 on Linux:
Generated at Mon May 28 21:07:20 2018

DreamDaemon [0x8048000, 0x0], [0x8048000, 0x804bb24]
libbyond.so [0xf7a47000, 0x0], 0x2059bd
linux-gate.so.1 [0xf7fb4000, 0xf7fb5080], [0xf7fb4000, 0xf7fb5080]
libbyond.so [0xf7a47000, 0x0], 0x2059bd
libbyond.so [0xf7a47000, 0x0], 0x2401bf
libbyond.so [0xf7a47000, 0x0], 0x23ff39
libbyond.so [0xf7a47000, 0x0], 0x26ec80
libbyond.so [0xf7a47000, 0x0], 0x273203
libbyond.so [0xf7a47000, 0x0], 0x273ced
libbyond.so [0xf7a47000, 0x0], 0x251c2c
libbyond.so [0xf7a47000, 0x0], 0x26a84e
libbyond.so [0xf7a47000, 0x0], 0x273083
libbyond.so [0xf7a47000, 0x0], 0x273ced
libbyond.so [0xf7a47000, 0x0], 0x251c2c
libbyond.so [0xf7a47000, 0x0], 0x26a84e
libbyond.so [0xf7a47000, 0x0], 0x2766ca
libbyond.so [0xf7a47000, 0x0], 0x254e1f
libbyond.so [0xf7a47000, 0x0], 0x26a84e
libbyond.so [0xf7a47000, 0x0], 0x273083
libbyond.so [0xf7a47000, 0x0], 0x273ced
libbyond.so [0xf7a47000, 0x0], 0x251c2c
libbyond.so [0xf7a47000, 0x0], 0x26a84e
libbyond.so [0xf7a47000, 0x0], 0x24f132
libbyond.so [0xf7a47000, 0x0], 0x26a84e
libbyond.so [0xf7a47000, 0x0], 0x273083
libbyond.so [0xf7a47000, 0x0], 0x273ced
libbyond.so [0xf7a47000, 0x0], 0x251c2c
libbyond.so [0xf7a47000, 0x0], 0x26a61c
libbyond.so [0xf7a47000, 0x0], 0x26bc0d
libbyond.so [0xf7a47000, 0x0], 0x226e29
libbyond.so 0x33ccd0, 0x33cdea
libbyond.so 0x303e30, 0x304032
DreamDaemon [0x8048000, 0x0], [0x8048000, 0x804ae34]
libc.so.6 0x18d90, 0x18e81 (__libc_start_main)
DreamDaemon [0x8048000, 0x0], [0x8048000, 0x804a731]

Recent proc calls:
/turf/simulated/wall/update_icon
/datum/proc/after_load
/turf/after_load
/turf/simulated/wall/after_load
/datum/proc/after_load
/datum/proc/after_load
/datum/proc/after_load
/atom/movable/lighting_overlay/proc/update_overlay
/atom/New
/atom/movable/New
/atom/movable/lighting_overlay/New
/atom/proc/(init)
/datum/lighting_corner/proc/update_active
/datum/lighting_corner/New
/datum/lighting_corner/proc/(init)
/turf/proc/generate_missing_corners
511.1385 is really out of date. It's entirely likely this issue has already been solved.