Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"curl -h" truncated #5547

Closed
gvanem opened this issue Jun 9, 2020 · 6 comments
Closed

"curl -h" truncated #5547

gvanem opened this issue Jun 9, 2020 · 6 comments
Labels

Comments

@gvanem
Copy link
Contributor

gvanem commented Jun 9, 2020

I've just noticed that a simple curl -h | most (or more, less or > file) stops listing the
help after the line --tls13-ciphers <ciphersuite list> TLS 1.3 c (line 211).
Not the full 233 lines it should be.

I've always thought that the CRT will register an atexit() handler to flush standard buffers when exit() is called. But the MSVC runtime seems not.

Adding a fflush(stdout); at the end of `` tool_help()` fixes it.

I'm on Win-10 using MSVC 2019 (v19.26.28806 for x86). Compiled using -MD.

@jay jay added cmdline tool Windows Windows-specific labels Jun 9, 2020
@jay
Copy link
Member

jay commented Jun 9, 2020

That's weird, how exactly did you build it?

@gvanem
Copy link
Contributor Author

gvanem commented Jun 9, 2020

Weird, yes. I built using a home-brew Makefile. It's been working for years.
But some recent change somewhere has broken this particular issue.

@jay jay added the build label Jun 10, 2020
@jay
Copy link
Member

jay commented Jun 10, 2020

We're going to need more than that. Can you reproduce using any of the regular build methods?

@gvanem
Copy link
Contributor Author

gvanem commented Jun 10, 2020

I've tried to use the official winbuild/Makefile.vc to reproduce, but failed (probably since my setup involves a lot more options and external libraries). But I see that fflush() is called on most streams, but not for stdout when only e.g. curl -h | less is used.

I looked around and found this advice on why it's good practice to
fflush(stdout). A fclose(stdout) at the end of tool_help.c also prevent a truncated output.

And when building with cl -MT, the auto-flushing of stdout is more irregular. It seems there is a 12kByte buffer inside the libcmt.lib. This makes sense since the above --tls13-ciphers <ciphersuite list> TLS 1.3 c is roughly at the 12 kByte mark.

@jay
Copy link
Member

jay commented Jun 10, 2020

The streams are supposed to be flushed when they are closed. I don't know why that is not happening. Possibly you are using dual CRTs, one for libcurl and one for curl, and there is some sort of disconnect there, but if that's the case I think it's a Microsoft issue not a curl issue.

@gvanem
Copy link
Contributor Author

gvanem commented Sep 7, 2020

This is no longer a problem. Probably all the changes in #5680 that solved it.
So I'm closing this now.

@gvanem gvanem closed this as completed Sep 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants