Mojira Archive
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

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

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

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

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

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

In this case, the results are 0 and 2.

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

Awaiting Response

intsuc

2021-08-31, 07:53 PM

2024-07-26, 02:06 AM

2024-07-26, 02:06 AM

2

4

Confirmed

(Unassigned)

1.17.1, 21w37a

-