Navigation

    全志在线开发者论坛

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

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

    MR Series
    4
    5
    2211
    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 4 last edited by

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

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

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

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

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

      H Copper 2 Replies Last reply Reply Quote Share 0
      • aozima
        aozima LV 7 last edited by

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

        汇编文件里的test函数

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

        1 Reply Last reply Reply Quote Share 0
        • H
          ht1123 LV 4 @zhaodongyu last edited by

          @zhaodongyu
          你好,想请问一下怎么在哪吒上使用riscv-v的指令?

          Z 1 Reply Last reply Reply Quote Share 0
          • Z
            zhaodongyu LV 4 @ht1123 last edited by xiaowenge

            @ht1123 可以看看这个:https://github.com/riscv/riscv-v-spec

            1 Reply Last reply Reply Quote Share 0
            • Copper
              Copper LV 4 @zhaodongyu last edited by

              @zhaodongyu
              C语言不就是这样么?数组边界是要在程序里面自己写条件判断来保证的。

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

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

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