void HwasanAllocatorInit() { atomic_store_relaxed(&hwasan_allocator_tagging_enabled, !flags()->disable_allocator_tagging); SetAllocatorMayReturnNull(common_flags()->allocator_may_return_null); allocator.Init(common_flags()->allocator_release_to_os_interval_ms); switch (flags()->malloc_align_right) { case 0: break; case 1: right_align_mode = kRightAlignSometimes; right_align_8 = false; break; case 2: right_align_mode = kRightAlignAlways; right_align_8 = false; break; case 8: right_align_mode = kRightAlignSometimes; right_align_8 = true; break; case 9: right_align_mode = kRightAlignAlways; right_align_8 = true; break; default: Report("ERROR: unsupported value of malloc_align_right flag: %d\n", flags()->malloc_align_right); Die(); } for (uptr i = 0; i < kShadowAlignment; i++) tail_magic[i] = GetCurrentThread()->GenerateRandomTag(); }
static void initializeFlags() { // Once we add our own flags we'll parse them here. // For now the common ones are sufficient. FlagParser Parser; SetCommonFlagsDefaults(); RegisterCommonFlags(&Parser); Parser.ParseString(GetEnv(EsanOptsEnv)); InitializeCommonFlags(); if (Verbosity()) ReportUnrecognizedFlags(); if (common_flags()->help) Parser.PrintFlagDescriptions(); __sanitizer_set_report_path(common_flags()->log_path); }
static void initInternal() { SanitizerToolName = "Scudo"; CHECK(!ScudoInitIsRunning && "Scudo init calls itself!"); ScudoInitIsRunning = true; initFlags(); AllocatorOptions Options; Options.setFrom(getFlags(), common_flags()); initAllocator(Options); ScudoInitIsRunning = false; }
static PyObject *perf_trace_context_common_flags(PyObject *self, PyObject *args) { static struct scripting_context *scripting_context; PyObject *context; int retval; if (!PyArg_ParseTuple(args, "O", &context)) return NULL; scripting_context = PyCObject_AsVoidPtr(context); retval = common_flags(scripting_context); return Py_BuildValue("i", retval); }
void initFlags() { SetCommonFlagsDefaults(); { CommonFlags cf; cf.CopyFrom(*common_flags()); cf.exitcode = 1; OverrideCommonFlags(cf); } Flags *f = getFlags(); f->setDefaults(); FlagParser scudo_parser; RegisterScudoFlags(&scudo_parser, f); RegisterCommonFlags(&scudo_parser); scudo_parser.ParseString(GetEnv("SCUDO_OPTIONS")); InitializeCommonFlags(); // Sanity checks and default settings for the Quarantine parameters. if (f->QuarantineSizeMb < 0) { const int DefaultQuarantineSizeMb = 64; f->QuarantineSizeMb = DefaultQuarantineSizeMb; } // We enforce an upper limit for the quarantine size of 4Gb. if (f->QuarantineSizeMb > (4 * 1024)) { dieWithMessage("ERROR: the quarantine size is too large\n"); } if (f->ThreadLocalQuarantineSizeKb < 0) { const int DefaultThreadLocalQuarantineSizeKb = 1024; f->ThreadLocalQuarantineSizeKb = DefaultThreadLocalQuarantineSizeKb; } // And an upper limit of 128Mb for the thread quarantine cache. if (f->ThreadLocalQuarantineSizeKb > (128 * 1024)) { dieWithMessage("ERROR: the per thread quarantine cache size is too " "large\n"); } }
void NORETURN Die() { if (common_flags()->abort_on_error) Abort(); internal__exit(common_flags()->exitcode); }