Bug 257463 - shells/pdksh crashes with ((--)) as input
Summary: shells/pdksh crashes with ((--)) as input
Status: Open
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Rodrigo Osorio
Depends on:
Reported: 2021-07-27 21:15 UTC by Robert Morris
Modified: 2021-07-28 11:51 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (rodrigo)


Note You need to log in before you can comment on or make changes to this bug.
Description Robert Morris 2021-07-27 21:15:18 UTC
If I run shells/pdksh on FreeBSD 13.0-RELEASE-p3 on an amd64,
and type


then ksh gets a segmentation fault.
Comment 1 Robert Morris 2021-07-27 21:37:35 UTC
The problem is that v_evaluate() in expr.c doesn't initialize curstate.val,
and token() doesn't set es->val when given this particular input.
Comment 2 Rodrigo Osorio freebsd_committer 2021-07-28 08:43:30 UTC
Hi Robert,

Thanks for the report. I try to reproduce the behavior in my
environment (FreeBSD 12 amd64) and pdksh doesn't crash. I only
got an error message : "ksh: --: -- requires lvalue"

Do you use project packages ? latest or quarterly branch ?
If do, can you made a sum of the pdksh binary, just to be sure
I'm testing with the right environment.

If you build your own packages, can you provide more details about
your setup.

All the best
-- Rodrigo
Comment 3 Robert Morris 2021-07-28 09:09:25 UTC
(In reply to Rodrigo Osorio from comment #2)
I get this crash whether I use the pkg or /usr/ports.
When I install with pkg, it says:

New packages to be INSTALLED:
        pdksh: 5.2.14p2_6

Here's the checksum &c of the binary:

% sum /usr/local/bin/ksh
13590 279 /usr/local/bin/ksh
% ls -l /usr/local/bin/ksh
-r-xr-xr-x  1 root  wheel  285096 Jul  1 15:24 /usr/local/bin/ksh
$ echo $KSH_VERSION 
@(#)PD KSH v5.2.14.2 99/07/13.2
% uname -a
FreeBSD xxx 13.0-RELEASE-p3 FreeBSD 13.0-RELEASE-p3 #0: Tue Jun 29 19:46:20 UTC 2021     root@amd64-builder.daemonology.net:/usr/obj/usr/src/amd64.amd64/sys/GENERIC  amd64
% echo '((--' | ksh
Segmentation fault

I see the same bug when compiling from /usr/ports, but I do
not know how to find out what version of ports I'm using.
If you tell me what to do, I'll do it. As far as I know there's
nothing special about my setup.
Comment 4 Rodrigo Osorio freebsd_committer 2021-07-28 11:51:29 UTC
(In reply to Robert Morris from comment #3)

Thanks for the details, with the command line you provide I can reproduce the issue. I  move the issue to the open state.