Commit graph

2136 commits

Author SHA1 Message Date
Jeff Epler
0256eb9a45 actually run what I intended 100x 2017-08-21 10:07:01 -05:00
Jeff Epler
a7b65aefbf jfc test my branches wtq 2017-08-21 09:53:36 -05:00
Jeff Epler
5f476506bd jfc test my branches wtq 2017-08-21 09:52:45 -05:00
Jeff Epler
f87868d8e3 temporary tweak to CI scripts 2017-08-21 09:30:37 -05:00
Jeff Epler
3ec5466445 lazyFileReader: open file in binary mode
Inputs to lazyFileReader may look like text files (their contents
are essentially ASCII), but they may not necessarily obey the
platform rules for text files, such as terminating each line with
the CR LF control sequence on Windows platforms.

Also, the file position operations which may be performed on text
files are severely limited by the C and C++ language standards.  For
instance, Microsoft documentation states that
 1. ifstream::seekg will call basic_filebuf::seekpos.
    basic_filebuf::seekpos is in turn implemented in terms of C fsetpos
    on Windows.
    https://msdn.microsoft.com/en-us/library/xx21a6ww(v=vs.110).aspx

 2. The C standard specifies that it is undefined behavior if the
    "fsetpos function is called to set a position that was not returned
    by a previous successful call to the fgetpos function on a stream
    associated with the same file (7.21.9.3)." [ISO/IEC 9899:2011]

 3. Similarly, ifstream::unget() may call basic_filebuf::pbackfail()
    which on Windows is implemented in terms of ungetc().
    https://msdn.microsoft.com/en-us/library/x0kf6337(v=vs.110).aspx
    https://msdn.microsoft.com/en-us/library/29hykw2y(v=vs.110).aspx

 4. Microsoft documents the following about how file positions are
    maintained when ungetc() is used on text streams:
        On a successful ungetc call against a text stream, the
        file-position indicator is unspecified until all the
        pushed-back characters are read or discarded.

 5. In stepcode, unget() and seekg() are freely mixed without regard
    to whether undefined behavior is encountered as a result of
    [1-4]
2017-08-21 09:04:53 -05:00
Jeff Epler
1d01b831aa errordesc.cc: Correctly append a single character to a std::string
The idiom
    char c = ...;
    _userMsg.append( &c );
is not correct C++, because it treats the address of 'c' as a NUL-
terminated C string.  However, this is not guaranteed.

When building and testing on Debian Stretch with AddressSanitizer:
    ASAN_OPTIONS="detect_leaks=false" CXX="clang++" CC=clang CXXFLAGS="-fsanitize=address" LDFLAGS="-fsanitize=address" cmake .. -DSC_ENABLE_TESTING=ON  -DSC_BUILD_SCHEMAS="ifc2x3;ap214e3;ap209"
    ASAN_OPTIONS="detect_leaks=false" make
    ASAN_OPTIONS="detect_leaks=false" ctest . --output-on-failure
an error like the following is encountered:

==15739==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffeb2ca7621 at pc 0x00000043c943 bp 0x7ffeb2ca75d0 sp 0x7ffeb2ca6d80
READ of size 33 at 0x7ffeb2ca7621 thread T0
    #0 0x43c942 in __interceptor_strlen.part.45 (/home/jepler/src/stepcode/build/bin/lazy_sdai_ap214e3+0x43c942)
    #1 0x7fb9056e6143 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::append(char const*) (/usr/lib/x86_64-linux-gnu/libstdc++.so.6+0x11f143)
    #2 0x7fb905b677c3 in ErrorDescriptor::AppendToDetailMsg(char) /home/jepler/src/stepcode/src/clutils/errordesc.cc:150:5

Address 0x7ffeb2ca7621 is located in stack of thread T0 at offset 33 in frame
    #0 0x7fb905b676af in ErrorDescriptor::AppendToDetailMsg(char) /home/jepler/src/stepcode/src/clutils/errordesc.cc:149

  This frame has 1 object(s):
    [32, 33) '' <== Memory access at offset 33 overflows this variable

A similar problem with AppendToUserMsg is found by inspection.

After this change, all 200 tests pass under the AddressSanitizer
configuration
2017-08-21 08:35:04 -05:00
Jeff Epler
0d2e791e82 express/error.c: Ensure the error buffer does not overflow
On Debian Stretch, when configuring stepcode like so:
    ASAN_OPTIONS="detect_leaks=false" CXX="clang++" CXXFLAGS="-fsanitize=address" cmake ..
a fatal error would be detected:

  ==29661==ERROR: AddressSanitizer: heap-buffer-overflow on address
  0x62100001dca0 at pc 0x0000004435e3 bp 0x7ffed6d9cae0 sp 0x7ffed6d9c290

  READ of size 4001 at 0x62100001dca0 thread T0

      #0 0x4435e2 in __interceptor_strlen.part.45 (/home/jepler/src/stepcode/build/bin/schema_scanner+0x4435e2)
      #1 0x501d7b in ERRORreport_with_symbol /home/jepler/src/stepcode/src/express/error.c:413

  0x62100001dca0 is located 0 bytes to the right of 4000-byte region
  [0x62100001cd00,0x62100001dca0)

  allocated by thread T0 here:

      #0 0x4c3ae8 in __interceptor_malloc (/home/jepler/src/stepcode/build/bin/schema_scanner+0x4c3ae8)
      #1 0x5011fc in ERRORinitialize /home/jepler/src/stepcode/src/express/error.c:129

Operations on ERROR_string were unsafe, because they did not guard
against accesses beyond the end of the allocatd region.

This patch ensures that all accesses via *printf functions do respect
the end of the buffer; and encapsulates the routine for pointing
ERROR_string at the space for the next error text to start, if space is
available.

Finally, because it was found with search and replace, a stray manipulation
of ERROR_string within the print-to-file branch of the code is removed.
This stray line would have had the effect of moving ERROR_string one byte
further along at every warning-to-file, which could also have been a
cause of the problem here.
2017-08-21 08:35:04 -05:00
Mark
71fe947ff5 Merge pull request #361 from jepler/appveyor-single-thread-test
appveyor build: don't use ctest parallelism
2017-08-19 17:12:28 -04:00
Mark
beb2a595f1 Merge pull request #357 from jepler/nullptr-bool
Fix build error with g++ 6.3 (Debian Stretch)
2017-08-19 15:41:33 -04:00
Jeff Epler
3fd71cf457 appveyor build: don't use ctest parallelism
On Windows, concurrent access to files is severely restricted
compared to standard operating systems.  When ctest is invoking
cmake, this causes it to write simultaneously to the same files in
each concurrent cmake invocation, leading to spurious test failures
like

  error MSB3491: Could not write lines to file "...".  The process
  cannot access the file '...' because it is being used by another
  process.

Explicitly ask for no parallelism with "-j1", even though it is
probably the default.
2017-08-15 20:38:47 -05:00
Jeff Epler
0fbc3c0c84 Fix build error with g++ 6.3 (Debian Stretch)
On this platform, TEST_NULLPTR fails, even though nullptr and
nullptr_t are supported:

/home/jepler/src/stepcode/build/CMakeFiles/CMakeTmp/src.cxx:4:23:
    error: converting to 'bool' from 'std::nullptr_t'
    requires direct-initialization [-fpermissive]
 int main() {return !!f();}
                      ~^~

Subsequent to this failure, the workaround definitions in sc_nullptr.h
prevent standard C++ headers (which must refer to real nullptr) to fail.

The failure occurs because the C++ standard apparently does not state
that operator! may be used on nullptr.  Despite this, some compilers
have historically allowed it.  g++ 6.3's behavior appears to be aligned
with the standard.

As requested by @brlcad, ensure that the function 'f' is used from main,
to avoid a clever (but not nullptr-supporting) compiler from somehow
skipping 'f' altogether, creating a false positive for nullptr support.
2017-08-15 06:50:56 -05:00
Mark
a96336ab97 Merge pull request #351 from stepcode/review/327
Review/327
2017-08-13 20:46:34 -04:00
Thomas Paviot
b24680d7e5 Merge pull request #356 from luzpaz/ascii-typos
Fixed typos showing up as ascii chars
2017-03-05 07:41:13 +01:00
Kunda
15afe96d67 Fixed typos showing up as ascii chars
Using http://www.lisi.ensma.fr/ftp/enseignement/A3_Master_Ingenierie_donnees/fonctionsGrammaire_EXPRESS.pdf I was able to fix typos in the text files for Builtin.py
2017-03-04 07:22:46 -05:00
Cliff Yapp
a78ca01b54 Revert "Get latest version of ap242 from http://stepmod.cvs.sourceforge.net/viewvc/stepmod/stepmod/data/modules/ap242_managed_model_based_3d_engineering/mim_lf.exp"
This reverts commit 0b456a833e.

New schema apparently doesn't build.
2016-08-06 16:51:58 -04:00
Cliff Yapp
8627627c5e Add an option to completely bypass the git management of the version header. 2016-08-06 13:53:12 -04:00
Cliff Yapp
9b091756b1 Allow the user to control whether C++11 is used (matters for subbuilds) 2016-08-06 13:02:35 -04:00
Cliff Yapp
dfce2dcf07 For the flags variables, rather annoyingly, they actually need to be managed as strings and not lists. 2016-08-06 12:37:01 -04:00
Cliff Yapp
5c7e63c75b Fix macro comments. This approach to managing the targets varies from the old EXCLUDE_OR_INSTALL setup in that by default the testable targets are not added to the 'all' build - in other works, 'make' will make just the main stepcode targets. The testable targets are available individually, and if SC_ENABLE_TESTING is enabled they *will* be added to the 'all' target, but by default they are not compiled in the basic build. 2016-08-06 12:32:12 -04:00
Cliff Yapp
0b456a833e Get latest version of ap242 from http://stepmod.cvs.sourceforge.net/viewvc/stepmod/stepmod/data/modules/ap242_managed_model_based_3d_engineering/mim_lf.exp 2016-08-06 12:05:18 -04:00
Cliff Yapp
a243b4d8c8 Separate shared and static generated files for better parallel building safety. 2016-08-06 11:55:38 -04:00
Cliff Yapp
daec3e2640 Add option handling to the SC target macros, replacing the EXCLUDE_FROM_INSTALL macro. 2016-08-06 11:43:59 -04:00
Cliff Yapp
06b13bb9af Make a stab at adapting the new, simplier verification to vanilla stepcode 2016-08-06 11:23:34 -04:00
Cliff Yapp
e38519a7f1 Update Find cmake scripts 2016-08-06 10:53:19 -04:00
Cliff Yapp
12def15dd2 Start working on merging BRL-CAD changes back into upstream. 2016-08-06 10:46:23 -04:00
Mark Pictor
a160cc9af6 fix #327 - statically initialize t_sdaiINTEGER etc 2015-08-30 11:57:58 -04:00
Mark Pictor
1dfe76b3b4 README: put CI badges in table 2015-08-23 22:30:36 -04:00
Mark Pictor
c23ba65c41 appveyor log - use JSON-like console data, massaged for parsability 2015-08-23 22:30:16 -04:00
Mark Pictor
274de2a91d appveyor: exclude hanging test 2015-08-10 21:06:51 -04:00
Mark Pictor
1a757024c4 add appveyor badge 2015-08-10 21:04:10 -04:00
Mark Pictor
abae0a7c45 allow downloading log directly from AV 2015-08-10 21:00:35 -04:00
Mark
bfc11face5 Merge pull request #345 from stepcode/review/misc
appveyor isn't at 100%, but it's considerably better
2015-08-10 20:47:30 -04:00
Mark Pictor
677261d4fb fix LNK2004 getEDesc already defined in sectionReader.obj
is this really the only/best way to fix this?!
2015-08-09 23:36:54 -04:00
Mark Pictor
4207a46f07 fix MSVC link error for NilSTEPentity 2015-08-09 23:30:13 -04:00
Mark Pictor
7316fe5070 msvc warnings/errors 2015-08-09 23:29:15 -04:00
Mark Pictor
4d32009592 'register' storage class specifier is deprecated [-Wdeprecated-register] 2015-08-03 22:00:22 -04:00
Mark Pictor
0b6078b72b missing include 2015-08-03 21:55:00 -04:00
Mark Pictor
36e34862cc cllazyfile: work around LNK2005 error. had to tweak class members so MSVC didn't see MgrNodeBase class twice.
suspect there is a better solution, but I'm not sure what it would be
2015-08-03 21:50:19 -04:00
Mark Pictor
9dcb6aa640 build judy array as part of base lib, else import/export macros don't work 2015-08-03 21:38:37 -04:00
Mark Pictor
bc5533bda8 test for, and use, nullptr if we have it 2015-08-03 21:37:28 -04:00
Mark Pictor
4e88ad69eb summarize-appveyor-log: sort before printing 2015-08-02 22:51:22 -04:00
Mark Pictor
b890c156f5 attempt to silence msvc linker errors 2015-08-02 22:50:26 -04:00
Mark Pictor
0ba7343004 no more excuses, build cllazyfile on windows 2015-08-02 15:59:48 -04:00
Mark Pictor
f2247d222f use COMPILE_DEFINITIONS property for definitions 2015-08-02 15:58:04 -04:00
Mark Pictor
5288026043 add windows dll import/export macros to cllazyfile 2015-08-02 15:57:10 -04:00
Mark Pictor
6e8cad223e cmake 2.8.7 needs append_string, not append 2015-08-02 15:37:45 -04:00
Mark Pictor
018e7cfffc reduce delay used in parallel test, as it appears to cause a failure.
TODO: rework the test to not be timing-sensitive
2015-08-02 14:53:36 -04:00
Mark Pictor
458b775f41 simplify cmake logic - use set_property(...APPEND...) rather than get/list append/set 2015-08-02 14:30:01 -04:00
Mark Pictor
dc82923cf1 support cmake 2.8.7 since that's what travis-ci uses 2015-08-02 14:28:53 -04:00
Mark Pictor
aa967b3316 tweak includ dir logic, print path 2015-07-26 23:22:32 -04:00