ID:1990413
 
Resolved
BYOND Version:509.1315r2
Operating System:Windows Server 2012 rc2
Web Browser:Chrome 47.0.2526.27
Applies to:Dream Daemon
Status: Resolved

This issue has been resolved.
Problem Summary:
a proc level var (that holds a client) is getting set to null when no sleeps or calls to non-byond procs (that could be sleeping) between the null check at the top of the proc and when this error happens.

-
runtime error: Cannot read null.sending
proc name: send asset (/proc/send_asset)
source file: asset_cache.dm,34

Code:
/proc/send_asset(var/client/client, var/asset_name, var/verify = TRUE)
if(!istype(client))
if(ismob(client))
var/mob/M = client
if(M.client)
client = M.client

else
return 0

else
return 0

if(client.cache.Find(asset_name) || client.sending.Find(asset_name))
return 0

client << browse_rsc(asset_cache[asset_name], asset_name)
if(!verify || !winexists(client, "asset_cache_browser")) // Can't access the asset cache browser, rip.
client.cache += asset_name
return 1

client.sending |= asset_name //line 34



That last line is triggering a null reference error randomly..

There is NO non-byond in procs getting called from start to here. (so no random code that could be sleeping in other procs)

There are no sleeps, no calls to procs that could sleep, so i'm fucking confused.

the client var is properly checked, it can't become null unless something sleeps.

It's always that line too, meaning browse_rsc either sleeping but not listed as such on the reference.

or (more likely) << is checking for disconnected clients and del()ing them, which is not expected behavior at all, and it's not reasonable to expect people to put if(client) lines after every <<

Edit: testing has shown that winexists is sleeping.

i had assumed the server knew info about the existing windows in a client, since they can't change from the client side after connection, but that proved to be wrong.
testing has shown that winexists is sleeping.

i had assumed the server knew info about the existing windows in a client, since they can't change from the client side after connection, but that proved to be wrong
They can change though, you can create new windows at runtime that winexists() can pick up on.

Probably could still be managed in a way where it always knows and doesn't have to query things though.
The sleeping is expected, but refs disappearing sounds wrong. I'll look into this soon.
You can delete windows clientsided so I can imagine it would be a little complicated to have the server always aware of what windows exist or not
I see there's no actual refcount error here, just that the client is becoming null--which is expected if the user logs out. I'll modify the reference to mention that the proc has to sleep.
Lummox JR resolved issue
Out of curiosity, will it time out? Like if someone never sends back an exists value.
If the client doesn't send back an exists value it's probably already close to disconnecting.