[vim/vim] Fix hang when to string of object with recursive references. (PR #15082)

41 views
Skip to first unread message

errael

unread,
Jun 22, 2024, 7:16:03 PM (10 days ago) Jun 22
to vim/vim, Subscribed

And add a hang test and a compare test (they look very similar).
There's a significant whitespace difference in vim9class.c.

Similar to object equals issue. object2string was called directly from
echo_string_core. Patterned this change from dict_tv2string usage.

@LemonBoy @yegappan object_tv2string is getting numbuf, echo_style,
composite_val, unlike dict_tv2string. That keeps the arguments to
object2string unchanged. Also in object_tv2string I didn't think the case

else if (copyID != 0 && obj->obj_copyID == copyID

would be doing anything, but now the failing case outputs

object of C {nest1: object of C {...}, nest2: object of
    C {nest1: object of C {...}, nest2: object of C {...}}}

This case was that last thing implemented.

If the case is commented out, then the test outputs

E724: Variable nested too deep for displaying

which is the situation that caused the hang.

(2nd crash in two days, might be a record for me :) )


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/15082

Commit Summary

  • 5e4b50a Fix hang when to string of object object with recursive references.

File Changes

(3 files)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15082@github.com>

errael

unread,
Jun 23, 2024, 6:23:08 AM (10 days ago) Jun 23
to vim/vim, Push

@errael pushed 1 commit.

  • ec83a9b Fix hang of string(object) when object has recursive references.


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15082/before/5e4b50a4049dec3d9196aac8d966ab2f19781dfe/after/ec83a9b8b97ae3999e42d4928def528801be9e95@github.com>

errael

unread,
Jun 23, 2024, 6:32:55 AM (10 days ago) Jun 23
to vim/vim, Subscribed

Rebased, last vim crash I know of

@chrisbra @yegappan @LemonBoy Hope someone can take a look and get this merged.

Can do side by side comparisons of

object_tv2string dict_tv2string
   object2string dict2string


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15082/c2184936611@github.com>

Christian Brabandt

unread,
Jun 23, 2024, 10:56:21 AM (10 days ago) Jun 23
to vim/vim, Subscribed

Thanks. @yegappan are you fine with this?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15082/c2185021724@github.com>

Yegappan Lakshmanan

unread,
Jun 24, 2024, 10:21:21 AM (9 days ago) Jun 24
to vim/vim, Subscribed

@yegappan commented on this pull request.


In src/vim9class.c:

>  	    }
-	    ga_concat(&ga, (char_u *)"}");
+	    line_breakcheck();

Why is the line_breakcheck() needed here? This may process other pending events that may change the value that is displayed here.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15082/review/2135959542@github.com>

errael

unread,
Jun 24, 2024, 11:23:39 AM (9 days ago) Jun 24
to vim/vim, Subscribed

@errael commented on this pull request.


In src/vim9class.c:

>  	    }
-	    ga_concat(&ga, (char_u *)"}");
+	    line_breakcheck();

Look at a side by side of this function, object2string with dict2string, that's why it is there. In fact, when doing my last check before opening the PR, I put this in, without knowing exactly why it's there.

I'm happy to take it out, LMK.

@yegappan Another thing I was unsure of, in dict_tv2string there is

    else if (copyID != 0 && tv->vval.v_dict->dv_copyID == copyID
	    && tv->vval.v_dict->dv_hashtab.ht_used != 0)

which I converted as

    else if (copyID != 0 && obj->obj_copyID == copyID
            && obj->obj_refcount != 0)

But I think the check against refcount is bogus and can/should just be taken out. Do you agree?


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15082/review/2136118081@github.com>

errael

unread,
Jun 24, 2024, 11:59:48 AM (9 days ago) Jun 24
to vim/vim, Subscribed

@errael commented on this pull request.


In src/vim9class.c:

>  	    }
-	    ga_concat(&ga, (char_u *)"}");
+	    line_breakcheck();

Ahh, instead if that bogus refcount check, the following is probably the equivalent check

    else if (copyID != 0 && obj->obj_copyID == copyID
            && obj->obj_class->class_obj_member_count != 0)


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15082/review/2136202807@github.com>

errael

unread,
Jun 24, 2024, 12:23:38 PM (9 days ago) Jun 24
to vim/vim, Subscribed

BTW, when the bug this issue addresses is encountered, a force kill is required. I'm guess that is because there some kind of nested signal handling going on, IDK.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15082/c2186955474@github.com>

errael

unread,
Jun 25, 2024, 10:10:37 AM (8 days ago) Jun 25
to vim/vim, Push

@errael pushed 1 commit.

  • b224770 Fix hang of string(object) when object has recursive references.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15082/before/ec83a9b8b97ae3999e42d4928def528801be9e95/after/b2247701d2f022b74cca35839144330decaa5fef@github.com>

errael

unread,
Jun 25, 2024, 10:14:58 AM (8 days ago) Jun 25
to vim/vim, Subscribed

@yegappan Changed && obj->obj_refcount != 0 to && obj->obj_class->class_obj_member_count != 0 as discussed above.

Any further comment about line_breakcheck()?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15082/c2189080392@github.com>

Yegappan Lakshmanan

unread,
Jun 26, 2024, 10:26:12 AM (7 days ago) Jun 26
to vim/vim, Subscribed

@yegappan commented on this pull request.


In src/vim9class.c:

>  	    }
-	    ga_concat(&ga, (char_u *)"}");
+	    line_breakcheck();

Yes. The check for obj->obj_class->class_obj_member_count is the correct check.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15082/review/2142052434@github.com>

Yegappan Lakshmanan

unread,
Jun 26, 2024, 10:27:14 AM (7 days ago) Jun 26
to vim/vim, Subscribed

@yegappan Changed && obj->obj_refcount != 0 to && obj->obj_class->class_obj_member_count != 0 as discussed above.

Any further comment about line_breakcheck()?

We can keep the line_breakcheck() call to be consistent with dict2string().


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15082/c2191852155@github.com>

Yegappan Lakshmanan

unread,
Jun 26, 2024, 10:27:33 AM (7 days ago) Jun 26
to vim/vim, Subscribed

@yegappan approved this pull request.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15082/review/2142056181@github.com>

errael

unread,
Jul 2, 2024, 6:53:15 PM (6 hours ago) Jul 2
to vim/vim, Subscribed

Rebased, only docs have changed.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15082/c2204615965@github.com>

Reply all
Reply to author
Forward
0 new messages