{"record":{"id":"b1a3a9e6bdbecf7e","repo":"ory/hydra","slug":"memory-v-is-too-large","errorCode":null,"errorMessage":"memory %v is too large","messagePattern":"memory (.+?) is too large","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"oryx/hasherx/hasher_argon2.go","lineNumber":73,"sourceCode":"\t}\n\t// Argon2 is a hasher that uses the Argon2 algorithm.\n\tArgon2 struct {\n\t\tc Argon2Configurator\n\t}\n\t// Argon2Configurator is a function that returns the Argon2 configuration.\n\tArgon2Configurator interface {\n\t\tHasherArgon2Config(ctx context.Context) *Argon2Config\n\t}\n)\n\nfunc NewHasherArgon2(c Argon2Configurator) *Argon2 {\n\treturn &Argon2{c: c}\n}\n\nfunc toKB(mem bytesize.ByteSize) (uint32, error) {\n\tkb := uint64(mem / bytesize.KB)\n\tif kb > math.MaxUint32 {\n\t\treturn 0, errors.Errorf(\"memory %v is too large\", mem)\n\t}\n\treturn uint32(kb), nil\n}\n\n// Generate generates a hash for the given password.\nfunc (h *Argon2) Generate(ctx context.Context, password []byte) (_ []byte, err error) {\n\tctx, span := otel.GetTracerProvider().Tracer(tracingComponent).Start(ctx, \"hash.Argon2.Generate\")\n\tdefer otelx.End(span, &err)\n\tp := h.c.HasherArgon2Config(ctx)\n\tspan.SetAttributes(attribute.String(\"argon2.config\", fmt.Sprintf(\"#%v\", p)))\n\n\tsalt := make([]byte, p.SaltLength)\n\tif _, err := rand.Read(salt); err != nil {\n\t\treturn nil, err\n\t}\n\n\tmem, err := toKB(p.Memory)\n\tif err != nil {","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/ory/hydra/blob/4174065ffb052799890f7480f5360a877a67ffc1/oryx/hasherx/hasher_argon2.go#L55-L91","documentation":"Returned by toKB when the configured Argon2 memory limit, converted to kilobytes, exceeds math.MaxUint32 (i.e. the configured value is ~4TB or more). The Argon2 parameter itself is absurdly large; the configuration value for hasher memory is at fault.","triggerScenarios":"Thrown at oryx/hasherx/hasher_argon2.go:73 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Lower the Argon2 memory configuration to a realistic value (e.g. 64MB–1GB)","Validate the configured memory size at config load time and fail fast with a clear message","Use bytesize units explicitly (e.g. 128MB) to avoid accidental raw-byte magnitudes"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4174065ffb052799890f7480f5360a877a67ffc1","analyzedAt":"2026-09-03T14:52:41.581Z","contentChangedAt":"2026-09-03T14:52:41.581Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}