I've noticed that sometimes when the gdb pretty printer calls jank_to_code_string it can return an odd looking string:
Locally, when I update the code to the following I don't have this issue anymore:
diff --git a/compiler+runtime/src/cpp/jank/c_api.cpp b/compiler+runtime/src/cpp/jank/c_api.cpp
index bd0524f74..ea8d28676 100644
--- a/compiler+runtime/src/cpp/jank/c_api.cpp
+++ b/compiler+runtime/src/cpp/jank/c_api.cpp
@@ -927,7 +927,7 @@ extern "C"
char const *jank_to_code_string(jank_object_ref const o)
{
object_ref const o_obj(reinterpret_cast<object *>(o));
- return o_obj.to_code_string().c_str();
+ return GC_strdup(o_obj.to_code_string().c_str());
}
static i64 to_integer_or_hash(object_ref const o)
Is there some subtle memory / ownership issue I am not understanding here? Should the pretty printer be wrapping the calls to jank_to_code_string with GC_strdup?
I've noticed that sometimes when the gdb pretty printer calls
jank_to_code_stringit can return an odd looking string:Locally, when I update the code to the following I don't have this issue anymore:
Is there some subtle memory / ownership issue I am not understanding here? Should the pretty printer be wrapping the calls to jank_to_code_string with GC_strdup?