exadel-inc / exadel-inc/CompreFace

Home Assistant addon crashes on startup with NullPointerException in CgroupV2Subsystem (bare-metal cgroupv2 kernel)

Open
#1,319 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
8.3k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

## Problem

The CompreFace Home Assistant addon enters a crash loop on startup with the following error:

```
java.lang.NullPointerException: null
at java.base/jdk.internal.platform.cgroupv2.CgroupV2Subsystem.getInstance(CgroupV2Subsystem.java:81)
```

**Environment:** bare-metal x86/NUC running Home Assistant OS with a pure cgroupv2 kernel.

**How to confirm:** In the addon logs (HA → Settings → Add-ons → CompreFace → Log) you'll see `Started FrsApplication` immediately followed by `Application run failed` with the NPE above, repeating in a loop.

## Root Cause

The JVM attempts to read the cgroup hierarchy via `/sys/fs/cgroup/` and `/proc/1/cgroup`. On bare-metal systems with a pure cgroupv2 kernel, this fails with a NullPointerException in `CgroupV2Subsystem.getInstance()`.

## Fix

Two complementary fixes resolve the issue:

1. **`cgroup_fix.so` (LD_PRELOAD)** — a C library that intercepts `open`, `open64`, `openat`, `fopen`, `fopen64` calls for `/proc/1/cgroup` and `/proc/self/cgroup`, returning fake cgroupv1 content (`1:name=systemd:/`)
2. **`-XX:-UseContainerSupport`** in a `java_wrapper` script — disables JVM container detection entirely, preventing `CgroupV2Subsystem` from being instantiated

## Working Solution

I have published a corrected Docker image and full build instructions (Dockerfile, C source, java_wrapper script) here:

👉 https://github.com/mdaraujoGit/compreface-fixed

The fixed image is available at `ghcr.io/mdaraujogit/compreface-fixed:1.1.0` and can be used directly as a drop-in replacement for the original addon image.

## Notes

- Related to issue #1291 (addon not starting in Home Assistant OS)
- Tested on Intel NUC, Home Assistant OS, OpenJDK 11, CompreFace 1.1.0

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.