Navigation

    全志在线开发者论坛

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • 在线文档
    • 社区主页

    【危险】内存越界却不报错

    D1系列-RISC-V
    2
    2
    68
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Z
      zhaodongyu LV 3 last edited by

      最近写riscv算子的过程中发现这么一个问题:
      比如:
      在c文件里定义一个数组a[10]
      调用汇编文件里的test函数

      汇编文件的test函数根据入参数组a进行数据读写操作,即使超过了数组a的范围,也能够正常读写且不报错。(编译运行都不会报错)

      这很危险啊,尤其是写操作会影响到非a数组地址内的内容。

      ps:我用的是riscv-v的指令

      可以暂时不要关注为什么汇编会越界访问~

      1 Reply Last reply Reply Quote Share 0
      • aozima
        aozima LV 6 last edited by

        @zhaodongyu 在 【危险】内存越界却不报错 中说:

        汇编文件里的test函数

        可以试着学下rust,不要用unsafe

        1 Reply Last reply Reply Quote Share 0
        • 1 / 1
        • First post
          Last post

        Copyright © 2022 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号

        行为准则 | 用户协议 | 隐私权政策