lingua-franca icon indicating copy to clipboard operation
lingua-franca copied to clipboard

C target with docker property produces no output

Open elgeeko1 opened this issue 1 year ago • 3 comments

When building an LF application for the C target with the docker property enabled, programs which contain a timer do not produce output when run.

target C {
    docker: true
}

main reactor {
    timer t(0, 1s);
    reaction(t) {=
        printf("tick\n");
    =}
}

Expected output: "tick" every 1s

Actual result: Only output produced:

---- System clock resolution: 1 nsec

The program is running (verified by publishing heartbeat messages to InfluxDB), but output is not visible.

When removing docker = true this works as expected. Similarly the Python target with timers also works.

Workaround Add --tty to the docker run command, or tty: true to the docker-compose file.

Suggested fix Add tty: true to the docker compose file.

elgeeko1 avatar Jun 27 '24 22:06 elgeeko1

I assume that this happened because

  • unlike our tests, this program does not terminate, so there isn't an obvious time to flush buffers
  • the volume of output produced is very small (5 chars/second), so some buffer never becomes full.

I think that both of these conditions need to hold in order for this problem to be observed. Therefore, this problem could be less likely to surface in a typical program than one might guess based on the simplicity of this misbehaving example.

petervdonovan avatar Jun 27 '24 22:06 petervdonovan

The proposed fix makes sense to me. @petervdonovan Do you see any reason not to add tty: true?

cmnrd avatar Jun 28 '24 13:06 cmnrd

I can push a fix for this today.

lhstrh avatar Jun 28 '24 14:06 lhstrh

@petervdonovan this really tripped up Erling, since many of the federates in the AVP demo only output that they started and have no other console output. He couldn't tell they were running. If just one error is produced, it may not appear.

elgeeko1 avatar Jul 02 '24 20:07 elgeeko1