Skip to content

ArrayList constructor init fail without errors #1551

@Kailo97

Description

@Kailo97

Help us help you

  • I have checked that my issue doesn't exist yet.
  • I have tried my absolute best to reduce the problem-space and have provided the absolute smallest test-case possible.
  • I can always reproduce the issue with the provided description below.

Environment

  • Operating System version: Windows 10
  • Game/AppID (with version if applicable): CS:GO 740 1.37.9.6/13796 1305/8278
  • Current SourceMod version: 1.10.0.6510
  • Current SourceMod snapshot: 1.11.0.6729
  • Current Metamod: Source snapshot: 1.12.0-dev+1149

Description

If plugin can't to resize ArrayList in constructor, keep size 0 without errors.

if (params[2])
{
array->resize(params[2]);
}

Appear in plugins with big allocation like replay bot for bhop servers. It's bad, that this type of error is silent and unclear.

Problematic Code (or Steps to Reproduce)

Here is test case. Tested on windows and linux. Sometimes can successfully pass allocation.

public void OnPluginStart()
{
    ArrayList list = new ArrayList(262144, 2000);
    PrintToServer("init size %d", list.Length);
    for (int i = 0; i < 2000; i++)
    {
        list.Set(i, 123);
    }
    PrintToServer("%d %d", list.Get(1999), list.Length);
}

Logs

init size 0
L 07/22/2021 - 12:52:07: [SM] Exception reported: Invalid index 0 (count: 0)
L 07/22/2021 - 12:52:07: [SM] Blaming: arraylist.smx
L 07/22/2021 - 12:52:07: [SM] Call stack trace:
L 07/22/2021 - 12:52:07: [SM]   [0] ArrayList.Set
L 07/22/2021 - 12:52:07: [SM]   [1] Line 7, E:\workdir\_work\arraylist\arraylist.sp::OnPluginStart

Metadata

Metadata

Assignees

No one assigned

    Labels

    Buggeneral bugs; can be anything

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions