{"record":{"id":"3888f1c53b866cc7","repo":"go-delve/delve","slug":"number-of-loaded-libraries-exceeds-maximum","errorCode":null,"errorMessage":"number of loaded libraries exceeds maximum","messagePattern":"number of loaded libraries exceeds maximum","errorType":"error_code","errorClass":"ErrTooManyLibraries","httpStatus":null,"severity":"error","filePath":"pkg/proc/linutil/dynamic.go","lineNumber":20,"sourceCode":"\nimport (\n\t\"bytes\"\n\t\"debug/elf\"\n\t\"encoding/binary\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\n\t\"github.com/go-delve/delve/pkg/proc\"\n)\n\nconst (\n\tmaxNumLibraries      = 1000000 // maximum number of loaded libraries, to avoid loading forever on corrupted memory\n\tmaxLibraryPathLength = 1000000 // maximum length for the path of a library, to avoid loading forever on corrupted memory\n)\n\nvar ErrTooManyLibraries = errors.New(\"number of loaded libraries exceeds maximum\")\n\nconst (\n\t_DT_NULL  = 0  // DT_NULL as defined by SysV ABI specification\n\t_DT_DEBUG = 21 // DT_DEBUG as defined by SysV ABI specification\n)\n\n// readUintRaw reads an integer of ptrSize bytes, with the specified byte order, from reader.\nfunc readUintRaw(reader io.Reader, order binary.ByteOrder, ptrSize int) (uint64, error) {\n\tswitch ptrSize {\n\tcase 4:\n\t\tvar n uint32\n\t\tif err := binary.Read(reader, order, &n); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\treturn uint64(n), nil\n\tcase 8:\n\t\tvar n uint64\n\t\tif err := binary.Read(reader, order, &n); err != nil {","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/linutil/dynamic.go#L2-L38","documentation":"ErrTooManyLibraries is returned by ElfUpdateSharedObjects when walking the dynamic linker's link_map list for a running process discovers more than maxNumLibraries (1,000,000) entries. The list walk terminates to avoid an infinite loop, which almost always means the link_map pointers read from the target's memory are corrupt or garbage rather than a real library count.","triggerScenarios":"Attaching to a process whose r_debug/link_map structures are unreadable or corrupted; reading memory from a wrong address (wrong debug pointer); calling ElfUpdateSharedObjects during binary info load when the dynamic section's DT_DEBUG entry points at invalid memory.","commonSituations":"Debugging stripped or partially-linked binaries; attaching to processes during early startup before the dynamic loader initialized r_debug; corrupted memory reads from a crashed or foreign-arch core/process; cgo binaries with unusual loaders.","solutions":["Retry after the process has finished dynamic loading (break at a later point than process entry)","Verify you are debugging a matching architecture binary (no cross-arch attach)","Inspect _DT_DEBUG/link_map reads: ensure memory reads of the target succeed and the binary has a valid dynamic section","If analyzing a core dump, confirm it was produced from the same binary/build"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// sanity check before walking link_map\nif rdebug == 0 || rdebug > 0x7fffffffffff { return ErrInvalidDebugPointer }","typeGuard":null,"tryCatchPattern":"if err := bi.ElfsUpdated(...); err != nil {\n    if errors.Is(err, linutil.ErrTooManyLibraries) {\n        // defer library rescan to next stop instead of failing\n        return retryAfterNextStop()\n    }\n    return err\n}","preventionTips":["Attach after the runtime has initialized (not at _rt0 entry) when scanning libraries","Verify architecture and word-size match between delve and target","Validate memory reads succeeded before trusting link_map pointers","Watch for corrupted processes; treat this error as a sign of memory corruption"],"tags":["linux","elf","shared-libraries","dynamic-loader"],"backgroundTag":"corrupt-link-map","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}