Segfaults are kinda annoying in the web environment so we use this instead.
Does an upcast, but throws instead of returning null if it fails