tcsh-org / tcsh

This is a read-only mirror of the tcsh code repository.
https://www.tcsh.org/
Other
232 stars 42 forks source link

Variable expansion :gas modifier test fails on i386 #24

Closed jbeich closed 4 years ago

jbeich commented 4 years ago

Affects at least 11.3-RELEASE, 12.1-RELEASE and 13.0-CURRENT.

$ pkg install git autoconf
$ git clone https://github.com/tcsh-org/tcsh /tmp/tcsh
$ cd /tmp/tcsh
$ ./configure; make; make test
[...]
125: :gas work as described in the man pages         FAILED (lexical.at:643)
[...]
ERROR: 181 tests were run,
1 failed unexpectedly.
54 tests were skipped.
suominen commented 4 years ago

This is the test:

set x=(aa bb aa bb)
echo $x:gas/a/c/:gs/b/d/
foreach i ( "$x:gas/a/c/:q" )
    echo $i
end
echo $x:gas/a/q/:gs/b/w/:s/b/e/
echo $x:gas/a/q/:gs/b/w/:s/b/e/:gas/q/Q/
exit 0

The first a flag gets stuck?

125. lexical.at:630: testing :gas work as described in the man pages ...
./lexical.at:643: tcsh -f gas.csh
--- -   2020-05-21 22:38:52.571182000 +0300
+++ /home/kim/src/tcsh/testsuite.dir/at-groups/125/stdout       2020-05-21 22:38:52.570335000 +0300
@@ -1,5 +1,5 @@
 cc db cc db
 cc bb cc bb
-qq we qq wb
-QQ we QQ wb
+qq ww qq ww
+QQ ww QQ ww

125. lexical.at:630: 125. :gas work as described in the man pages (lexical.at:630): FAILED (lexical.at:643)
suominen commented 4 years ago

Test succeeds on amd64.

zoulasc commented 4 years ago

could this be a compiler issue? compile without optimization?

jbeich commented 4 years ago

Test succeeds on amd64.

If you pass -m32 it doesn't. ;)

could this be a compiler issue?

Affects at least Clang 8.0.1, 10.0.0, GCC 4.2.1 (patched), 9.3.0.

compile without optimization?

Passing CFLAGS=-O0 doesn't help.

zoulasc commented 4 years ago

Ok, it could be something else then; let me play with it some more on my side.

zoulasc commented 4 years ago

On the other topic we should fix all the tests to handle symlinks better.

suominen commented 4 years ago

Also fails on NetBSD/i386 (9.0_STABLE).

suominen commented 4 years ago

And also fails on NetBSD/amd64 (9.99.56 / 2020-04-14 09:21 EEST):

env CC='cc -m32' ./configure
alzwded commented 4 years ago

I've kinda looked over it and I don't get it. I can try -m32 and see what's up.

alzwded commented 4 years ago

Mmm... it's fine with -m32 on centos with gcc 4.8.5, I'm guessing it's a *BSD-i386 thing then?

alzwded commented 4 years ago

I've got a qemu going, it seems realloc is doing some strange things and ending up setting RMAGIC on dolaflags[1] when realloc'ing to size 3. There's that line with op->ov_rmagic = RMAGIC that writes out that value; after returning from xrealloc, that's the value that's there instead of a 0. (and then my VM crashed)

suominen commented 4 years ago

On Ubuntu 16.04 with env CFLAGS=-m32 ./configure all is good. (We will soon have this in Travis CI -- see #26.)

On Ubuntu 18.04 with env CFLAGS=-m32 ./configure the test crashes in the last expansion:

glenmorangie:~/src/tcsh> ./tcsh -f testsuite.dir/125/gas.csh
cc db cc db
cc bb cc bb
qq we qq wb
Abort
Exit 134

But the results for the previous lines are correct.

suominen commented 4 years ago

Tried with both clang and gcc on Ubuntu 18.04.

glenmorangie:~/src/tcsh> clang -m32 --version
clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
Target: i386-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
glenmorangie:~/src/tcsh> gcc -m32 --version
gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
alzwded commented 4 years ago

How stupid of me, in sh.dol.c the two xrealloc lines growing or shrinking dolaflags and dolmcnts should read xrealloc(..., ndolflags * sizeof(int)) (emphasis on * sizeof(int). With that change, the test passes on FreeBSD 12.0-RELEASE and CC="gcc -m32", gcc being 9.3.0. I can put together a merge request for that. I have no idea why it was working on amd64

alzwded commented 4 years ago

27 is up. The Travis job fails on freebsd because of other tests,