Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8254807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:18:58+00:00 2026-06-08T01:18:58+00:00

Edit 4 : It turns out that this is actually just a limitation of

  • 0

Edit 4: It turns out that this is actually just a limitation of TTY input in general; there’s nothing specific about OCaml, Coq, or Emacs which is causing the problem.


I’m working on a Coq program using Proof General in Emacs, and I’ve found a bug with input that’s too long. If a region to submit to coqtop through Proof General contains more than 1023 characters, Proof General (though not Emacs) hangs while waiting for a response, and the *coq* buffer contains one extra ^G character for every character over 1023. For instance, if a 1025-character region was sent to coqtop, then the *coq* buffer would end with the two extra characters ^G^G. I can’t proceed past this point in the file, and I have to kill the coqtop process (either with C-c C-x or a kill/killall from the terminal).

Something about this limitation arises from coqtop itself. If one generates a 1024-character or longer string and pipes it in, such as by running

perl -e 'print ("Eval simpl in " . (" " x 1024) . "1.\n")' | coqtop

then everything works fine. (Similarly, coqc works fine as well.) However, if I run coqtop in a terminal, I can’t type more than 1024 characters on one line, including the ending return character. Thus, typing a 1023-character line and then hitting return works; but after typing 1024 characters, hitting any key, including return (but not including delete, etc.), does nothing but produce a beep. And it turns out that ocaml (the OCaml toplevel) has the same behavior:

perl -e 'print ((" " x 1024) . "1;;")' | ocaml

works fine, but I can’t type more than 1024 characters on one line if running ocaml from a terminal. Since my understanding is that coqtop relies on the OCaml toplevel (more obviously when run as coqtop -byte), I imagine this is a related limitation.

The relevant software versions are:

  • OCaml 3.12.1 from Homebrew;
  • Coq 8.3pl3 (and 8.3pl2) from Homebrew;
  • Proof General 4.1;
  • The build of GNU Emacs 24.1.1 from Emacs for Mac OS X; and
  • Mac OS X 10.6.7.

And my questions are:

  • What about ocaml and coqtop is enforcing this character limit? And why only for input from the terminal or Emacs, as opposed to input from a pipe or a file?
  • Why does Proof General’s (apparent) ignorance of this limit cause hanging errors and mysterious ^Gs?
  • How can I work around this limitation? My end goal is to use Coq inside Proof General/Emacs, so workarounds which dodge the underlying issue are fine.

Edit 3: After finding that the 1024-character input limitation also exists in the Ocaml toplevel (something which I imagine is related), I’ve added that information and deleted the original problem description, as it’s been completely obscured and superseded. (See the edit history if necessary).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T01:19:00+00:00Added an answer on June 8, 2026 at 1:19 am

    I reported this as issue 5678 on the OCaml bug tracker, and the user dim explained that this wasn’t a problem with OCaml per se, but was a limitation of TTY input. The issue is this. Since text isn’t sent to running commands until the user hits return, all that waiting input must be stored somewhere. The buffer it’s stored in, called the input queue or the type-ahead buffer, has a fixed size, which is controlled by the C constant MAX_INPUT. This constant is equal to 1024 on Mac OS X. Buffering like this allows useful processing of input, such as deleting characters before they’re sent. All commands run from the terminal which don’t do something special (such as using the readline library) will exhibit this behavior; for example, cat chokes in exactly the same way.

    To avoid this behavior, one can unset the ICANON flag, for instance by running stty -icanon; this puts the TTY into non-canonical input mode, where input is not processed at all before being sent to the command. This means that editing becomes impossible: delete, left and right arrows, and so on all enter their literal equivalents (^?, ^[[D, ^[[C, …); similarly, ⌃D no longer sends an EOF, but merely a literal control character. However, for my particular use case, this (so far!) seems to be ideal, since Emacs is handling all my input for me. (Edit: But there’s a better option!) (Libraries like readline, as I understand it, change this setting as well, but watch for control characters and handle editing, etc., themselves.) To restore canonical mode, one can run stty icanon.

    The ledit tool wraps line editing around the program given to it as an argument, so ledit coqtop works fine (if oddly; I prefer ledit -l 65536 to avoid its scrolling), but interacted oddly with Emacs. The rlwrap tool does the same thing, but leaves the other program reading from a TTY; thus, while it can receive longer inputs, hitting enter and sending them to the wrapped command behaves very strangely and ends up necessitating that the command be killed.

    Edit: In my specific use-case, I can also simply tell Emacs to use a pipe instead of a PTY, solving the problems at a stroke. The Emacs variable process-connection-type controls how subsidiary processes are communicated with; nil means to use a pipe, and non-nil means to use a TTY. Proof General uses the variable proof-shell-process-connection-type to determine how this should be set. Using a pipe solves all the 1024-character-limit problems.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: It turns out that the second edit to my .emacs file actually works.
Edit: Turns out I just had some values -switched-. I'm working with OpenGL and
Solution Edit: Turns out you can't use the PHP SDK to return the correct
Edit: It turns out I missed something obvious, but I'm going to leave the
EDIT: solved it, turns out I should use %c not %s because foodSelect and
Sometimes, VS wont let me do edit and continue, and it turns out it's
EDIT: Note that due to the way hard drives actually write data, none of
EDIT: Just try with something like this: __declspec(dllexport) int foo(int param) {return param*param;} and
SOLVED: As it turns out, my problem was rooted in the fact that I
EDIT 07/14 As Bill Burgess mentionned in a comment of his answer, this question

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.