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

Disable readline if stdin is not attached to a terminal #4495

Merged
merged 1 commit into from
Jun 1, 2021

Conversation

fingolfin
Copy link
Member

This PR should fix #4466 and I hope @hulpke can verify that. It is not an alternative to PR #4494 (which also fixes that issue) but rather complements it: IMHO this PR here fixes the "real" issue; but that's debatable. In any case, ideally both would be merged.

I hope nobody is doing weird stuff that involves piping text into GAP (such that stdin is not a terminal) while also requiring GNU readline support to be enabled. Indeed, things like the pexpect interface by SageMath most likely would want to disable readline support anyway (perhaps @dimpase can confirm this). And the GUI frontends XGAP and GAP.app by @RussWoodroofe use special control codes, by enabling so called "window mode", which already disables GNU readline integration. So all in all I am hopeful this is safe, and does not even need to be mentioned in the release notes.

@fingolfin fingolfin added topic: kernel release notes: not needed PRs introducing changes that are wholly irrelevant to the release notes labels May 17, 2021
@dimpase
Copy link
Member

dimpase commented May 17, 2021

SageMath certainly builds GAP with readline enabled. While we are phasing out pexpect interface for GAP in favour of libgap, it is not complete.

I will need to verify whether this does not break things for us

Copy link
Contributor

@hulpke hulpke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, alas this does not fix the issue and the extra characters are still in the file.

@fingolfin
Copy link
Member Author

@dimpase I am sure you build it with readline enabled, but that's not the point. But you don't e.gy send "arrow-up enter" in order to execute the previous command again, do you?

@dimpase
Copy link
Member

dimpase commented May 17, 2021

no, I don't think such contortions are done by Sage. Although perhaps users do it, one never knows (I would not worry about it, though).

@fingolfin
Copy link
Member Author

@hulpke Thanks for trying. At first I was very confused by this, but I just had another look and I think I know what I missed... I've updated this PR, could you give it another try, please?

@hulpke
Copy link
Contributor

hulpke commented May 17, 2021

@hulpke Thanks for trying. At first I was very confused by this, but I just had another look and I think I know what I missed... I've updated this PR, could you give it another try, please?

Sure. Still, same ESC sequence remains and same error. (Since it is not my computer, I unfortunately cannot give you a login, but I'm happy to continue testing.)

@fingolfin
Copy link
Member Author

@hulpke thanks! This is rather vexing. OK, one more: could you just try compiling GAP with the configure option --without-readline, to ensure no GNU readline support is in there at all? Does that help?

@hulpke
Copy link
Contributor

hulpke commented May 17, 2021

If I configure --without-readline all is fine (even in the master branch)

@RussWoodroofe
Copy link
Contributor

Responding belatedly to ping: Yes, this should not affect XGAP or Gap.app, as the -p flag turns off readline. Anyway, both use openpty to establish communication. Doesn't that mark stdin as being a terminal?

As far as the root problem: would adding the -E flag to the invocation of gap in the gac script fix it? (Probably this has already been tried...)

@fingolfin
Copy link
Member Author

@hulpke this is really weird, esp. since I can't reproduce it locally at all... I now think it may not be related to those settings in /etc/inputrc at all, but rather perhaps to some termcap settings / ncurse initialization? But that still doesn't explain why this PR doesn't make it go away -- I don't think we leave any calls into readline in place... weird.

I just pushed another HACK; could you please build GAP from this commit, and see if (a) you see any of the HACK messages if you start GAP with / without the -E option (they should be there without it, but not with it given), and (b) to check once again that in this version whether the escape sequence is printed.

@hulpke
Copy link
Contributor

hulpke commented May 18, 2021

Sorry, @fingolfin for all the trouble. I did:

  • make clean
  • configure (w/o any other option)
  • make

Still the same extra characters.

  • Edited build/c_* to delete the characters
  • make

Then calling bin/gap.sh gives

HACK: GAP calling rl_initialize
HACK: FuncBINDKEYSTOGAPHANDLER
HACK: FuncBINDKEYSTOGAPHANDLER
HACK: FuncREADLINEINITLINE
HACK: FuncREADLINEINITLINE
HACK: FuncBINDKEYSTOGAPHANDLER
HACK: FuncREADLINEINITLINE
HACK: FuncREADLINEINITLINE
HACK: FuncBINDKEYSTOGAPHANDLER
HACK: FuncBINDKEYSTOGAPHANDLER
HACK: FuncBINDKEYSTOGAPHANDLER
HACK: FuncBINDKEYSTOGAPHANDLER
HACK: FuncBINDKEYSTOGAPHANDLER
HACK: FuncBINDKEYSTOGAPHANDLER
 ┌───────┐   GAP 4.12dev-880-gbaec09a built on 2021-05-18 14:27:38-0600
 │  GAP  │   https://www.gap-system.org
 └───────┘   Architecture: x86_64-pc-linux-gnu-default64-kv8
 Configuration:  gmp 6.0.0, GASMAN, readline
 Loading the library and packages ...
 Packages:   AtlasRep 2.1.0, AutPGrp 1.10, CTblLib 1.2.2, FactInt 1.6.2,
             GAPDoc 1.6.2, PrimGrp 3.2.0, SmallGrp 1.4.1, TomLib 1.2.6,
             TransGrp 3.0
 Try '??help' for help. See also '?copyright', '?cite' and '?authors'
gap> HACK: readlineFgets
HACK: initreadline

while gap -E gives

Unix138 /home/fac/f/hulpke/tmp/gap > bin/gap.sh -E
 ┌───────┐   GAP 4.12dev-880-gbaec09a built on 2021-05-18 14:27:38-0600
 │  GAP  │   https://www.gap-system.org
 └───────┘   Architecture: x86_64-pc-linux-gnu-default64-kv8
 Configuration:  gmp 6.0.0, GASMAN
 Loading the library and packages ...
 Packages:   AtlasRep 2.1.0, AutPGrp 1.10, CTblLib 1.2.2, FactInt 1.6.2,
             GAPDoc 1.6.2, PrimGrp 3.2.0, SmallGrp 1.4.1, TomLib 1.2.6,
             TransGrp 3.0
 Try '??help' for help. See also '?copyright', '?cite' and '?authors'

@fingolfin
Copy link
Member Author

@hulpke thanks for trying again. At this point I am out of ideas (perhaps @ChrisJefferson has one, though)?

That said, I think this PR is useful on its own, as it really disables use of readline fully, while before we still called rl_initialize() even though we then never again called into readline.

@hulpke hulpke self-requested a review May 19, 2021 14:12
@fingolfin fingolfin merged commit 60d180d into gap-system:master Jun 1, 2021
@fingolfin fingolfin deleted the mh/no-tty-then-no-readling branch June 1, 2021 10:09
fingolfin added a commit to fingolfin/gap that referenced this pull request Jan 10, 2024
... by reverting a previous change that made us disable readline
when stdin is not connected to a terminal (see
gap-system#4495). While that still
seems useful, and avoids certain issues when piping GAP output
into files, it needs a better implication that avoids the issues
described in gap-system#5014

Also add a separate CI test suite target "testworkspace" for testing
for this issue, and potentially other workspace related issues.
fingolfin added a commit to fingolfin/gap that referenced this pull request Jan 11, 2024
... by reverting a previous change that made us disable readline
when stdin is not connected to a terminal (see
gap-system#4495). While that still
seems useful, and avoids certain issues when piping GAP output
into files, it needs a better implication that avoids the issues
described in gap-system#5014

Also add a separate CI test suite target "testworkspace" for testing
for this issue, and potentially other workspace related issues.
fingolfin added a commit that referenced this pull request Jan 12, 2024
... by reverting a previous change that made us disable readline
when stdin is not connected to a terminal (see
#4495). While that still
seems useful, and avoids certain issues when piping GAP output
into files, it needs a better implication that avoids the issues
described in #5014

Also add a separate CI test suite target "testworkspace" for testing
for this issue, and potentially other workspace related issues.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release notes: not needed PRs introducing changes that are wholly irrelevant to the release notes topic: kernel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compilation error on not bleeding-edge gcc
4 participants