{"record":{"id":"0cf1e0ffa274fee8","repo":"dotnet/runtime","slug":"precise-stack-mark-not-supported-disabling-n","errorCode":null,"errorMessage":"Precise stack mark not supported - disabling.\\n","messagePattern":"Precise stack mark not supported - disabling\\.\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/mono/mono/metadata/sgen-mono.c","lineNumber":2128,"sourceCode":"\t\t\t\t */\n\t\t\t\tHandleStack *stack = info->client_info.info.handle_stack;\n\t\t\t\tg_assert (stack == NULL || mono_handle_stack_is_empty (stack));\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tg_assert (info->client_info.stack_start);\n\t\tg_assert (info->client_info.info.stack_end);\n\n\t\taligned_stack_start = get_aligned_stack_start (info);\n\t\tg_assert (info->client_info.suspend_done);\n\t\tif (!debug_coop_no_stack_scan) {\n\t\t\tSGEN_LOG (3, \"Scanning thread %p, range: %p-%p, size: %\" G_GSIZE_FORMAT \"d, pinned=%\" G_GSIZE_FORMAT \"d\", info, info->client_info.stack_start, info->client_info.info.stack_end, (char*)info->client_info.info.stack_end - (char*)info->client_info.stack_start, sgen_get_pinned_count ());\n\t\t\tif (mono_gc_get_gc_callbacks ()->thread_mark_func && !conservative_stack_mark) {\n\t\t\t\tmono_gc_get_gc_callbacks ()->thread_mark_func (info->client_info.runtime_data, (guint8 *)aligned_stack_start, (guint8 *)info->client_info.info.stack_end, precise, &ctx);\n\t\t\t} else if (!precise) {\n\t\t\t\tif (!conservative_stack_mark) {\n\t\t\t\t\tfprintf (stderr, \"Precise stack mark not supported - disabling.\\n\");\n\t\t\t\t\tconservative_stack_mark = TRUE;\n\t\t\t\t}\n\t\t\t\t//FIXME we should eventually use the new stack_mark from coop\n\t\t\t\tsgen_conservatively_pin_objects_from ((void **)aligned_stack_start, (void **)info->client_info.info.stack_end, start_nursery, end_nursery, PIN_TYPE_STACK);\n\t\t\t}\n\n\t\t\tif (!precise) {\n\t\t\t\tsgen_conservatively_pin_objects_from ((void**)&info->client_info.ctx, (void**)(&info->client_info.ctx + 1),\n\t\t\t\t\tstart_nursery, end_nursery, PIN_TYPE_STACK);\n\n\t\t\t\t{\n\t\t\t\t\t// This is used on Coop GC for platforms where we cannot get the data for individual registers.\n\t\t\t\t\t// We force a spill of all registers into the stack and pass a chunk of data into sgen.\n\t\t\t\t\t//FIXME under coop, for now, what we need to ensure is that we scan any extra memory from info->client_info.info.stack_end to stack_mark\n\t\t\t\t\tMonoThreadUnwindState *state = &info->client_info.info.thread_saved_state [SELF_SUSPEND_STATE_INDEX];\n\t\t\t\t\tif (state && state->gc_stackdata) {\n\t\t\t\t\t\tsgen_conservatively_pin_objects_from ((void **)state->gc_stackdata, (void**)((char*)state->gc_stackdata + state->gc_stackdata_size),\n\t\t\t\t\t\t\tstart_nursery, end_nursery, PIN_TYPE_STACK);","sourceCodeStart":2110,"sourceCodeEnd":2146,"githubUrl":"https://github.com/dotnet/runtime/blob/60108ba66eb7d1d12f595480091b4ad80a24b172/src/mono/mono/metadata/sgen-mono.c#L2110-L2146","documentation":"During SGen's thread scan (sgen_client_scan_thread_data), a precise stack mark requires mono_gc_get_gc_callbacks()->thread_mark_func to be registered. When a thread is on the imprecise pass, precise marking was requested, but no thread_mark_func exists, SGen logs this once, sets the static conservative_stack_mark flag to TRUE, and pins the thread stack conservatively. Note sgen_client_init already defaults conservative_stack_mark=TRUE with the comment 'Precise marking is broken on all supported targets. Disable until fixed.', so this message only appears when precise is explicitly requested and unsupported.","triggerScenarios":"Setting MONO_GC_PARAMS=stack-mark=precise on a runtime or platform that does not register a GC thread_mark_func (i.e. without the cooperative GC's thread-mark callback). Emitted at most once per process because it flips the global conservative_stack_mark flag on first occurrence.","commonSituations":"Opting into precise stack marking to reduce false pinning on a platform where it isn't implemented; embedding Mono in a custom host that does not install the GC thread-mark callback; running on an older/newer runtime whose platform support for precise marking changed.","solutions":["Remove 'stack-mark=precise' from MONO_GC_PARAMS and rely on the default conservative marking","Use a runtime/platform build that registers thread_mark_func (a cooperative-GC-enabled build) if precise marking is required","Treat the message as informational: GC correctness is preserved via the automatic conservative fallback, only precision/pinning behavior changes"],"exampleFix":"# before\nexport MONO_GC_PARAMS=stack-mark=precise\n\n# after\n# omit the option; default conservative stack marking is used\nexport MONO_GC_PARAMS=","handlingStrategy":"fallback","validationCode":"// After the runtime is initialized, query whether precise marking actually took effect.\n// mono_gc_precise_stack_mark_enabled() returns !conservative_stack_mark (gc-internals.h:363).\n#include <mono/metadata/mono-gc.h>\ngboolean want_precise = g_getenv (\"MONO_GC_PARAMS\") != NULL; // your own logic\nif (want_precise && !mono_gc_precise_stack_mark_enabled ()) {\n    g_print (\"Precise stack marking is not available on this platform/runtime; \"\n             \"GC will run in conservative mode.\\n\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Don't set 'stack-mark=precise' unless you have confirmed the platform/runtime registers a GC thread_mark_func","After init, call mono_gc_precise_stack_mark_enabled() to verify the requested mode actually engaged rather than trusting the env var","Treat the message as benign: GC correctness is unaffected; only the amount of conservative pinning changes","When embedding Mono, install the cooperative-GC thread-mark callback if you need precise marking instead of relying on the env var alone"],"tags":["mono","sgen","gc","stack-marking","configuration","environment-variable"],"backgroundTag":null,"analyzedSha":"60108ba66eb7d1d12f595480091b4ad80a24b172","analyzedAt":"2026-08-10T18:54:11.478Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}