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.

  • 相关阅读:
    react-native 安卓支持 gif动态图
    react-navigation,StackNavigator,TabNavigator 导航使用
    poj3694 网络(板子题)
    POJ1275 Cashier Employment 差分约束(优化 二分)
    Codeforces Round #667 (Div. 3)
    POJ1201 Intervals 差分约束(贪心也可)
    YY的GCD
    Codeforces Round #666 (Div. 2) A~E
    Rendezvous
    创世纪
  • 原文地址:https://www.cnblogs.com/saryli/p/15160977.html
Copyright © 2011-2022 走看看