java - 在代码中解密 AES 加密的授权 token 方法时 Jar 崩溃。 hs_err _

此问题在生产环境中大约每天发生一次。负载约为 20TPS,服务器上的每个请求都会调用 AES 解密两次。该错误不是针对所有请求生成的,而是每天崩溃一次。以下是 hs_err_pid 文件的片段。

Java 运行时环境检测到 fatal error :

SIGSEGV (0xb) 在 pc=0x00007f26cc5de47e,pid=53978,tid=0x00007f26837f7700 JRE 版本:Java(TM) SE Runtime Environment (8.0_241-b31) (build 1.8.0_241-b31) Java VM:Java HotSpot(TM) 64 位服务器 VM(25.241-b31 混合模式 linux-amd64 压缩 oops) 有问题的框架: v ~StubRoutines::arrayof_jbyte_fill

Current thread (0x00007f26d0a03800):  JavaThread "http-nio-9094-exec-10" daemon 
[_thread_in_Java, id=54617, stack(0x00007f26836f7000,0x00007f26837f8000)]


Stack: [0x00007f26836f7000,0x00007f26837f8000],  sp=0x00007f26837f44f0,  free space=1013k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
v  ~StubRoutines::arrayof_jbyte_fill
J 26458 C2 java.util.Arrays.fill([BB)V (21 bytes) @ 0x00007f26cc737ca2 
[0x00007f26cc737c60+0x42]
j  com.sun.crypto.provider.CipherCore.fillOutputBuffer([BI[BII[B)I+73
j  com.sun.crypto.provider.CipherCore.doFinal([BII)[B+65
j  com.sun.crypto.provider.AESCipher.engineDoFinal([BII)[B+7
j  javax.crypto.Cipher.doFinal([B)[B+30
j  com.hello.genesys.common.AES.decrypt([BLjava/lang/String;)[B+92

解密方法如下:

public static byte[] decrypt(byte[] data, String password) throws Exception {
    try {
        log.info("/// Inside the decrypter method of AES class ////");
        if (null == cipher) {
            log.info("The Cipher is null and hence forming new object of cipher");
            cipher = Cipher.getInstance("AES/ECB/PKCS5PADDING");
        }

        log.info("Key generation method to be called");
        Key k = new SecretKeySpec(password.getBytes(), AES_ENCRYPTION_TYPE);
        
        log.info("Cipher initialization to be done");
        cipher.init(Cipher.DECRYPT_MODE, k);

        log.info("The byte array value to be returned");
        
        return cipher.doFinal(data);
    } catch (Throwable e) {
        log.info("Inside Exception of AES decryption method");
        e.printStackTrace();
    }
    return null;
}

此方法在不同的类中调用:

byte[] decrypter = AES.decrypt(decodeToken, _env("tokenSalt"));

它不会抛出异常,但会因 arrayof_jbyte_fill 相关错误而崩溃。请帮我解决这个问题,因为它只出现在生产环境中,而在低层环境中不会出现。链接到 hs_err_pid 文件以获取更多详细信息:https://drive.google.com/file/d/1WDG4rm7vIw6HDbhZPtXjud7r8TEh4d74/view?usp=sharing

最佳答案

错误在于密码对象本身。我现在已经创建并初始化了一个本地密码对象而不是全局密码对象,并且在部署后 2 周内似乎没有崩溃。因此,由于 2 个解密过程背靠背同时发生,因此在第二次解密请求期间它会崩溃,因为第一个解密请求仍在使用该对象。所以这是我对这个问题的分析

关于java - 在代码中解密 AES 加密的授权 token 方法时 Jar 崩溃。 hs_err _pid 文件提到 arrayof_jbyte_fill,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63222761/

相关文章:

google-api - Google Calendar API 在单个批处理请求中返回 403 R

python - 我可以向父跨度 Datadog 添加标签吗

reactjs - 如何在 React 中添加对状态码 400 的验证

delphi - TEdgeBrowser 导航失败,出现错误 "File not found"

swagger - 我如何记录我没有所有权的对象?

firebase - 如何将复杂的 Firestore 查询卸载到 Firebase Cloud F

amazon-web-services - ECS 服务的两个或多个实例之间的通信

r - 以矩阵形式计算我的投资组合中股票之间的 beta

css - 实现背景过滤器 : opacity(0%) in CSS

docker - WSL2 上禁用了 bridge-nf-call-iptables 和 bridg