dotnet/runtime · warning
Warning: Could not open bridge dump file `%s` for writing: %
Error message
Warning: Could not open bridge dump file `%s` for writing: %s\n
What it means
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.
Source
Thrown at src/mono/mono/metadata/sgen-new-bridge.c:598
#endif
static void
dump_graph (void)
{
static int counter = 0;
MonoObject *obj;
HashEntry *entry;
size_t prefix_len = strlen (dump_prefix);
char *filename = g_newa (char, prefix_len + 64);
FILE *file;
int edge_id = 0;
sprintf (filename, "%s.%d.gexf", dump_prefix, counter++);
file = fopen (filename, "w");
if (file == NULL) {
fprintf (stderr, "Warning: Could not open bridge dump file `%s` for writing: %s\n", filename, strerror (errno));
return;
}
fprintf (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");
fprintf (file, "<graph defaultedgetype=\"directed\">\n"
"<attributes class=\"node\">\n"
"<attribute id=\"0\" title=\"class\" type=\"string\"/>\n"
"<attribute id=\"1\" title=\"bridge\" type=\"boolean\"/>\n"
"</attributes>\n");
fprintf (file, "<nodes>\n");
SGEN_HASH_TABLE_FOREACH (&hash_table, MonoObject *, obj, HashEntry *, entry) {
MonoVTable *vt = SGEN_LOAD_VTABLE (obj);
fprintf (file, "<node id=\"%p\"><attvalues><attvalue for=\"0\" value=\"%s.%s\"/><attvalue for=\"1\" value=\"%s\"/></attvalues></node>\n",
obj, m_class_get_name_space (vt->klass), m_class_get_name (vt->klass), entry->is_bridge ? "true" : "false");
} SGEN_HASH_TABLE_FOREACH_END;
fprintf (file, "</nodes>\n");View on GitHub (pinned to 60108ba66e)
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
Example fix
# before export MONO_GC_DEBUG=bridge-dump=/var/log/bridge/dump # warning: dir missing # after mkdir -p /var/log/bridge export MONO_GC_DEBUG=bridge-dump=/var/log/bridge/dump
Defensive patterns
Strategy: validation
Validate before calling
// Validate the bridge-dump prefix is writable BEFORE enabling bridge dumps.
// Run this before the runtime writes its first bridge cycle.
#include <glib.h>
#include <sys/stat.h>
#include <errno.h>
#include <string.h>
gboolean bridge_dump_prefix_ok (const char *prefix) {
gchar *dir = g_path_get_dirname (prefix);
gboolean ok = g_file_test (dir, G_FILE_TEST_IS_DIR) && access (dir, W_OK) == 0;
if (!ok)
g_printerr ("bridge-dump dir '%s' not writable: %s\n", dir, strerror (errno));
g_free (dir);
return ok;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Precise stack mark not supported - disabling.\n
- max-heap-size must be at least %dMb.\n
- max-heap-size must be an integer.\n
- icall symbol maps not enabled, pass --enable-icall-symbol-ma
- Unrecognized asset behavior:${asset.behavior}, for asset ${a
AI-assisted analysis of dotnet/runtime@60108ba66e (2026-08-10).
Data as JSON: /api/errors/4e99e995e42ca3dc.
Report an issue: GitHub.