---
title: 使用 ODC 调试带有 CursorForLoop 语句的存储过程时，OBServer 进程可能 core dump-OceanBase数据库使用指南
description: 了解OceanBase数据库在实际应用中关于使用 ODC 调试带有 CursorForLoop 语句的存储过程时，OBServer 进程可能 core dump相关的常见问题和使用技巧，帮助您快速解决使用 ODC 调试带有 CursorForLoop 语句的存储过程时，OBServer 进程可能 core dump的难题。
---
切换语言

- 中文站 - 简体中文
- International - English
- 日本站 - 日本語

划线反馈

# 使用 ODC 调试带有 CursorForLoop 语句的存储过程时，OBServer 进程可能 core dump

更新时间：2026-06-04 09:56

适用版本： V2.2.x、V3.1.x、V3.2.x 内容类型：Troubleshoot  

## 问题现象

在 ODC 中调试如下含有 `CursorForLoop` 的存储过程时，可能出现 OBServer 进程 core dump。

```sql
-- reboot 数据库后初始化数据：
create table t(col1 int, col2 int, col3 int, col4 int, col5 int, col6 int, col7 int, col8 int, col9 int, col10 int);
insert into t values(1,2,3,4,5,6,7,8,9,10);
select * from t;
commit;

-- ODC 连接到数据库调试如下匿名块可以复现 core 掉问题
DECLARE
  i NUMBER;
BEGIN
  for idx in (select * from t) loop
    dbms_output.put_line(1);
    for idx in (select * from t) loop
      dbms_output.put_line(2);
      for idx in (select * from t) loop
        dbms_output.put_line(3);
      end loop;
    end loop;
  end loop;

  for idx in (select * from t) loop
    dbms_output.put_line(4);
  end loop;
END;

```

`for idx in (select * from t) loop ... end` 为 `CursorForLoop`，调试此处时可能出现 core dump。

## 关键诊断信息

### 触发条件

使用 ODC 调试带有 `CursorForLoop` 语句的存储过程。

## 问题原因

实现 `CursorForLoop` 语句时，需要使用一个变量来保存当前的 index，在 OceanBase 数据库 V4.x 之前版本，该变量保存在栈上，循环结束后该变量的栈内存会被释放。而调试器读取全部变量时，如果该栈内存已被复用，调试器可能读到脏数据导致 core dump。

## 问题风险及影响

偶现问题，可能影响用户调试存储过程。

## 影响版本

OceanBase 数据库 V2.2.77 GA（oceanbase-2.2.77-20210508211731）及之后版本、V3.1.2 GA（oceanbase-3.1.2-20210618150922）及之后版本、V3.2.3 GA（oceanbase-3.2.3.0-20220418212020）及之后版本、V3.2.4 GA（oceanbase-3.2.4.0-100000072022102819）及之后版本。

## 解决方法及规避方式

- 升级到问题已修复版本，目前已修复的版本包括 OceanBase 数据库 V2.2.77 BP19（oceanbase-2.2.77-119000122024060513）及之后版本、V3.2.3 BP8 Hotfix4（oceanbase-3.2.3.3-108040052023060909）版本、V3.2.3 BP8 Hotfix5（oceanbase-3.2.3.3-108050012023070409）版本、V3.2.3 BP8 Hotfix6（oceanbase-3.2.3.3-108060012023102510）版本、V3.2.3 BP9（oceanbase-3.2.3.3-109000182023071410）及之后版本、V3.2.4 BP4（oceanbase-3.2.4.4-104000052023062021）及之后版本。
 - 禁止对包含 `CursorForLoop` 的存储过程进行调试。

上一篇

[访问不存在的 Package.Cursor 导致 Core](https://www.oceanbase.com/knowledge-base/oceanbase-database-20000045537)

下一篇

[OBKV 使用带 CURRENT_STRAMP 属性的列作为 TTL 过期列导致节点宕机](https://www.oceanbase.com/knowledge-base/oceanbase-database-1000000000452197) ![有帮助](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*y6ocSqN8cqsAAAAAAAAAAAAAARQnAQ)![无帮助](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*BG9IQJyLHF8AAAAAAAAAAAAAARQnAQ)![反馈](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*eTWdQKCRKHwAAAAAAAAAAAAAARQnAQ)[AI](https://www.oceanbase.com/obi) 咨询热线
