Skip to content

gdb pretty print issue #879

Description

@djblue

I've noticed that sometimes when the gdb pretty printer calls jank_to_code_string it can return an odd looking string:

Image

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)
Image

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions