fix compile error and portal segfault