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

Infinite loop when evaluating ((-2**63/-1)) #789

Open
oliwer opened this issue Oct 9, 2024 · 1 comment
Open

Infinite loop when evaluating ((-2**63/-1)) #789

oliwer opened this issue Oct 9, 2024 · 1 comment
Labels
bug Something is not working

Comments

@oliwer
Copy link

oliwer commented Oct 9, 2024

Using Korn Shell Version AJM 93u+m/1.0.8 2024-01-01 on Linux amd64, the following command causes ksh to run into an infinite loop. I had to kill -9 it:

echo $((-2**63/-1))

I ran a quick gdb, and it seems this line is the culprit:

num = U2F((Sfulong_t)(sp[-1]) / (Sfulong_t)(num));

The variable sp[-1] holds a negative long double (-9223372036854775808) which we are casting to an unsigned long. Looks like a similar issue to #770

@McDutchie McDutchie added the bug Something is not working label Oct 28, 2024
@McDutchie
Copy link

I don't have access to Linux x86_64 right now, but on FreeBSD x86_64, the symptom is:

$ arch/freebsd13.i386-64/bin/ksh -c 'echo $((-2**63/-1))'
Floating exception(coredump)

Yes, looks like a workaround similar to the one that fixed #770 might work — though the real problem here is #771, which is not getting fixed anytime soon I'm afraid :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working
Projects
None yet
Development

No branches or pull requests

2 participants