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

Failing sscanf tests #3933

Closed
kangaroo opened this issue Feb 9, 2015 · 6 comments
Closed

Failing sscanf tests #3933

kangaroo opened this issue Feb 9, 2015 · 6 comments
Assignees

Comments

@kangaroo
Copy link
Contributor

kangaroo commented Feb 9, 2015

I haven't spent any real time investigating this yet, brain dump follows.

Several sscanf tests are currently broken on mac and linux:

vagrant@vagrant-ubuntu-trusty-64:/vagrant/binaries/CMake$ ./src/pal/tests/palsuite/c_runtime/sscanf/test3/paltest_sscanf_test3
vagrant@vagrant-ubuntu-trusty-64:/vagrant/binaries/CMake$ ./src/pal/tests/palsuite/c_runtime/sscanf/test3/paltest_sscanf_test3 ; echo $?
5
vagrant@vagrant-ubuntu-trusty-64:/vagrant/binaries/CMake$ gdb --args ./src/pal/tests/palsuite/c_runtime/sscanf/test3/paltest_sscanf_test3 ; echo $?
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./src/pal/tests/palsuite/c_runtime/sscanf/test3/paltest_sscanf_test3...done.
(gdb) r
Starting program: /vagrant/binaries/CMake/src/pal/tests/palsuite/c_runtime/sscanf/test3/paltest_sscanf_test3 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff6bc9700 (LWP 2047)]
[New Thread 0x7ffff63c8700 (LWP 2048)]

Program received signal SIGSEGV, Segmentation fault.
0x0000000000510c57 in __tinput_s (stream=0x7fffffffda78, format=0x7fffffffdd87 "n", arglist=0x7fffffffdc30) at /vagrant/src/pal/src/safecrt/input.inl:1038
1038                                        *(int UNALIGNED *)pointer = (unsigned int)number;
(gdb) bt
#0  0x0000000000510c57 in __tinput_s (stream=0x7fffffffda78, format=0x7fffffffdd87 "n", arglist=0x7fffffffdc30) at /vagrant/src/pal/src/safecrt/input.inl:1038
dotnet/coreclr#1  0x0000000000488714 in vscan_fn (inputfn=0x50ed60 <__tinput_s>, string=0x52ccd0 "bar1", format=0x7fffffffdd80 "%[a-z]%n", arglist=0x7fffffffdc30) at /vagrant/src/pal/src/safecrt/sscanf.c:65
dotnet/coreclr#2  0x00000000004884aa in sscanf_s (string=0x52ccd0 "bar1", format=0x7fffffffdd80 "%[a-z]%n") at /vagrant/src/pal/src/safecrt/sscanf.c:201
dotnet/coreclr#3  0x0000000000423c09 in PAL_vsscanf (Buffer=0x52ccd0 "bar1", Format=0x52ccd5 "%[a-z]", ap=0x7fffffffe380) at /vagrant/src/pal/src/cruntime/printf.cpp:1178
dotnet/coreclr#4  0x0000000000428198 in PAL_sscanf (buffer=0x52ccd0 "bar1", format=0x52ccd5 "%[a-z]") at /vagrant/src/pal/src/cruntime/printf.cpp:1479
dotnet/coreclr#5  0x0000000000420306 in DoStrTest (inputstr=0x52ccd0 "bar1", formatstr=0x52ccd5 "%[a-z]", checkstr=0x52ccdc "bar") at /vagrant/src/pal/tests/palsuite/c_runtime/sscanf/test3/../sscanf.h:47
dotnet/coreclr#6  0x0000000000420d53 in main (argc=1, argv=0x7fffffffe628) at /vagrant/src/pal/tests/palsuite/c_runtime/sscanf/test3/test3.c:27

On OSX 3, 9 and 10 are broken. It appears that 9, 10 are passing on Linux just based on luck of where the pointer is:

(gdb) 
1038                                        *(int UNALIGNED *)pointer = (unsigned int)number;
1: *arglist = {gp_offset = 40, fp_offset = 48, overflow_arg_area = 0x7fffffffdc70, reg_save_area = 0x7fffffffdb80}
(gdb) 
1042                                } else /*NULL*/;
1: *arglist = {gp_offset = 40, fp_offset = 48, overflow_arg_area = 0x7fffffffdc70, reg_save_area = 0x7fffffffdb80}
(gdb) p pointer
$1 = (void *) 0x7ffff6f8a000 <tzname>
(gdb) 

It seems the 3 cases share a similar base cause of entering the case to parse an array width, which seems at a quick glance like an incorrect branch.

@sergiy-k
Copy link
Contributor

sergiy-k commented Feb 9, 2015

@kangaroo Thank you very much for reporting the issue. We have never seen this before (these tests used to pass all the time on Linux). I guess, like you said, this was just based on luck. I will take a look.

@kangaroo
Copy link
Contributor Author

kangaroo commented Feb 9, 2015

@sergiy-k They do pass, mostly because the overconsumption of the va_list happens to return a writeable pointer on linux. So its kind of a false pass :)

@sergiy-k sergiy-k self-assigned this Feb 11, 2015
sergiy-k referenced this issue in sergiy-k/coreclr Feb 11, 2015
These tests need to be temporary disabled untill the issue https://github.com/dotnet/coreclr/issues/161 is fixed. This needs to be done in order to enable running PAL tests in the lab. Currently these test cases fail on Mac and Linux release builds.
@sergiy-k
Copy link
Contributor

Hi @kangaroo, I have fixed these sscanf issues in dotnet/coreclr#258.
Unfortunately, these three tests that you mentioned did not crash when I ran them on Mac (debug and release) so I stepped through them under debugger to make sure the code does the right thing. Luckily, two of the sscanf tests (9 and 11) were crashing on a release build on Linux so that gave me a good starting point since all these failures shared the common root problem. Thank you!

@kangaroo
Copy link
Contributor Author

@sergiy-k Ok, I'll check the tests on my mac where they were failing shortly to confirm the status.

@kangaroo
Copy link
Contributor Author

LGTM

Finished running PAL tests.

PAL Test Results:
Passed: 820
Failed: 0

@sergiy-k
Copy link
Contributor

@kangaroo Thank you!

mmitche referenced this issue in mmitche/coreclr Feb 24, 2015
These tests need to be temporary disabled untill the issue https://github.com/dotnet/coreclr/issues/161 is fixed. This needs to be done in order to enable running PAL tests in the lab. Currently these test cases fail on Mac and Linux release builds.
@msftgits msftgits transferred this issue from dotnet/coreclr Jan 30, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Jan 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants