Skip to content

Race Condition in IKVM JNI Layer Causes NegativeArraySizeException During Concurrent Startup #714

@gmohd2786

Description

@gmohd2786

We are encountering a critical race condition in the IKVM JNI layer (JNIEnv.NewObjectArray()) when running Java applications on IIS/.NET. This results in NegativeArraySizeException during concurrent application startup, especially after IIS resets.

Details:

Exception: NegativeArraySizeException in JNIEnv.NewObjectArray()
Environment: Windows Server 2022, .NET Runtime, IIS, Spring Framework
Reproducibility: Intermittent, only under concurrent load at startup (IIS reset)
Impact: Production downtime, data loss (empty site/page mappings), silent failures
Why Application-Level Workarounds Are Not Acceptable:

Retry logic can result in empty arrays, causing missing sites/pages and broken analytics
Fail-fast leads to downtime and restart loops
Synchronization cannot cover all JNI code paths and impacts performance
Request:

Please investigate thread-safety and initialization order in the JNI layer
Ensure JNIEnv.NewObjectArray() and related methods are fully protected from concurrent access before initialization
Add concurrent access tests to the IKVM test suite
We have a detailed bug report and root cause analysis available, including suggested fixes and test cases. Please advise how best to share this information and collaborate on a solution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions