mojira.dev
MC-235674

Debug traces have ambiguity due to raw messages

The bug

Debug trace files generated by /debug function <name> print a command message started with [M] and an error message started with [E] as-is. Since debug traces have syntax with offside rule, which depends on indentation or line breaks, printing these messages as-is can break their syntax.

For example, an mcfunction mc-235674:test-1 with the following content

data get storage mc-235674: text
data get storage mc-235674: text

can produce the following debug trace

mc-235674:test-1
    [C] data get storage mc-235674: text
        [M] Storage mc-235674: has the following contents: "
    [R = 0] data get storage mc-235674: text
"
    [R = 46] data get storage mc-235674: text
mc-235674:test-1
    [C] data get storage mc-235674: text
        [M] Storage mc-235674: has the following contents: "
    [R = 0] data get storage mc-235674: text
"
    [R = 46] data get storage mc-235674: text

As you can see, the text tag has line breaks and disguises itself as if it were the correct output. A naïve parser would mistake the result for [R = 0], or treat it as invalid debug trace.

For another example, let's assume a command foo. Debug-tracing the following function mc-235674:test-2

foo
foo
foo
foo

can produce the following output

mc-235674:test-2
    [C] foo
        [M] foo
    [R = 0] foo
    [C] foo
        [M] foo
    [R = 1] foo
    [C] foo
        [M] foo
    [R = 2] foo
mc-235674:test-2
    [C] foo
        [M] foo
    [R = 0] foo
    [C] foo
        [M] foo
    [R = 1] foo
    [C] foo
        [M] foo
    [R = 2] foo

Since technically the message of the command can be arbitrary string, we can interpret the output in two ways.

One interpretation is as follows:

mc-235674:test-2
    [C] foo
        [M] foo
    [R = 0] foo
    [C] foo
        [M] foo
    [R = 1] foo
    [C] foo
        [M] foo
    [R = 2] foo
mc-235674:test-2
    [C] foo
        [M] foo
    [R = 0] foo
    [C] foo
        [M] foo
    [R = 1] foo
    [C] foo
        [M] foo
    [R = 2] foo

where the section enclosed in ⟦⟧ is the message of the foo. In this case, the results are 1 and 2.
The other interpretation is as follows:

mc-235674:test-2
    [C] foo
        [M] foo
    [R = 0] foo
    [C] foo
        [M] foo
    [R = 1] foo
    [C] foo
        [M] foo
    [R = 2] foo
mc-235674:test-2
    [C] foo
        [M] foo
    [R = 0] foo
    [C] foo
        [M] foo
    [R = 1] foo
    [C] foo
        [M] foo
    [R = 2] foo

In this case, the results are 0 and 2.

This means that we cannot inspect debug traces unambiguously, without knowledge of the internal implementation.

Comments 1

We do not have enough information to reproduce this issue.

Please include the following information to help us understand your problem:

Steps to Reproduce:
1. (Explain what needs to be done for the issue to happen)
2.
3.

Observed Results:
(Briefly describe what happens)

Expected Results:
(Briefly describe what should happen)

Please also attach any needed commands, datapacks, resourcepacks, screenshots, videos, or worlds needed to help reproduce this issue.

Refer to the Bug Tracker Guidelines for more information about how to write helpful bug reports. Bug reports with insufficient information may be closed as Incomplete.

This issue is being temporarily resolved as Awaiting Response. Once the requested information has been delivered, the report will be reopened automatically.

Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support (Technical Issues) – 📧 Microsoft Support (Account Issues)
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki

intsuc

(Unassigned)

Confirmed

(Unassigned)

1.17.1, 21w37a

Retrieved