The following issues were found

torch/csrc/Stream.cpp
1 issues
There is an unknown macro here somewhere. Configuration is required. If HANDLE_TH_ERRORS is a macro then please configure it.
Error

Line: 37

              }

static PyObject * THPStream_get_device(THPStream *self, void *unused) {
  HANDLE_TH_ERRORS
  return THPDevice_New(c10::Stream::unpack(self->cdata).device());
  END_HANDLE_TH_ERRORS
}

static PyObject * THPStream_eq(THPStream *self, THPStream *other) {

            

Reported by Cppcheck.

tools/coverage_plugins_package/setup.py
1 issues
Missing module docstring
Error

Line: 1 Column: 1

              import setuptools  # type: ignore[import]

with open("README.md", "r", encoding="utf-8") as fh:
    long_description = fh.read()

setuptools.setup(
    name="coverage-plugins",
    version="0.0.1",
    author='PyTorch Team',

            

Reported by Pylint.

torch/csrc/jit/frontend/concrete_module_type.cpp
1 issues
equal - Function does not check the second iterator for over-read conditions
Security

Line: 120 Column: 8 CWE codes: 126
Suggestion: This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it

                    forwardHooks_ == other.forwardHooks_ &&
      forwardPreHooks_ == other.forwardPreHooks_;
  // clang-format on
  if (!equal) {
    return false;
  }

  // We store modules in order of insertion (to make compilation
  // deterministic). However, for the purposes of equality, insertion order

            

Reported by FlawFinder.

torch/csrc/jit/codegen/fuser/cpu/temp_file.h
1 issues
wcslen - Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected)
Security

Line: 37 Column: 9 CWE codes: 126

                int fd = -1;
  int save_errno = errno;

  len = wcslen(tmpl);
  if (len < 6 + suffix_len ||
      wcsncmp(&tmpl[len - 6 - suffix_len], L"XXXXXX", 6)) {
    return -1;
  }


            

Reported by FlawFinder.

torch/csrc/QScheme.h
1 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 15 Column: 3 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

                PyObject_HEAD
  at::QScheme qscheme;
  // NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays)
  char name[QSCHEME_NAME_LEN + 1];
};

extern PyTypeObject THPQSchemeType;

inline bool THPQScheme_Check(PyObject *obj) {

            

Reported by FlawFinder.

torch/csrc/jit/codegen/cuda/tools/stringify_file.py
1 issues
Missing module docstring
Error

Line: 1 Column: 1

              
# Generates a C++ header files embedding the original input as a string literal

import argparse
import pathlib
from datetime import datetime

arg_parser = argparse.ArgumentParser(
    description='Converts source files to C++ string literals', allow_abbrev=False)

            

Reported by Pylint.

test/cpp/jit/test_subgraph_utils.cpp
1 issues
syntax error
Error

Line: 51

                }
}

TEST(SubgraphUtilsTest, MergeSubgraphs) {
  auto graph = std::make_shared<Graph>();
  std::unordered_map<std::string, Value*> parse_map;
  parseIR(
      R"IR(
graph(%a : Tensor, %b : Tensor, %c : Tensor):

            

Reported by Cppcheck.

test/cpp/jit/test_subgraph_rewriter.cpp
1 issues
syntax error
Error

Line: 12

              namespace jit {
using namespace testing;

TEST(SubgraphRewriterTest, FilterMatch) {
  auto graph = std::make_shared<Graph>();

  parseIR(
      R"IR(
graph(%0):

            

Reported by Cppcheck.

test/cpp/jit/test_subgraph_matcher.cpp
1 issues
syntax error
Error

Line: 26

                AT_ASSERT(!findPatternMatches(pattern, graph).empty());
}

TEST(SubgraphMatcherTest, Trivial2) {
  Graph graph;
  auto* g_in = graph.addInput();
  auto* g_tanh = graph.insertNode(graph.create(aten::tanh, /*num_outputs =*/1));
  g_tanh->addInput(g_in);
  graph.registerOutput(g_tanh->output());

            

Reported by Cppcheck.

test/cpp/jit/test_script_profile.cpp
1 issues
syntax error
Error

Line: 52

                EXPECT_EQ(stat.count, 3);
}

TEST(ScriptProfileTest, CallingOrder) {
  ScriptProfile p;
  p.enable();
  EXPECT_THROW(p.dumpStats(), c10::Error);
  p.disable();
  auto dp = std::make_shared<profiling::Datapoint>(SourceRange{});

            

Reported by Cppcheck.