Skip to content

Conversation

@Kevincoooool
Copy link
Contributor

esp_video组件存在数组越界Bug:// 错误的代码(第296-297行)
s_sensor_sccb_mask[i2c_port].sccb_io[0] = NULL;
s_sensor_sccb_mask[i2c_port].sccb_io[1] = NULL; // ❌ 数组越界! 问题分析:
sccb_io 数组大小定义为 ESP_VIDEO_INIT_DEV_NUMS
这是一个枚举值,取决于启用的视频设备数量
您只启用了DVP设备,所以 ESP_VIDEO_INIT_DEV_NUMS = 1
数组只有 sccb_io[0],但代码试图访问 sccb_io[1]
GCC的 -Werror=array-bounds 检测到越界访问并报错
🔧 修复内容
// 修复后的代码(第296-298行)
s_sensor_sccb_mask[i2c_port].handle = NULL;
for (int j = 0; j < ESP_VIDEO_INIT_DEV_NUMS; j++) {
s_sensor_sccb_mask[i2c_port].sccb_io[j] = NULL;
}
将硬编码的数组访问改为循环:
这样无论 ESP_VIDEO_INIT_DEV_NUMS 的值是多少(1、2、3...),代码都能正确工作。

@github-actions github-actions bot changed the title fix bug fix bug (AEGHB-1270) Oct 16, 2025
@WangYuxin-esp
Copy link
Collaborator

Thanks. Will fix this.

@Y1hsiaochunnn
Copy link

Y1hsiaochunnn commented Oct 16, 2025

Hi @Kevincoooool ,我运行xiaozhi-esp32,复现了。不过组件本身的examples编译没问题,会不会是c++编译要求高导致的?

@WangYuxin-esp
Copy link
Collaborator

但是没有在官方的示例中复现到这个问题,似乎和传入 esp_video_init 的传参有关系。你能打包一个最小的复现程序吗(删除 build 目录,保留 sdkconfig 文件)?

@Kevincoooool
Copy link
Contributor Author

Hi @Kevincoooool ,我运行xiaozhi-esp32,复现了。不过组件本身的examples编译没问题,会不会是c++编译要求高导致的?

我也是用xiaozhi-esp32,把video组件版本改为1.3.0,然后芯片选用ESP32S3,启用DVP摄像头再编译就会复现,因为S3不支持MIPI

@WangYuxin-esp
Copy link
Collaborator

不支持 MIPI 的情况下, 根据依赖关系,它是自动关掉 MIPI 相关的代码的。
什么编译环境?

@Kevincoooool
Copy link
Contributor Author

Kevincoooool commented Oct 16, 2025

但是没有在官方的示例中复现到这个问题,似乎和传入 esp_video_init 的传参有关系。你能打包一个最小的复现程序吗(删除 build 目录,保留 sdkconfig 文件)?

sdkconfig.zip

使用的xiaozhi-esp32最新代码,组件太多打包比较大,把sdkconfig放上来了
xiaozhi-esp32/managed_components/espressif__esp_video/src/esp_video_init.c:297:53: error: array subscript 1 is above array bounds of 'struct esp_sccb_io_t *[1]' [-Werror=array-bounds=]
297 | s_sensor_sccb_mask[i2c_port].sccb_io[1] = NULL;

@Kevincoooool
Copy link
Contributor Author

不支持 MIPI 的情况下, 根据依赖关系,它是自动关掉 MIPI 相关的代码的。 什么编译环境?

IDF5.5.1

@WangYuxin-esp
Copy link
Collaborator

WangYuxin-esp commented Oct 16, 2025

不在 xiaozhi 里面编译,是不是就没有报错了? 对比了一些编译配置,是编译的优化级别不一样:
compiler

@WangYuxin-esp
Copy link
Collaborator

@Kevincoooool 请更新 esp-video 的 yml 文件中的 版本号到 1.3.1。并更新 esp-video 的 changlog:

1.3.1

  • Fix array bounds check failure in destroy_sccb_device() when compile option is OPTIMIZATION_SIZE

@Kevincoooool
Copy link
Contributor Author

@Kevincoooool 请更新 esp-video 的 yml 文件中的 版本号到 1.3.1。并更新 esp-video 的 changlog:

1.3.1

  • Fix array bounds check failure in destroy_sccb_device() when compile option is OPTIMIZATION_SIZE

好的

@WangYuxin-esp
Copy link
Collaborator

@Kevincoooool 请更新 esp-video 的 yml 文件中的 版本号到 1.3.1。并更新 esp-video 的 changlog:

1.3.1

  • Fix array bounds check failure in destroy_sccb_device() when compile option is OPTIMIZATION_SIZE

好的

请合并提交到一个 commit message:
git rebase -i HEAD~2

@WangYuxin-esp
Copy link
Collaborator

@Kevincoooool 请更新 esp-video 的 yml 文件中的 版本号到 1.3.1。并更新 esp-video 的 changlog:

1.3.1

  • Fix array bounds check failure in destroy_sccb_device() when compile option is OPTIMIZATION_SIZE

好的

请合并提交到一个 commit message: git rebase -i HEAD~2

commit msg 太简单啦,可以通过 git commit --amend 命令修改为 fix: fix array bounds check failure in destroy_sccb_device

1.Fix array bounds check failure in destroy_sccb_device() when compile option is OPTIMIZATION_SIZE.
2.Update the component version and update the CHANGELOG.
@Kevincoooool
Copy link
Contributor Author

@Kevincoooool 请更新 esp-video 的 yml 文件中的 版本号到 1.3.1。并更新 esp-video 的 changlog:

1.3.1

  • Fix array bounds check failure in destroy_sccb_device() when compile option is OPTIMIZATION_SIZE

好的

请合并提交到一个 commit message: git rebase -i HEAD~2

commit msg 太简单啦,可以通过 git commit --amend 命令修改为 fix: fix array bounds check failure in destroy_sccb_device

好嘞,感谢感谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants