Skip to content

Fix potential out of bounds scope allocation #559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

SuperFola
Copy link
Member

@SuperFola SuperFola commented Jul 9, 2025

Description

It is possible for ArkScript to create too many variables (more than 8192 at once), which results in a segfault. This aims to fix this bug, but I am aware that it will likely hinder performance.

Checklist

  • I have read the Contributor guide
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation if needed
  • I have added tests that prove my fix/feature is working
  • New and existing tests pass locally with my changes

Copy link

github-actions bot commented Jul 9, 2025

Static analysis report

Lizard report

Listing only functions with cyclomatic complexity >= 15 or NLOC >= 100 or parameters >= 6.

Report about files you didn't modify in this PR
Filename Start line:end line Function name Parameters NLOC CCN
src/arkreactor/VM/VM.cpp 450:1884 Ark::VM::safeRun 3 1200 246
src/arkreactor/Compiler/Macros/Processor.cpp 239:617 Ark::internal::MacroProcessor::evaluate 3 355 125
src/arkreactor/Compiler/BytecodeReader.cpp 274:557 Ark::BytecodeReader::display 4 241 95
src/arkreactor/Exceptions.cpp 87:297 Ark::Diagnostics::makeContext 9 152 61
src/arkreactor/Compiler/Lowerer/ASTLowerer.cpp 522:678 Ark::internal::ASTLowerer::handleCalls 5 123 38
src/arkscript/JsonCompiler.cpp 27:260 JsonCompiler::_compile 1 200 36
include/Ark/Compiler/AST/Parser.hpp 107:196 Ark::internal::ARK_APIParser::string 0 87 32
src/arkreactor/Compiler/NameResolution/NameResolutionPass.cpp 162:273 Ark::internal::NameResolutionPass::visitKeyword 3 93 32
src/arkscript/main.cpp 23:352 main 2 284 31
src/arkreactor/Compiler/AST/Node.cpp 171:269 Ark::internal::Node::repr 0 84 28
src/arkreactor/Compiler/Macros/Processor.cpp 102:185 Ark::internal::MacroProcessor::processNode 3 61 27
src/arkreactor/Compiler/Lowerer/ASTLowerer.cpp 138:242 Ark::internal::ASTLowerer::compileExpression 5 86 27
src/arkreactor/Compiler/AST/Node.cpp 271:344 Ark::internal::Node::debugPrint 1 64 24
src/arkreactor/TypeChecker.cpp 110:194 Ark::types::generateError 5 72 24
src/arkreactor/Compiler/NameResolution/NameResolutionPass.cpp 54:160 Ark::internal::NameResolutionPass::visit 2 87 23
src/arkreactor/Compiler/AST/Parser.cpp 292:427 Ark::internal::Parser::import_ 0 109 23
src/arkreactor/Compiler/Lowerer/ASTLowerer.cpp 268:326 Ark::internal::ASTLowerer::compileListInstruction 4 48 22
src/arkreactor/VM/VM.cpp 2003:2112 Ark::VM::backtrace 3 94 22
include/utf8.hpp 138:184 utf8::isValid 1 44 21
src/arkreactor/Compiler/AST/Optimizer.cpp 33:83 Ark::internal::Optimizer::countAndPruneDeadCode 1 42 20
src/arkscript/REPL/Utils.cpp 52:184 Ark::internal::getColorPerKeyword 0 110 19
src/arkreactor/TypeChecker.cpp 28:108 Ark::types::displayContract 4 70 19
src/arkreactor/Compiler/NameResolution/StaticScope.cpp 68:109 Ark::internal::NamespaceScope::get 2 32 18
src/arkreactor/VM/Value.cpp 72:132 Ark::Value::toString 1 48 18
src/arkreactor/Compiler/Macros/Executors/Function.cpp 16:88 Ark::internal::FunctionExecutor::applyMacro 2 55 17
include/Ark/Compiler/AST/Predicates.hpp 132:156 Ark::internal::IsSymbol::operator ( ) 1 24 16
src/arkscript/Formatter.cpp 168:224 Formatter::format 3 53 16
src/arkreactor/Compiler/Macros/Processor.cpp 699:738 Ark::internal::MacroProcessor::isConstEval 1 35 16
src/arkscript/Formatter.cpp 274:315 Formatter::formatFunction 2 35 15
src/arkreactor/Compiler/Lowerer/ASTLowerer.cpp 78:94 Ark::internal::ASTLowerer::nodeProducesOutput 1 13 15
src/arkreactor/Compiler/IntermediateRepresentation/IROptimizer.cpp 12:197 Ark::internal::IROptimizer::IROptimizer 1 162 4
src/arkreactor/Exceptions.cpp 299:310 Ark::Diagnostics::helper 9 11 2

CppCheck report

Report files about files you didn't modify in this PR
Filename Line Type Description
include/Ark/VM/Value/Procedure.hpp 43 style Class 'Procedure' has a constructor with 1 argument that is not explicit.
include/Ark/VM/Value/Procedure.hpp 51 style Class 'Procedure' has a constructor with 1 argument that is not explicit.
include/Ark/Logger.hpp 77 performance Function parameter 'data' should be passed by const reference.
src/arkreactor/Builtins/IO.cpp 81 style Parameter 'n' can be declared as reference to const
src/arkreactor/Builtins/IO.cpp 105 style Parameter 'n' can be declared as reference to const
src/arkreactor/Compiler/BytecodeReader.cpp 440 style struct member 'Arg::kind' is never used.
src/arkreactor/Compiler/NameResolution/NameResolutionPass.cpp 142 style Consider using std::find_if algorithm instead of a raw loop.
src/arkreactor/VM/State.cpp 187 style Consider using std::any_of, std::all_of, std::none_of algorithm instead of a raw loop.
src/arkreactor/VM/Value/Procedure.cpp 15 performance Variable 'm_procedure' is assigned in constructor body. Consider performing initialization in initialization list.

@coveralls
Copy link

Coverage Status

coverage: 86.652% (-0.02%) from 86.675%
when pulling 7c77ed7 on fix/scope-bad-alloc
into 6face81 on dev.

Copy link

github-actions bot commented Jul 9, 2025

Fuzzing report

/usr/local/bin/afl-whatsup status check tool for afl-fuzz by Michal Zalewski

Summary stats

    Fuzzers alive : 0
   Dead or remote : 1 (included in stats)
   Total run time : 5 minutes, 0 seconds
      Total execs : 36 thousands
 Cumulative speed : 121 execs/sec
    Pending items : 131 faves, 1185 total
 Coverage reached : 11.10%
    Crashes saved : 0
      Hangs saved : 0

Cycles without finds : 0
Time without finds : 0

[+] Captured 47484 tuples (map size 214235, highest value 255, total values 412070019) in '/dev/null'.
[+] A coverage of 47484 edges were achieved out of 214272 existing (22.16%) with 1195 input files.

@SuperFola SuperFola marked this pull request as draft July 9, 2025 18:49
@SuperFola SuperFola changed the title wip - bad performances Fix potential out of bounds scope allocation Jul 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants