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.

  • 相关阅读:
    MySQL集群常见高可用方案(转)
    upsource使用
    Hystrix 使用
    astah UML 先画图、后编程
    java ThreadLocal 使用
    Java基础 Annotation使用
    LVS+Keepalived+Nginx+Tomcat高可用负载均衡集群配置
    招聘求职学习
    Rotate List 面试题
    vue前台(四点二)
  • 原文地址:https://www.cnblogs.com/saryli/p/15160977.html
Copyright © 2011-2022 走看看