Skip to content

Conversation

naveentatikonda
Copy link
Member

Description

Fix NPE while detecting AVX2 on other platforms(other than Linux, Mac and Windows)

java.lang.NullPointerException: Cannot invoke "java.lang.Boolean.booleanValue()" because "org.opensearch.knn.jni.Platfor
mUtils.isAVX2Supported" is null
        at org.opensearch.knn.jni.PlatformUtils.isAVX2SupportedBySystem(PlatformUtils.java:98)
        at org.opensearch.knn.plugin.KNNPlugin.lambda$static$0(KNNPlugin.java:183)
        at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1423)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)

Related Issues

Resolves #2788

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@naveentatikonda naveentatikonda added the Bug Fixes Changes to a system or product designed to handle a programming bug/glitch label Sep 30, 2025
Vikasht34
Vikasht34 previously approved these changes Sep 30, 2025
Copy link
Collaborator

@Vikasht34 Vikasht34 left a comment

Choose a reason for hiding this comment

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

Looks good

0ctopus13prime
0ctopus13prime previously approved these changes Sep 30, 2025
@Vikasht34 Vikasht34 dismissed stale reviews from 0ctopus13prime and themself via 03fa8a6 September 30, 2025 16:21
Copy link
Collaborator

@navneet1v navneet1v left a comment

Choose a reason for hiding this comment

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

somehow I see just the Changelog file present in the file diff. Something is wrong here.

Comment on lines +57 to +58
if (!Platform.isIntel() || Platform.isWindows()) {
return isAVX2Supported = false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

how does this solves the NPE? is it like on windows even when user has disabled the AVX2 we were still checking isIntel || isWindows() ?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is just to terminate and return early. This is the detection logic which will check if user has enabled or disabled AVX2 based on OS.

NPE is happening when it is ran on some other platform like FreeBSD other than linux, windows and mac because the default value of isAVX2Supported is null. So, we are fixing it here by returning false if it is still null

@naveentatikonda naveentatikonda merged commit 170f58c into opensearch-project:main Sep 30, 2025
40 checks passed
0ctopus13prime pushed a commit to 0ctopus13prime/k-NN that referenced this pull request Oct 5, 2025
Signed-off-by: Naveen Tatikonda <[email protected]>
Signed-off-by: Vikasht34 <[email protected]>
Co-authored-by: Vikasht34 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Fixes Changes to a system or product designed to handle a programming bug/glitch v3.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Non-Windows, non-Mac OS, non-Linux case is not considered in PlatformUtils leading to uncaught exception

4 participants