当前位置: 首页 > 工具软件 > fastJSON 2 > 使用案例 >

今天遇到了alibaba.fastjson2导致的程序直接挂到的问题:A fatal error has been detected by the Java Runtime Environment:

蔡辰钊
2023-12-01

先说错误:

Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@26ebc1f0]
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f4c2a73f9f5, pid=2375325, tid=0x00007f4bb4eef700
#
# JRE version: OpenJDK Runtime Environment (8.0_312-b07) (build 1.8.0_312-b07)
# Java VM: OpenJDK 64-Bit Server VM (25.312-b07 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# J 10149 C1 com.alibaba.fastjson2.util.JDKUtils.getCharArray(Ljava/lang/String;)[C (33 bytes) @ 0x00007f4c2a73f9f5 [0x00007f4c2a73f960+0x95]
#
# Core dump written. Default location: /root/core or core.2375325
#
# An error report file with more information is saved as:
# /root/hs_err_pid2375325.log
Compiled method (c1) 65629336 10149   !   3       com.alibaba.fastjson2.util.JDKUtils::getCharArray (33 bytes)
 total in heap  [0x00007f4c2a73f7d0,0x00007f4c2a73ff88] = 1976
 relocation     [0x00007f4c2a73f8f8,0x00007f4c2a73f958] = 96
 main code      [0x00007f4c2a73f960,0x00007f4c2a73fd80] = 1056
 stub code      [0x00007f4c2a73fd80,0x00007f4c2a73fe28] = 168
 oops           [0x00007f4c2a73fe28,0x00007f4c2a73fe30] = 8
 metadata       [0x00007f4c2a73fe30,0x00007f4c2a73fe40] = 16
 scopes data    [0x00007f4c2a73fe40,0x00007f4c2a73fec0] = 128
 scopes pcs     [0x00007f4c2a73fec0,0x00007f4c2a73ff50] = 144
 dependencies   [0x00007f4c2a73ff50,0x00007f4c2a73ff58] = 8
 handler table  [0x00007f4c2a73ff58,0x00007f4c2a73ff70] = 24
 nul chk table  [0x00007f4c2a73ff70,0x00007f4c2a73ff88] = 24
#
# If you would like to submit a bug report, please visit:
#   https://bugzilla.redhat.com/enter_bug.cgi?product=Red%20Hat%20Enterprise%20Linux%208&component=java-1.8.0-openjdk
#

原因是在使用:

com.alibaba.fastjson2.JSON.parseArray(sysOrg.getParentJson(),Integer.class);

 sysOrg的parentJson为null。导致了这个错误。

我特意试了一下原来的版本:

com.alibaba.fastjson.JSON

如果值为null的时候,会返回null。而不会导致整个程序挂掉。

所以在使用新版本的东西的时候一定要好好测一测。虽然问题在我自己,但是版本间的差异还是要注意啊。

我用的版本:

        <dependency>
            <groupId>com.alibaba.fastjson2</groupId>
            <artifactId>fastjson2</artifactId>
            <version>2.0.1</version>
        </dependency>

后续版本没有测试,是否解决了这个问题。

 类似资料: