[BUG]
- Dominant language
- Java
- Stars
- 4.4k
- Forks
- 613
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 6
Description
### 问题描述
在 Solaris SPARC 平台将 Fastjson2 从 2.0.32 升级至 2.0.57 后,调用 `JSON.toJSONString` 时触发 JVM 崩溃(SIGBUS,BUS_ADRALN)。崩溃发生在 `Unsafe_GetLong`,与 `IOUtils.getLongLE` 的内存对齐访问有关。
---
### 环境信息
- **OS信息**:Oracle Solaris 11.4 SPARC(SunOS 5.11),144 vCPU,物理内存 38 GB
- **JDK信息**:Oracle JDK 1.8.0_461,HotSpot 64-Bit Server VM (25.461-b25)
- **版本信息**:Fastjson2 2.0.57(回退到 2.0.32 可规避问题)
---
### 重现步骤
1. 在 Solaris SPARC WebLogic 容器中启动应用
2. 调用 `com.alibaba.fastjson2.JSON.toJSONString(obj)`
3. JVM 崩溃并生成 hs_err_pid.log,关键帧如下:
```java
V [libjvm.so+0xdaf360] Unsafe_GetLong+0x188
j com.alibaba.fastjson2.util.IOUtils.getLongLE([CI)J+12
j com.alibaba.fastjson2.JSONWriterUTF16.writeString([C)V+123
```
---
### 期待的正确结果
升级后应能正常完成 JSON 序列化,无 SIGBUS 或 JVM 崩溃。
---
### 相关日志输出
```text
# A fatal error has been detected by the Java Runtime Environment:
# SIGBUS (0xa) at pc=0xffffffff28eaf360, pid=5439, tid=0x000000000000006d
# Problematic frame:
# V [libjvm.so+0xdaf360] Unsafe_GetLong+0x188
siginfo: si_signo: 10 (SIGBUS), si_code: 1 (BUS_ADRALN), si_addr: 0x00000007b7c4caa2
```
---
#### 附加信息
- **线程上下文**:WebLogic `[ACTIVE] ExecuteThread: '0'` 在执行序列化时崩溃
- **JVM 参数**:`-Xmx1280m -XX:+UseCompressedOops`
- **平台特点**:SPARC 对非对齐内存访问敏感,可能与 `Unsafe.getLong` 优化冲突
- **临时方案**:回退到 Fastjson2 2.0.32 可避免该问题
Contributor guide
Research direction
Start by reading com.alibaba.fastjson2.util.IOUtils.getLongLE and the call path in JSONWriterUTF16.writeString, then reproduce the failure on Oracle Solaris 11.4 SPARC with JDK 1.8.0_461 using the reported JSON.toJSONString invocation. Done means serialization completes on SPARC without SIGBUS or JVM crashes while preserving behavior on supported platforms.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100