summaryrefslogtreecommitdiffstats
path: root/libbacktrace/GetPss.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libbacktrace/GetPss.cpp')
-rw-r--r--libbacktrace/GetPss.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/libbacktrace/GetPss.cpp b/libbacktrace/GetPss.cpp
index 442383b87..09a721dee 100644
--- a/libbacktrace/GetPss.cpp
+++ b/libbacktrace/GetPss.cpp
@@ -14,11 +14,10 @@
* limitations under the License.
*/
-#include <assert.h>
#include <inttypes.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
-#include <stdint.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
@@ -46,13 +45,22 @@ static bool ReadData(int fd, unsigned long place, uint64_t *data) {
size_t GetPssBytes() {
FILE* maps = fopen("/proc/self/maps", "r");
- assert(maps != NULL);
+ if (maps == nullptr) {
+ return 0;
+ }
int pagecount_fd = open("/proc/kpagecount", O_RDONLY);
- assert(pagecount_fd >= 0);
+ if (pagecount_fd == -1) {
+ fclose(maps);
+ return 0;
+ }
int pagemap_fd = open("/proc/self/pagemap", O_RDONLY);
- assert(pagemap_fd >= 0);
+ if (pagemap_fd == -1) {
+ fclose(maps);
+ close(pagecount_fd);
+ return 0;
+ }
char line[4096];
size_t total_pss = 0;