While you can run moodle with $CFG->wwwroot beeing empty, weblib will fail (in that case) setting $path in line 5625:
$path = str_replace($CFG->httpswwwroot.'/', '', $CFG->pagepath);
It will strip all slashes from $CFG->pagepath instead of kicking of $CFG->httpswwwroot.
One of our customers couldn't get the chat- and quiz- modules running, so we detected wwwroot = '' in the config. Note: You get a whitescreen if you make php create an object with an empty name, that took us some time and efford to get the mouse trapped
We couldn't reconstruct how this config was born, but it was there and moodle running.
How to repeat:
set wwwroot as emptystring, call chat-view.
Suggested fix: check for all needed config every session_start(). Presenting an error message is better than a whitescreen.