JNA 5.13.0: C++ Side Mutex Creation Fails with "Invalid Memory" Error
还没有人认领这个 Issue。
评估
调研方向
首先使用提供的 createMutex 示例复现 Java JNA 对 MSVC 构建的 C++ 库的调用,然后检查 Java/native 边界,以及报告无效内存访问的 mutex 构造或锁定位置。完成的标准是确定无效内存访问的原因,并确认在 Windows 10 上修正后的交互正常。
由索引模型根据 Issue 内容生成。
描述
Description:
When using JNA 5.13.0 to interface with a C++ library, an issue arises where attempting to create a mutex on the C++ side results in an "invalid memory" error. This issue occurs consistently whenever the mutex creation is attempted. Below are the details of the environment and the problem:
Environment:
- Java Version: 1.8.0_361 (Oracle JDK)
- JNA Version: 5.13.0(5.17.0 same err)
- Operating System: [Windows 10]
- C++ Compiler/Environment: [MSVC]
Problem Description:
The Java application uses JNA to interact with a native C++ library.
On the C++ side, when attempting to create a std::mutex (or any other type of mutex), the program throws an error related to invalid memory access.
The error message or behavior indicates that the memory allocation or usage for the mutex is corrupted or invalid.
Example Code:
Java Side:
public interface MyLibrary extends Library {
MyLibrary INSTANCE = Native.load("mylibrary", MyLibrary.class);
void createMutex();
}
public class Main {
public static void main(String[] args) {
MyLibrary.INSTANCE.createMutex();
}
}
C++ Side:
#include <mutex>
extern "C" {
void createMutex() {
std::mutex mtx; // Attempting to create a mutex
mtx.lock(); // Error occurs here or during construction
mtx.unlock();
}
}
Error
java.lang.Error: Invalid memory access
- 主要语言
- Java
- 星标
- 8.9k
- 派生
- 1.7k
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
java-native-access/jna 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 88/100
java-native-access/jna#1740 ·
-
难度 4/5 3-5 天 新手友好度 66/100
java-native-access/jna#1738 ·
-
难度 4/5 3-5 天 新手友好度 45/100
java-native-access/jna#1736 ·
-
难度 3/5 1-2 天 新手友好度 65/100
java-native-access/jna#1717 ·
-
Windows32Exception - The parameter is incorrect可能重新可做 @marktech0813 于 331 天前认领,目前没有进行中的 PR。 未关闭
难度 4/5 3-5 天 新手友好度 35/100
java-native-access/jna#1700 · 11 条评论 ·
查看 java-native-access/jna 的全部 Issue
相似的 Issue
-
enhancement
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
waiting-for-triage
难度 1/5 1 小时以内 新手友好度 72/100
spring-cloud/spring-cloud-openfeign#1443 ·
维护者通常 1 天内回复
-
难度 1/5 1-3 小时 新手友好度 84/100
ADORSYS-GIS/keycloak-oid4vp-plugin#221 ·
维护者通常 2 天内回复
-
status: team-only type: dependency-upgrade
难度 2/5 1-3 小时 新手友好度 65/100
spring-projects/spring-boot#52099 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 67/100
tchiotludo/akhq#3307 · 1 个 reaction ·
维护者通常 1 天内回复