Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pfSense has detected a crash report or programming bug. #543

Closed
revoltingperson opened this issue Aug 26, 2024 · 6 comments · Fixed by #567
Closed

pfSense has detected a crash report or programming bug. #543

revoltingperson opened this issue Aug 26, 2024 · 6 comments · Fixed by #567

Comments

@revoltingperson
Copy link

Describe the bug
I did not use API during the weekend, but today I discovered pfsense reported a bug in the package with the following traceback. I have not tested whether any functionality has been affected:
Crash report begins. Anonymous machine information:

amd64
14.0-CURRENT
FreeBSD 14.0-CURRENT amd64 1400094 #1 RELENG_2_7_2-n255948-8d2b56da39c: Wed Dec 6 20:45:47 UTC 2023 root@freebsd:/var/jenkins/workspace/pfSense-CE-snapshots-2_7_2-main/obj/amd64/StdASW5b/var/jenkins/workspace/pfSense-CE-snapshots-2_7_2-main/sources/F

Crash report details:

PHP Errors:
[25-Aug-2024 16:00:12 Europe/Moscow] PHP Fatal error: Uncaught TypeError: RESTAPI\Caches\RESTAPIVersionReleasesCache::get_data_to_cache(): Return value must be of type array, null returned in /usr/local/pkg/RESTAPI/Caches/RESTAPIVersionReleasesCache.inc:27
Stack trace:
#0 /usr/local/pkg/RESTAPI/Core/Cache.inc(68): RESTAPI\Caches\RESTAPIVersionReleasesCache->get_data_to_cache()
#1 /usr/local/pkg/RESTAPI/.resources/scripts/manage.php(179): RESTAPI\Core\Cache->process()
#2 /usr/local/pkg/RESTAPI/.resources/scripts/manage.php(434): refresh_cache('RESTAPIVersionR...')
#3 {main}
thrown in /usr/local/pkg/RESTAPI/Caches/RESTAPIVersionReleasesCache.inc on line 27

No FreeBSD crash data found.

pfSense Version & Package Version:

  • pfSense Version: [e.g. pfSense 2.7.2]
  • Package Version [e.g. v2.0.3]
@SleepyNinja0o
Copy link

I get this error as well whenever I loose internet connection ... Seems its not properly catching the error when the return results are null.

@jaredhendrickson13
Copy link
Owner

This behavior is intentional and expected in certain situations. Caches are updated by background processes that run on a schedule. Sometimes, your pfSense instance might be unable to fetch the data needed for the cache. When this happens, an error is thrown for two main reasons:

  1. Admin Notification: The error alerts admins that the cache failed to update and may now be outdated. Since these processes run in the background, a crash report is a good way to notify admins, as errors from these processes might otherwise go unnoticed.

  2. Debugging Information: The error provides maintainers with a traceback to help debug why the cache failed to update. While the issue is often situational, the traceback offers valuable context for troubleshooting.

In the case of the RESTAPIVersionReleasesCache, which is where this report originates, it attempts to fetch available REST API package release versions from GitHub's API. The most common reasons for failure are:

  1. GitHub API Issues: GitHub's API might be down or experiencing problems, causing pfSense to either not receive a response or get an invalid one.

  2. Network Connectivity Issues: Your pfSense instance might be unable to reach GitHub's API.

In both scenarios, the cache file should not be updated, and an error should be thrown to alert admins. These issues are almost always temporary and resolve themselves. It's generally safe to clear crash reports related to cache files. However, if the report keeps appearing, it indicates a recurring issue (typically network-related) that needs to be addressed.

@Xenophilicy
Copy link

I too am receiving this error when network connectivity is interrupted.

If I understand correctly the reason stated for the error, this is due to the package trying to call home to GitHub and check for a newer release of the package. I disagree with the behavior of throwing a crash report in the logs just because the package cannot access the GitHub API.

For instance, if maintenance is being done on the firewall or anything north of its connections impacting its path to GitHub's API, there will be a crash report every time it tries to access the API. This seems a bit extreme just for a call back home to check for a version update in my opinion - especially since the check will be retried eventually anyway at a later time if it were a one-time thing. This happens quite often as we are doing intrusive maintenance fairly frequently and there is no "recurring issue [] that needs to be addressed." The crash reports also have to be manually cleared via the GUI, and can start to spam or hide actual crash reports that require attention.

pfSense provides a built-in system log that, preferably, could be used instead. This is located at "Status / System Logs" under the "Packages" tab in the GUI - very easy to locate for troubleshooting issues with update checks in the future. Something simple could be printed here such as "Cannot reach GitHub API to check for latest release" without causing a pfSense crash report.

@bozobogd
Copy link

It would be nice to have an option to completely disable this feature, cause there are firewalls that by design don't have internet access.
Also, I agree with @Xenophilicy that this should instead be logged in system logs.

@jaredhendrickson13
Copy link
Owner

The component that generates the crash report isn't the cache itself, it's the component that manages background processes. This component is used in several places across the package and in most cases having it generate crash reports is vital.

Short term, I can rework this cache's logic higher up to allow for better error handling to avoid the error. There's been a todo item to rework this cache for a while now.

Long term, I'd like to make caches more customizable where you can pick the refresh interval, and define how long a cache can stay stale for.

For now, you can disable the automatic cache refreshes by deleting cache jobs in /etc/crontab or if you have the cron package, just delete the job in the API or UI. You can still refresh caches after using pfsense-restapi refreshcache <cache name>

@bozobogd
Copy link

Many thanks for your prompt answers and solutions.

@jaredhendrickson13 jaredhendrickson13 linked a pull request Sep 20, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants