zoukankan      html  css  js  c++  java
  • golang 常见问题解析: panic: runtime error: makeslice: len out of range

    https://github.com/golang/go/issues/38673

    that error is triggered by the makeslice function in the runtime, when the len argument of make( ) called on a slice is either negative of unreasonably big; e.g:

    n := -1
    sl := make([]int, n)   // make argument is negative
    

      

    n := 1<<60
    sl := make([]int, n)   // make argument is too big
    

      

    (make is the function that is used to allocate an array, len is the requested length of the array. For obvious reasons, it makes no sense to ask for a negative len, or a lenght that would make the array require thousands of terabytes of memory).

    This means that the Go application you are using has a programming error and it doesn't check that a number that is passed to make somewhere is negative or too big.

    Since this is not a Go bug, but an issue in the user code that needs to be fixed in the application, I'm closing this issue. If you believe that this actually may be a bug in the Go compiler on in the runtime, please provide an autocontained code snippet that

    1) is correct

    2) triggers the error;

    the upper limit of a slice is some significant fraction of the address space of a process. For 32 bit processes, between 1-2 gb, perhaps a little less on 32 bit windows because of DLL address space fragmentation. For 64 bit processes, in excess of a terrabyte, 10^40 bits.

  • 相关阅读:
    淘女郎相册爬虫(Python编写)
    在 Linux 命令行中使用和执行 PHP 代码
    PHP PhantomJs中文文档(翻译)
    PHP
    PHP
    PHP
    PHP — 用PHP实现一个双向队列
    Redis — CentOS6.4安装Redis以及安装PHP客户端phpredis
    Linux
    Memcache学习笔记
  • 原文地址:https://www.cnblogs.com/saryli/p/15160977.html
Copyright © 2011-2022 走看看