{"record":{"id":"4e99e995e42ca3dc","repo":"dotnet/runtime","slug":"warning-could-not-open-bridge-dump-file-s-for","errorCode":null,"errorMessage":"Warning: Could not open bridge dump file `%s` for writing: %s\\n","messagePattern":"Warning: Could not open bridge dump file `(.+?)` for writing: (.+?)\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/mono/mono/metadata/sgen-new-bridge.c","lineNumber":598,"sourceCode":"#endif\n\nstatic void\ndump_graph (void)\n{\n\tstatic int counter = 0;\n\n\tMonoObject *obj;\n\tHashEntry *entry;\n\tsize_t prefix_len = strlen (dump_prefix);\n\tchar *filename = g_newa (char, prefix_len + 64);\n\tFILE *file;\n\tint edge_id = 0;\n\n\tsprintf (filename, \"%s.%d.gexf\", dump_prefix, counter++);\n\tfile = fopen (filename, \"w\");\n\n\tif (file == NULL) {\n\t\tfprintf (stderr, \"Warning: Could not open bridge dump file `%s` for writing: %s\\n\", filename, strerror (errno));\n\t\treturn;\n\t}\n\n\tfprintf (file, \"<gexf xmlns=\\\"http://www.gexf.net/1.2draft\\\" xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" xsi:schemaLocation=\\\"http://www.gexf.net/1.2draft http://www.gexf.net/1.2draft/gexf.xsd\\\" version=\\\"1.2\\\">\\n\");\n\n\tfprintf (file, \"<graph defaultedgetype=\\\"directed\\\">\\n\"\n\t\t\t\"<attributes class=\\\"node\\\">\\n\"\n\t\t\t\"<attribute id=\\\"0\\\" title=\\\"class\\\" type=\\\"string\\\"/>\\n\"\n\t\t\t\"<attribute id=\\\"1\\\" title=\\\"bridge\\\" type=\\\"boolean\\\"/>\\n\"\n\t\t\t\"</attributes>\\n\");\n\n\tfprintf (file, \"<nodes>\\n\");\n\tSGEN_HASH_TABLE_FOREACH (&hash_table, MonoObject *, obj, HashEntry *, entry) {\n\t\tMonoVTable *vt = SGEN_LOAD_VTABLE (obj);\n\t\tfprintf (file, \"<node id=\\\"%p\\\"><attvalues><attvalue for=\\\"0\\\" value=\\\"%s.%s\\\"/><attvalue for=\\\"1\\\" value=\\\"%s\\\"/></attvalues></node>\\n\",\n\t\t\t obj, m_class_get_name_space (vt->klass), m_class_get_name (vt->klass), entry->is_bridge ? \"true\" : \"false\");\n\t} SGEN_HASH_TABLE_FOREACH_END;\n\tfprintf (file, \"</nodes>\\n\");","sourceCodeStart":580,"sourceCodeEnd":616,"githubUrl":"https://github.com/dotnet/runtime/blob/60108ba66eb7d1d12f595480091b4ad80a24b172/src/mono/mono/metadata/sgen-new-bridge.c#L580-L616","documentation":"In dump_graph (sgen-new-bridge.c), when a bridge dump prefix is set, SGen writes the object graph of each bridge cycle to <prefix>.<counter>.gexf. If fopen(filename, \"w\") fails it logs this warning with the filename and strerror(errno) then returns, skipping that dump; the collection and bridge processing continue unaffected. The prefix is configured via set_dump_prefix, exposed through MONO_GC_DEBUG=bridge-dump=<prefix> (parsed in sgen-bridge.c) or the sgen_bridge_set_dump_prefix API.","triggerScenarios":"Enabling 'bridge-dump=<prefix>' in MONO_GC_DEBUG where the prefix's parent directory does not exist, is not writable by the runtime user, is on a read-only filesystem, or the path is otherwise invalid. The warning recurs on every bridge cycle while the prefix remains set.","commonSituations":"iOS/Android-style bridge debugging where the prefix points to a sandbox/container directory not yet created; running the process as a user without write permission to the prefix path; a typo'd or relative prefix resolved against an unexpected working directory.","solutions":["Create and make writable the parent directory of the prefix: mkdir -p <dir> && chmod u+w <dir>","Use a prefix in a known-writable location such as /tmp/bridge or another temp dir owned by the runtime user","Remove 'bridge-dump=' from MONO_GC_DEBUG if the dumps are not actually needed"],"exampleFix":"# before\nexport MONO_GC_DEBUG=bridge-dump=/var/log/bridge/dump   # warning: dir missing\n\n# after\nmkdir -p /var/log/bridge\nexport MONO_GC_DEBUG=bridge-dump=/var/log/bridge/dump","handlingStrategy":"validation","validationCode":"// Validate the bridge-dump prefix is writable BEFORE enabling bridge dumps.\n// Run this before the runtime writes its first bridge cycle.\n#include <glib.h>\n#include <sys/stat.h>\n#include <errno.h>\n#include <string.h>\ngboolean bridge_dump_prefix_ok (const char *prefix) {\n    gchar *dir = g_path_get_dirname (prefix);\n    gboolean ok = g_file_test (dir, G_FILE_TEST_IS_DIR) && access (dir, W_OK) == 0;\n    if (!ok)\n        g_printerr (\"bridge-dump dir '%s' not writable: %s\\n\", dir, strerror (errno));\n    g_free (dir);\n    return ok;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer an absolute prefix in a temp dir owned by the runtime user (e.g. /tmp/bridge) to avoid CWD/permission surprises","mkdir -p the prefix's parent directory in your launch script before setting MONO_GC_DEBUG","Remember the warning is non-fatal and repeats each bridge cycle, so an unfixable path can flood stderr - disable bridge-dump if you don't need it","On mobile/sandboxed runtimes, confirm the sandbox grants write access to the chosen path before enabling dumps"],"tags":["mono","sgen","bridge-processing","gc","debugging","filesystem","configuration"],"backgroundTag":null,"analyzedSha":"60108ba66eb7d1d12f595480091b4ad80a24b172","analyzedAt":"2026-08-10T18:54:11.478Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}