Skip to content

Conversation

@EllieTellie
Copy link

Description

Fixes EXCEPTION_ILLEGAL_INSTRUCTION crash on CPUs without BMI2 support.
Snappy compression library detects BMI2 support at compile time based on the build machine. When built on a machine with BMI2, Snappy uses instructions like BZHI which crashes.


Testing

Tested the change on devices that have older CPUs and confirmed it no longer crashes.
To reproduce the machine you are building on must support BMI2.
To reproduce the machine you are running Firebase on must not support BMI2, for example: Intel Celeron/Pentium Silver (Gemini Lake), Intel Core i-series pre-Haswell or AMD pre-Zen.


Type of Change

Place an x the applicable box:

  • Bug fix. Add the issue # below if applicable.
  • New feature. A non-breaking change which adds functionality.
  • Other, such as a build process or documentation change.

Notes

crash.dmp

  • Bug fixes and feature changes require an update to the Release Notes section of release_build_files/readme.md.
  • Read the contribution guidelines CONTRIBUTING.md.
  • Changes to the public API require an internal API review. If you'd like to help us make Firebase APIs better, please propose your change in a feature request so that we can discuss it together.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @EllieTellie, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a critical bug that caused application crashes on older CPUs by preventing the Snappy compression library from using advanced instruction sets (BMI2) that are not universally supported. By explicitly disabling these optimizations during the build process, the change significantly enhances the application's stability and compatibility across a wider range of hardware, particularly for devices with pre-Haswell Intel or pre-Zen AMD processors.

Highlights

  • Crash Fix: Addresses an EXCEPTION_ILLEGAL_INSTRUCTION crash that occurred on CPUs lacking BMI2 support when the Snappy compression library was compiled on a machine with BMI2 capabilities.
  • CPU Compatibility: Ensures broader CPU compatibility by explicitly disabling Snappy's BMI2 optimizations at compile time.
  • Build Configuration: Modifies CMakeLists.txt to set the SNAPPY_HAVE_BMI2 flag to 0, preventing the use of BMI2 instructions like BZHI on incompatible hardware.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request aims to fix a crash on older CPUs by disabling BMI2 optimizations in the Snappy compression library. The approach of setting SNAPPY_HAVE_BMI2 to 0 is correct. However, the implementation has a potential issue where the setting might not be applied in existing build directories due to CMake's caching behavior. I've added a specific comment with a suggestion to ensure the fix is always effective.

@adabru
Copy link

adabru commented Jan 9, 2026

I confirm that this patch resolved a crash I was experiencing with the firebase-unity-sdk on a Windows machine with an Intel Celeron N4120.

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 this pull request may close these issues.

2 participants