Search Unity

Bug Random error " Invalid memory pointer was detected in ThreadsafeLinearAllocator::Deallocate! "

Discussion in 'Unity Transport' started by Kichang-Kim, Apr 26, 2022.

  1. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    1,011
    Hi. I found that when I test my project which using Unity Transport 1.0.0, it shows random error like this:

    Invalid memory pointer was detected in ThreadsafeLinearAllocator::Deallocate!


    But it has no stack trace, so I can't figure out what make this error. It does not occurred when play offline mode or editor, only shown when play in iOS device with Unity Transport enabled.

    Any ideas?

    Thanks.
     
  2. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    441
    Are you using Unity Transport on its own or in conjunction with Netcode for GameObjects? We've had a report of the same error recently, but coming from Netcode from GameObjects. Also what editor version are you using?

    Otherwise, the lack of stack trace would tend to indicate that this error could be coming from a Burst-compiled job. If you have a way of reproducing this reliably, could you try to reproduce it with Burst disabled (you'll need to disable it both from the Jobs menu and from the Burst AOT settings in your project settings).
     
  3. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    1,011
    I used Unity Transport directly with Unity 2021.3.0f1. I will report if I find reproducing steps.
     
  4. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    1,011
    Hmm, It has no stack-trace even Burst Compilation is disabled. (Other logs from Job shows stack trace correctly.)
     
  5. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    1,011
    I found that increasing queueCapacity and maximumPayloadSize by using NetworkSettings.WithBaselibNetworkInterfaceParameters() makes that this error is disappeared.
     
  6. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    441
    Had a quick look at it, and the error is actually coming from deep inside native memory management code, where no stack traces are outputted. If you have access to an editor version >2022.1.0a13, there should be a "-diag-temp-memory-leak-validation" console switch to enable more diagnostics.

    Interesting that increasing queue capacities and maximum payload size solved the issue. That does help narrowing it down a bit. Thanks for reporting your findings! If you find out anything else, please let us know.