GnuCash
Contact   Instructions
Bug 795251 - googletest detection cannot be overridden
Summary: googletest detection cannot be overridden
Status: RESOLVED INCOMPLETE
Alias: None
Product: GnuCash
Classification: Unclassified
Component: Build system (show other bugs)
Version: git-maint
Hardware: Other NetBSD
: Normal normal
Target Milestone: future
Assignee: core
QA Contact: core
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-04-14 03:28 EDT by Thomas Klausner
Modified: 2021-01-28 20:25 EST (History)
7 users (show)

See Also:


Attachments

Description Thomas Klausner 2018-04-14 03:28:51 EDT
My distribution contains a googletest package. It installs the headers in ${PREFIX}/include/gmock and ${PREFIX}/include/gtest (where PREFIX is /usr/pkg in my case). However, it is not sufficient for gnucash's needs, so in the package I unpack googletest-1.8.0 and set GMOCK_ROOT and GTEST_ROOT to point to that.

However, when the googletest package is installed, the build fails:
/scratch/finance/gnucash/work/googletest-release-1.8.0/googlemock/src/gmock-all.cc:40:25: fatal error: gmock/gmock.h: No such file or directory

I haven't completely understood the problem yet, but in effect,  the autodetected ${PREFIX}/include seems to be preferred to the GMOCK_ROOT and GTEST_ROOT (and even GMOCK_INCLUDE_DIR) variables that I pass in manually on the cmake commandline.

Verbose output from cmake + make VERBOSE=1:

With googletest package from distribution installed:

c++  -DHAVE_CONFIG_H -DHAVE_GUILE22 -I/usr/pkg/include -I/scratch/finance/gnucas
h/work/gnucash-3.0/common -I/scratch/finance/gnucash/work/gnucash-3.0/libgnucash/engine -I/scratch/finance/gnucash/work/gnucash-3.0/common/test-core -I/usr/pkg/include/glib/glib-2.0 -I/usr/pkg/lib/glib-2.0/include -I/usr/pkg/guile/2.2/include/guile/2.2 -I/scratch/finance/gnucash/work/googletest-release-1.8.0/googlemock  -Werror -Wall -Wmissing-declarations -Wno-unused -std=gnu++11 -O2 -g -D_FORTIFY_SOURCE=2 -fstack-check -I/usr/pkg/include/libofx -I/usr/pkg/include -I/usr/include -I/usr/pkg/include/python3.6 -I/usr/pkg/include/glib/glib-2.0 -I/usr/pkg/include/glib/gio-unix-2.0 -I/usr/pkg/lib/glib-2.0/include -I/usr/pkg/include/freetype2 -I/usr/pkg/include/libdrm -Wno-deprecated-declarations   -Wno-missing-declarations -o CMakeFiles/gmock.dir/scratch/finance/gnucash/work/googletest-release-1.8.0/googlemock/src/gmock-all.cc.o -c /scratch/finance/gnucash/work/googletest-release-1.8.0/googlemock/src/gmock-all.cc

(build fails as above)

WITHOUT googletest package from distribution installed:

c++  -DHAVE_CONFIG_H -DHAVE_GUILE22 -I/usr/pkg/include -I/scratch/finance/gnucash/work/gnucash-3.0/common -I/scratch/finance/gnucash/work/gnucash-3.0/libgnucash/engine -I/scratch/finance/gnucash/work/gnucash-3.0/common/test-core -I/usr/pkg/include/glib/glib-2.0 -I/usr/pkg/lib/glib-2.0/include -I/usr/pkg/guile/2.2/include/guile/2.2 -I/scratch/finance/gnucash/work/googletest-release-1.8.0/googletest/include -I/scratch/finance/gnucash/work/googletest-release-1.8.0/googletest -I/scratch/finance/gnucash/work/googletest-release-1.8.0/googlemock/include -I/scratch/finance/gnucash/work/googletest-release-1.8.0/googlemock  -Werror -Wall -Wmissing-declarations -Wno-unused -std=gnu++11 -O2 -g -D_FORTIFY_SOURCE=2 -fstack-check -I/usr/pkg/include/libofx -I/usr/pkg/include -I/usr/include -I/usr/pkg/include/python3.6 -I/usr/pkg/include/glib/glib-2.0 -I/usr/pkg/include/glib/gio-unix-2.0 -I/usr/pkg/lib/glib-2.0/include -I/usr/pkg/include/freetype2 -I/usr/pkg/include/libdrm -Wno-deprecated-declarations   -Wno-missing-declarations -o CMakeFiles/gmock.dir/scratch/finance/gnucash/work/googletest-release-1.8.0/googlemock/src/gmock-all.cc.o -c /scratch/finance/gnucash/work/googletest-release-1.8.0/googlemock/src/gmock-all.cc

(build succeeds)

Relevant CMake flags:
-DGMOCK_ROOT=${WRKDIR}/googletest-release-1.8.0/googlemock
-DGMOCK_INCLUDE_DIR=${WRKDIR}/googletest-release-1.8.0/googlemock/include
-DGTEST_ROOT=${WRKDIR}/googletest-release-1.8.0/googletest

where WRKDIR is /scratch/finance/gnucash/work and /scratch/finance/gnucash/work/googletest-release-1.8.0 contains the unpacked source of googletest-1.8.0.
Comment 1 Geert Janssens 2018-04-16 17:43:40 EDT
Can you test with the current head of the maint branch ?

A commit has been merged recently that should allow to build against a system installed shared library version of google test/mock.
Comment 2 Thomas Klausner 2018-04-20 03:01:01 EDT
I installed googletest and ran (from the main branch as of a couple minutes ago):

CXXFLAGS=-Wno-deprecated-declarations cmake .. -DALLOW_OLD_GETTEXT=ON -DWITH_AQBANKING:BOOL=OFF -DWITH_SQL=OFF
make

The build succeeded, so that's good.

I then tried running the tests (I hadn't done that before) and it complains about lots of missing programs and fails a lot of tests. I used "make test".

E.g.
Unable to find executable:
.../gnucash/build/bin/test-transaction-voiding
.../gnucash/build/bin/test-recurrence
.../gnucash/build/bin/test-business
.../gnucash/build/bin/test-employee
.../gnucash/build/bin/test-vendor
...

Then:
24% tests passed, 78 tests failed out of 102
The following tests FAILED:
          1 - test-exp-parser (Failed)
          2 - test-link-module-app-utils (Failed)
          3 - test-print-parse-amount (Not Run)
          4 - test-scm-query-string (Failed)
          5 - test-sx (Not Run)
          9 - test-app-utils (Failed)
         10 - test-date-converting (Not Run)
         11 - test-dom-converters1 (Not Run)
         12 - test-kvp-frames (Not Run)
         13 - test-load-backend (Not Run)
         14 - test-load-xml2 (Failed)
         15 - test-load-example-account (Failed)
         16 - test-string-converters (Not Run)
         17 - test-xml-account (Not Run)
         18 - test-xml-commodity (Not Run)
         19 - test-xml-pricedb (Not Run)
         20 - test-xml-transaction (Not Run)
         21 - test-xml2-is-file (Failed)
         22 - test-real-data (Failed)
         23 - test-gnc-glib-utils (Not Run)
         24 - test-resolve-file-path (Not Run)
         25 - test-userdata-dir (Not Run)
         26 - test-userdata-dir-invalid-home (Not Run)
         27 - test-gnc-path-util (Failed)
         28 - test-link (Not Run)
         29 - test-load-engine (Not Run)
         30 - test-guid (Not Run)
         31 - test-date (Not Run)
         32 - test-object (Not Run)
         33 - test-commodities (Not Run)
         34 - test-qof (Not Run)
         35 - test-engine (Not Run)
         36 - test-account-object (Not Run)
         37 - test-group-vs-book (Not Run)
         38 - test-lots (Not Run)
         39 - test-querynew (Not Run)
         40 - test-query (Not Run)
         41 - test-split-vs-account (Not Run)
         42 - test-transaction-reversal (Not Run)
         43 - test-transaction-voiding (Not Run)
         44 - test-recurrence (Not Run)
         45 - test-business (Not Run)
         46 - test-address (Not Run)
         47 - test-customer (Not Run)
         48 - test-employee (Not Run)
         49 - test-job (Not Run)
         50 - test-vendor (Not Run)
         51 - test-numeric (Not Run)
         52 - test-gnc-guid (Not Run)
         53 - test-kvp-value (Not Run)
         54 - test-qofsession (Not Run)
         55 - test-gnc-int128 (Not Run)
         56 - test-gnc-rational (Not Run)
         57 - test-gnc-numeric (Not Run)
         58 - test-gnc-timezone (Not Run)
         59 - test-gnc-datetime (Not Run)
         60 - test-import-map (Not Run)
         61 - test-scm-query (Failed)
         66 - test-load-c (Failed)
         67 - test-modsysver (Failed)
         68 - test-incompatdep (Failed)
         69 - test-agedver (Failed)
         70 - test-dynload (Failed)
         78 - test-link-module-tax-us (Not Run)
         79 - test-link-module-gnome-utils (Failed)
         81 - test-import-parse (Failed)
         82 - test-link-generic-import (Not Run)
         83 - test-import-pending-matches (Not Run)
         84 - test-tokenizer (Failed)
         85 - test-tx_import (Not Run)
         86 - test-link-ofx (Not Run)
         87 - test-link-qif-imp (Not Run)
         88 - test-link-module-ledger-core (Not Run)
         89 - test-link-module-register-core (Not Run)
         90 - test-link-module-register-gnome (Not Run)
         91 - test-link-module-report-locale-specific-us (Not Run)
         92 - test-link-module-report-gnome (Failed)
         94 - test-link-module-report-system (Failed)

'make test-sx' succeeded. So I looked for another test target and found 'make check':

Scanning dependencies of target test-tx_import
[ 31%] Building CXX object gnucash/import-export/csv-imp/test/CMakeFiles/test-tx_import.dir/test-tx-import.cpp.o
[ 31%] Linking CXX executable ../../../../bin/test-tx_import
...
/usr/pkg/lib/libgtest_main.a(gtest_main.cc.o): In function `main':
/scratch/devel/googletest/work/googletest-release-1.8.0/googletest/src/gtest_main.cc:36: undefined reference to `testing::InitGoogleTest(int*, char**)'
/usr/pkg/lib/libgtest_main.a(gtest_main.cc.o): In function `RUN_ALL_TESTS()':
/scratch/devel/googletest/work/googletest-release-1.8.0/googletest/include/gtest/gtest.h:2233: undefined reference to `testing::UnitTest::GetInstance()'
/scratch/devel/googletest/work/googletest-release-1.8.0/googletest/include/gtest/gtest.h:2233: undefined reference to `testing::UnitTest::Run()'
*** Error code 1

make -k check is otherwise successful and I then see:

95% tests passed, 5 tests failed out of 102

Total Test time (real) = 111.00 sec

The following tests FAILED:
          1 - test-exp-parser (Failed)
         34 - test-qof (Child aborted)
         57 - test-gnc-numeric (Failed)
         58 - test-gnc-timezone (Child aborted)
         85 - test-tx_import (Not Run)
Errors while running CTest

I'll let you decide how successful this is and if and how many bug reports I should file :)

Please document the proper way to run tests.
Btw, https://wiki.gnucash.org/wiki/Testing still mentions the autotools way to add tests (in the Legacy Tests section).
Comment 3 John Ralls 2018-04-20 10:14:08 EDT
Yes, make test just runs the tests without building them first, so unless you've already run make check the bulk of the tests are expected to fail.

The link error suggests that the installed googletest library (libgtest.so?) is missing some symbols.

For the other tests, you now need to analyze the test failures and figure out if they're bugs in GnuCash or something to do with your installation. The test output is in two files in Testing/Temporary; LastTest.log is usually the more useful. The tests can also be run individually, they're all in bin. Running in the debugger (after doing a debug build, of course) is often helpful to understanding a failure.
Comment 4 Thomas Klausner 2018-04-21 06:31:48 EDT
test-exp-parser:

# bin/test-exp-parser 
Backtrace:
In ice-9/boot-9.scm:
 160: 1 [catch #t #<catch-closure 853400> ...]
In unknown file:
   ?: 0 [apply-smob/1 #<catch-closure 853400>]

ERROR: In procedure apply-smob/1:
ERROR: In procedure primitive-load-path: Unable to find file "fin" in load path

# find . -name *fin*
...
./lib/gnucash/scm/ccache/2.0/fin.go



# bin/test-qof
...
ERROR:/archive/foreign/gnucash/libgnucash/engine/test/test-gnc-date.c:1077:test_qof_print_date_buff: assertion failed (buff == "11/23/1974"): ("11/23/74" == "11/23/1974")

Run in gdb gives:

(gdb) bt
#0  0x0000757552f1d38a in _lwp_kill () from /usr/lib/libc.so.12
#1  0x0000757552f1d017 in abort () at /disk/6/archive/foreign/src/lib/libc/stdlib/abort.c:74
#2  0x000075755467c34a in g_assertion_message (domain=domain@entry=0x0, file=file@entry=0x4289b8 "/archive/foreign/gnucash/libgnucash/engine/test/test-gnc-date.c", line=line@entry=1077, 
    func=func@entry=0x42baf0 <__func__.15696> "test_qof_print_date_buff", 
    message=message@entry=0x757556913070 "assertion failed (buff == \"11/23/1974\"): (\"11/23/74\" == \"11/23/1974\")") at gtestutils.c:2532
#3  0x000075755467cb16 in g_assertion_message_cmpstr (domain=0x0, file=0x4289b8 "/archive/foreign/gnucash/libgnucash/engine/test/test-gnc-date.c", line=1077, 
    func=0x42baf0 <__func__.15696> "test_qof_print_date_buff", expr=0x42a607 "buff == \"11/23/1974\"", arg1=<optimized out>, cmp=0x4289f8 "==", arg2=0x42a5fc "11/23/1974")
    at gtestutils.c:2610
#4  0x000000000040f40f in test_qof_print_date_buff ()
#5  0x000075755467bf2f in test_case_run (tc=0x757558033600) at gtestutils.c:2255
#6  g_test_run_suite_internal (suite=suite@entry=0x757558031f00, path=path@entry=0x0) at gtestutils.c:2339


# bin/test-gnc-numeric
...
[----------] 2 tests from gncnumeric_stream
[ RUN      ] gncnumeric_stream.output_stream
unknown file: Failure
C++ exception with description "locale::facet::_S_create_c_locale name not valid" thrown in the test body.
[  FAILED  ] gncnumeric_stream.output_stream (0 ms)
[ RUN      ] gncnumeric_stream.input_stream
[       OK ] gncnumeric_stream.input_stream (0 ms)
[----------] 2 tests from gncnumeric_stream (0 ms total)

...
[==========] 22 tests from 6 test cases ran. (29 ms total)
[  PASSED  ] 21 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] gncnumeric_stream.output_stream

 1 FAILED TEST

# bin/test-gnc-timezone
terminate called after throwing an instance of 'std::invalid_argument'
  what():  The timezone string failed to resolve to a valid filename

Run in gdb gives:
(gdb) bt
#0  0x00007079ad11d38a in _lwp_kill () from /usr/lib/libc.so.12
#1  0x00007079ad11d017 in abort () at /disk/6/archive/foreign/src/lib/libc/stdlib/abort.c:74
#2  0x00007079ae07c6fc in __gnu_cxx::__verbose_terminate_handler () at /disk/6/archive/foreign/src/external/gpl3/gcc/dist/libstdc++-v3/libsupc++/vterminate.cc:95
#3  0x00007079ae085d20 in __cxxabiv1::__terminate (handler=<optimized out>) at /disk/6/archive/foreign/src/external/gpl3/gcc/dist/libstdc++-v3/libsupc++/eh_terminate.cc:47
#4  0x00007079ae085d7a in std::terminate () at /disk/6/archive/foreign/src/external/gpl3/gcc/dist/libstdc++-v3/libsupc++/eh_terminate.cc:57
#5  0x00007079ae085ccd in __cxxabiv1::__cxa_throw (obj=0x7079b134d2f0, tinfo=0x6ae338 <typeinfo for std::invalid_argument@@GLIBCXX_3.4>, 
    dest=0x4457b0 <std::invalid_argument::~invalid_argument()@plt>) at /disk/6/archive/foreign/src/external/gpl3/gcc/dist/libstdc++-v3/libsupc++/eh_throw.cc:87
#6  0x000000000044676d in IANAParser::find_tz_file(std::string const&) ()
#7  0x0000000000471f76 in IANAParser::IANAParser::IANAParser(std::string const&) ()
#8  0x0000000000447a0f in TimeZoneProvider::parse_file(std::string const&) ()
#9  0x0000000000448294 in TimeZoneProvider::construct(std::string const&) ()
#10 0x0000000000448438 in TimeZoneProvider::TimeZoneProvider(std::string const&) ()
#11 0x0000000000484c69 in TimeZoneProvider::TimeZoneProvider() ()
#12 0x00007079b19b0370 in __static_initialization_and_destruction_0 () from /archive/foreign/gnucash/build/lib/gnucash/libgncmod-engine.so
#13 0x00007079b19b0757 in _GLOBAL__sub_I_gnc_datetime.cpp () from /archive/foreign/gnucash/build/lib/gnucash/libgncmod-engine.so
Comment 5 Thomas Klausner 2018-04-21 06:32:31 EDT
(The automatic trace detector put some non-trace information in the trace attachment.)
Comment 6 John Ralls 2018-04-21 10:00:17 EDT
For the first, before the backtrace there will be a dump of the command. Two variables in that dump are significant, GUILE_LOAD_PATH and GUILE_LOAD_COMPILED_PATH. What are they set to?

For the second, your distro has borked boost::date_time to return the wrong value for the date formatting parameter %Y, returning a 2-digit year instead of the specified 4-digit year. No need of a backtrace, the test result tells you exactly what's wrong.
Comment 7 Thomas Klausner 2018-04-21 10:49:56 EDT
For test-exp-parser: No, I pasted the complete output of starting it from the commandline directly. Should I manually set up some environment variables?


As for the second, if printing %Y was broken, all the tests would fail, not just this one, so it must be something else, perhaps locale-related.
Comment 8 John Ralls 2018-04-21 11:41:36 EDT
Yeah, the expression parser is in Scheme so it needs guile and guile needs some help finding its pieces, particularly in the build environment. The easiest way to get there is to copy the command from LastTest.log.

Ah, good point, though not "all the tests" because that's a glib test and it stops at the first failure, but it would have failed much earlier. You're right, that test is of the date format set by the locale. In that particular case it comes from /usr/share/locale/en_US/LC_TIME. On MacOS (what I have handy at the moment) it's %m/%d/%Y. That seems pretty common, but the 2.6 version of the test, which used GLib's GDateTime class, used g_date_time_format() to get the comparison value instead of hard-coding it. The test program is C rather than C++ and I took the lazy way by hard-coding the string since it works on the Linux distros that we test against as well as MacOS. I'll have to find a less-lazy way to generate the expected string.
Comment 9 John Ralls 2018-04-21 11:45:12 EDT
Back to test-tx_import: All of the other google-test based tests compiled OK and most passed, so something's up with that one test. Does <builddir>/common/test-core/libgtest.a exist?
Comment 10 Thomas Klausner 2018-04-22 02:40:02 EDT
Ah, sorry. I didn't follow your advice for looking at LastTest.log earlier.
Here's the output for test-exp-parser from that file:


1/102 Testing: test-exp-parser
1/102 Test: test-exp-parser
Command: "/usr/pkg/bin/cmake" "-E" "env" "GNC_UNINSTALLED=YES" "GNC_BUILDDIR=/archive/foreign/gnucash/build" "GNC_UNINSTALLED=yes" "GNC_BUILDDIR=/archive/foreign/gnucash/build" "GUILE_WARN_DEPRECATED=no" "LD_LIBRARY_PATH=/archive/foreign/gnucash/build/lib:/archive/foreign/gnucash/build/lib/gnucash" "GNC_MODULE_PATH=/archive/foreign/gnucash/build/lib:/archive/foreign/gnucash/build/lib/gnucash" "GUILE=/usr/pkg/bin/guile" "GUILE_LOAD_COMPILED_PATH=/archive/foreign/gnucash/build/lib/gnucash/scm/ccache/2.0" "GUILE_LOAD_PATH=/archive/foreign/gnucash/libgnucash/app-utils/test/mod-foo:/archive/foreign/gnucash/libgnucash/app-utils/test/mod-bar:/archive/foreign/gnucash/libgnucash/app-utils/test/mod-baz" "/archive/foreign/gnucash/build/bin/test-exp-parser"
Directory: /archive/foreign/gnucash/build/libgnucash/app-utils/test
"test-exp-parser" start time: Apr 20 08:55 CEST
Output:
----------------------------------------------------------
FAILURE bad expression /archive/foreign/gnucash/libgnucash/app-utils/test/test-exp-parser.c:161 wrong offset; expected 2, got 4
FAILURE bad expression /archive/foreign/gnucash/libgnucash/app-utils/test/test-exp-parser.c:162 wrong offset; expected 0, got 4

(process:21881): qof-WARNING **: 08:55:41.132: [gnc_numeric_div()] Divide by 0.
<CRITICAL> (gnc.gui) [func_op()] function eval error: [In ice-9/boot-9.scm:
 160: 6 [catch #t #<catch-closure 849a60> ...]
In unknown file:
   ?: 5 [apply-smob/1 #<catch-closure 849a60>]
In ice-9/eval.scm:
 432: 4 [eval # #]
In ice-9/boot-9.scm:
 160: 3 [catch #t #<procedure ab4c90 at ice-9/eval.scm:416:20 ()> ...]
In ice-9/eval.scm:
 432: 2 [eval # #]
 436: 1 [eval # #]
In unknown file:
   ?: 0 [+ "three" 0]

ERROR: In procedure +: Wrong type argument in position 1: "three"
]

Executed 57 tests. There were 2 failures.
<end of output>
Test time =   1.00 sec
----------------------------------------------------------
Test Failed.
"test-exp-parser" end time: Apr 20 08:55 CEST
"test-exp-parser" time elapsed: 00:00:01
----------------------------------------------------------

As for test-tx_import:
The file does not exist, no.
Comment 11 Geert Janssens 2019-05-25 06:50:10 EDT
There have been several bug fixes in our build system. What's the current status of this issue ?
Which tests continue to fail when run under current maint ?

By the way I have recently found a more interesting way to run individual tests:
ctest -V -R <test-name>

That will ensure the test is run in the proper environment. -V will print more details while testing
Comment 12 Thomas Klausner 2019-07-08 09:54:38 EDT
With today's maint HEAD I see, using "cmake -DWITH_AQBANKING=OFF -DALLOW_OLD_GETTEXT=ON  -DWITH_SQL=OFF -DGUILE_EXECUTABLE=/usr/pkg/guile/2.2/bin/guile  -DGUILD_EXECUTABLE=/usr/pkg/guile/2.2/bin/guild ..":

96% tests passed, 5 tests failed out of 116

The following tests FAILED:
          1 - test-exp-parser (Failed)
         32 - test-qof (Child aborted)
         55 - test-gnc-numeric (Failed)
         56 - test-gnc-timezone (Child aborted)
         84 - test-tx_import (Not Run)


1:

ctest -V -R test-exp-parser 
UpdateCTestConfiguration  from :/archive/foreign/gnucash/build/DartConfiguration.tcl
UpdateCTestConfiguration  from :/archive/foreign/gnucash/build/DartConfiguration.tcl
Test project /archive/foreign/gnucash/build
Constructing a list of tests
Done constructing a list of tests
Updating test list for fixtures
Added 0 tests to meet fixture requirements
Checking test dependency graph...
Checking test dependency graph end
test 1
    Start 1: test-exp-parser

1: Test command: /usr/pkg/bin/cmake "-E" "env" "GNC_UNINSTALLED=YES;GNC_BUILDDIR=/archive/foreign/gnucash/build;GNC_UNINSTALLED=yes;GNC_BUILDDIR=/archive/foreign/gnucash/build;LD_LIBRARY_PATH=/archive/foreign/gnucash/build/lib:/archive/foreign/gnucash/build/lib/gnucash;GNC_MODULE_PATH=/archive/foreign/gnucash/build/lib:/archive/foreign/gnucash/build/lib/gnucash;GUILE=/usr/pkg/guile/2.2/bin/guile;GUILE_LOAD_COMPILED_PATH=/archive/foreign/gnucash/build/lib/gnucash/scm/ccache/2.2;GUILE_LOAD_PATH=/archive/foreign/gnucash/libgnucash/app-utils/test/mod-foo:/archive/foreign/gnucash/libgnucash/app-utils/test/mod-bar:/archive/foreign/gnucash/libgnucash/app-utils/test/mod-baz;" "/archive/foreign/gnucash/build/bin/test-exp-parser"
1: Environment variables: 
1:  GNC_UNINSTALLED=YES
1:  GNC_BUILDDIR=/archive/foreign/gnucash/build
1:  GNC_UNINSTALLED=yes
1:  GNC_BUILDDIR=/archive/foreign/gnucash/build
1:  LD_LIBRARY_PATH=/archive/foreign/gnucash/build/lib:/archive/foreign/gnucash/build/lib/gnucash
1:  GNC_MODULE_PATH=/archive/foreign/gnucash/build/lib:/archive/foreign/gnucash/build/lib/gnucash
1:  GUILE=/usr/pkg/guile/2.2/bin/guile
1:  GUILE_LOAD_COMPILED_PATH=/archive/foreign/gnucash/build/lib/gnucash/scm/ccache/2.2
1:  GUILE_LOAD_PATH=/archive/foreign/gnucash/libgnucash/app-utils/test/mod-foo:/archive/foreign/gnucash/libgnucash/app-utils/test/mod-bar:/archive/foreign/gnucash/libgnucash/app-utils/test/mod-baz
1: Test timeout computed to be: 10000000
1: FAILURE bad expression /archive/foreign/gnucash/libgnucash/app-utils/test/test-exp-parser.c:161 wrong offset; expected 2, got 4
1: FAILURE bad expression /archive/foreign/gnucash/libgnucash/app-utils/test/test-exp-parser.c:162 wrong offset; expected 0, got 4
1: 
1: (process:23229): qof-WARNING **: 15:51:40.533: [gnc_numeric_div()] Divide by 0.
1: <CRITICAL> (gnc.gui) [func_op()] function eval error: [ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZH�B�{]
1: 
1: Executed 57 tests. There were 2 failures.
1/1 Test #1: test-exp-parser ..................***Failed    0.18 sec

0% tests passed, 1 tests failed out of 1

Total Test time (real) =   0.21 sec

The following tests FAILED:
          1 - test-exp-parser (Failed)
Errors while running CTest

32:
...
32: ERROR:/archive/foreign/gnucash/libgnucash/engine/test/test-gnc-date.c:880:test_qof_print_date_buff: assertion failed (buff == "11/23/1974"): ("11/23/74" == "11/23/1974")
...

55:

55: C++ exception with description "locale::facet::_S_create_c_locale name not valid" thrown in the test body.

I see a similar problem in other boost using applications on NetBSD as well.


56:

ctest -V -R test-gnc-timezone
UpdateCTestConfiguration  from :/archive/foreign/gnucash/build/DartConfiguration.tcl
UpdateCTestConfiguration  from :/archive/foreign/gnucash/build/DartConfiguration.tcl
Test project /archive/foreign/gnucash/build
Constructing a list of tests
Done constructing a list of tests
Updating test list for fixtures
Added 0 tests to meet fixture requirements
Checking test dependency graph...
Checking test dependency graph end
test 56
    Start 56: test-gnc-timezone

56: Test command: /archive/foreign/gnucash/build/bin/test-gnc-timezone
56: Environment variables: 
56:  GNC_UNINSTALLED=YES
56:  GNC_BUILDDIR=/archive/foreign/gnucash/build
56: Test timeout computed to be: 10000000
56: terminate called after throwing an instance of 'std::invalid_argument'
56:   what():  The timezone string failed to resolve to a valid filename
1/1 Test #56: test-gnc-timezone ................Child aborted***Exception:   0.04 sec

0% tests passed, 1 tests failed out of 1

Total Test time (real) =   0.07 sec

The following tests FAILED:
         56 - test-gnc-timezone (Child aborted)
Errors while running CTest



84:

[ 57%] Linking CXX executable ../../../../bin/test-tx_import
ld: /usr/pkg/lib/libgtest_main.a(gtest_main.cc.o): in function `main':
/scratch/devel/googletest/work/googletest-release-1.8.1/googletest/src/gtest_main.cc:35: undefined reference to `testing::InitGoogleTest(int*, char**)'
ld: /usr/pkg/lib/libgtest_main.a(gtest_main.cc.o): in function `RUN_ALL_TESTS()':
/scratch/devel/googletest/work/googletest-release-1.8.1/googletest/include/gtest/gtest.h:2341: undefined reference to `testing::UnitTest::GetInstance()'
ld: /scratch/devel/googletest/work/googletest-release-1.8.1/googletest/include/gtest/gtest.h:2341: undefined reference to `testing::UnitTest::Run()'
*** Error code 1

Hope this helps!
Comment 13 John Ralls 2019-07-08 22:43:38 EDT
The first one is going to take some debugging. The expression parser is supposed to indicate the position of the invalid character (the ç) but it's indicating the end of the string instead. Since it works on all of the OSes we regularly build on I'm afraid it's up to you to debug it on NetBSD.

Looks like NetBSD's nl_langinfo returns %y instead of %Y for US date format and that test doesn't account for the possibility.

The locale exception seems like a hole in the C++ standard library. Does NetBSD have its own or does it use gcc's? It would be helpful to have a stack trace (ideally with debug symbols) for both that and the gnc-timezone exception.

The link failure in test-tx_import is puzzling. Try building it with VERBOSE=1 to see the command line (if you'd use ninja it would do that for you without being asked and generally be faster).
Comment 14 Thomas Klausner 2019-07-20 10:08:45 EDT
When I run 'ninja check' in a loop until I get at the end:

ninja check
[2/3] Linking CXX executable bin/test-tx_import
FAILED: bin/test-tx_import 
: && /usr/bin/c++  -Wno-error=deprecated-declarations -Wno-register -Werror -Wall -Wmissing-declarations -Wno-unused -Wno-error=parentheses -std=gnu++11   gnucash/import-export/csv-imp/test/CMakeFiles/test-tx_import.dir/test-tx-import.cpp.o  -o bin/test-tx_import  -Wl,-rpath,/disk/6/archive/foreign/gnucash/build/lib/gnucash:/disk/6/archive/foreign/gnucash/build/lib:/usr/pkg/lib lib/gnucash/libgncmod-csv-import.so -lintl -Wl,-R/usr/pkg/lib -L/usr/pkg/lib -lglib-2.0 /usr/pkg/lib/libgtest.a /usr/pkg/lib/libgtest_main.a -licui18n -licuuc -licudata lib/gnucash/libgncmod-generic-import.so lib/gnucash/libgncmod-gnome-utils.so -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 lib/libgnc-backend-xml-utils.so -lsecret-1 lib/gnucash/libgncmod-app-utils.so -lgio-2.0 -lxslt -llzma -lm -lxml2 -lz lib/gnucash/libgncmod-engine.so lib/libgnc-core-utils.so /usr/pkg/lib/libboost_date_time.so /usr/pkg/lib/libboost_regex.so /usr/pkg/lib/libboost_locale.so /usr/pkg/lib/libboost_filesystem.so /usr/pkg/lib/libboost_system.so -lgobject-2.0 lib/libgnc-module.so -Wl,-R/usr/pkg/lib -L/usr/pkg/lib -Wl,--export-dynamic -pthread -lgmodule-2.0 -lintl -lglib-2.0 -Wl,-R/usr/pkg/guile/2.2/lib -L/usr/pkg/guile/2.2/lib -lguile-2.2 -lgc && :
ld: /usr/pkg/guile/2.2/lib/libguile-2.2.so: warning: warning: tmpnam() possibly used unsafely, use mkstemp() or mkdtemp()
ld: lib/libgnc-backend-xml-utils.so: warning: warning: mktemp() possibly used unsafely, use mkstemp() or mkdtemp()
ld: /usr/pkg/lib/libgtest_main.a(gtest_main.cc.o): in function `main':
/scratch/devel/googletest/work/googletest-release-1.8.1/googletest/src/gtest_main.cc:35: undefined reference to `testing::InitGoogleTest(int*, char**)'
ld: /usr/pkg/lib/libgtest_main.a(gtest_main.cc.o): in function `RUN_ALL_TESTS()':
/scratch/devel/googletest/work/googletest-release-1.8.1/googletest/include/gtest/gtest.h:2341: undefined reference to `testing::UnitTest::GetInstance()'
ld: /scratch/devel/googletest/work/googletest-release-1.8.1/googletest/include/gtest/gtest.h:2341: undefined reference to `testing::UnitTest::Run()'

Is something wrong with the googletest package?

NetBSD does have its own locale implementation, related but not identical to the FreeBSD one.

Here's the backtrace for test-gnc-timezone:

(gdb) bt
#0  0x0000757868d99a9a in _lwp_kill () from /usr/lib/libc.so.12
#1  0x0000757868d99749 in abort () at /disk/6/archive/foreign/src/lib/libc/stdlib/abort.c:74
#2  0x000075786a0b37b7 in __gnu_cxx::__verbose_terminate_handler () at /disk/6/archive/foreign/src/external/gpl3/gcc/dist/libstdc++-v3/libsupc++/vterminate.cc:95
#3  0x000075786a0bcef7 in __cxxabiv1::__terminate (handler=<optimized out>) at /disk/6/archive/foreign/src/external/gpl3/gcc/dist/libstdc++-v3/libsupc++/eh_terminate.cc:47
#4  0x000075786a0bcf51 in std::terminate () at /disk/6/archive/foreign/src/external/gpl3/gcc/dist/libstdc++-v3/libsupc++/eh_terminate.cc:57
#5  0x000075786a0bcea4 in __cxxabiv1::__cxa_throw (obj=<optimized out>, tinfo=0x6d5618 <typeinfo for std::invalid_argument@@GLIBCXX_3.4>, dest=0x459800 <std::invalid_argument::~invalid_argument()@plt>)
    at /disk/6/archive/foreign/src/external/gpl3/gcc/dist/libstdc++-v3/libsupc++/eh_throw.cc:93
#6  0x000000000045aa77 in IANAParser::find_tz_file(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
#7  0x0000000000489d3a in IANAParser::IANAParser::IANAParser(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
#8  0x000000000045bd31 in TimeZoneProvider::parse_file(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
#9  0x000000000045c5ca in TimeZoneProvider::construct(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
#10 0x000000000045c776 in TimeZoneProvider::TimeZoneProvider(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
#11 0x000000000049dbaf in TimeZoneProvider::TimeZoneProvider() ()
#12 0x000075786d9cc9b5 in __static_initialization_and_destruction_0(int, int) () from /disk/6/archive/foreign/gnucash/build/lib/gnucash/libgncmod-engine.so
#13 0x000075786d9ccdff in _GLOBAL__sub_I_gnc_datetime.cpp () from /disk/6/archive/foreign/gnucash/build/lib/gnucash/libgncmod-engine.so
#14 0x000075786d976dfc in ?? () from /disk/6/archive/foreign/gnucash/build/lib/gnucash/libgncmod-engine.so
#15 0x000075786ddf3400 in ?? ()
#16 0x000075786d95afd9 in _init () from /disk/6/archive/foreign/gnucash/build/lib/gnucash/libgncmod-engine.so
#17 0x0000000000000000 in ?? ()

There is no backtrace for test-gnc-timezone because it does not stop when it throws the fault:

(gdb) r
Starting program: /disk/6/archive/foreign/gnucash/build/bin/test-gnc-numeric 
Running main() from /scratch/devel/googletest/work/googletest-release-1.8.1/googletest/src/gtest_main.cc
[==========] Running 22 tests from 6 test cases.
[----------] Global test environment set-up.
[----------] 7 tests from gncnumeric_constructors
[ RUN      ] gncnumeric_constructors.test_default_constructor
[       OK ] gncnumeric_constructors.test_default_constructor (0 ms)
[ RUN      ] gncnumeric_constructors.test_gnc_rational_constructor
[       OK ] gncnumeric_constructors.test_gnc_rational_constructor (0 ms)
[ RUN      ] gncnumeric_constructors.test_gnc_numeric_constructor
[       OK ] gncnumeric_constructors.test_gnc_numeric_constructor (0 ms)
[ RUN      ] gncnumeric_constructors.test_int64_constructor
[       OK ] gncnumeric_constructors.test_int64_constructor (0 ms)
[ RUN      ] gncnumeric_constructors.test_implicit_int_constructor
[       OK ] gncnumeric_constructors.test_implicit_int_constructor (0 ms)
[ RUN      ] gncnumeric_constructors.test_double_constructor
[       OK ] gncnumeric_constructors.test_double_constructor (1 ms)
[ RUN      ] gncnumeric_constructors.test_string_constructor
[       OK ] gncnumeric_constructors.test_string_constructor (3 ms)
[----------] 7 tests from gncnumeric_constructors (4 ms total)

[----------] 1 test from gncnumeric_output
[ RUN      ] gncnumeric_output.string_output
[       OK ] gncnumeric_output.string_output (0 ms)
[----------] 1 test from gncnumeric_output (0 ms total)

[----------] 2 tests from gncnumeric_stream
[ RUN      ] gncnumeric_stream.output_stream
unknown file: Failure
C++ exception with description "locale::facet::_S_create_c_locale name not valid" thrown in the test body.
[  FAILED  ] gncnumeric_stream.output_stream (0 ms)
[ RUN      ] gncnumeric_stream.input_stream
[       OK ] gncnumeric_stream.input_stream (0 ms)
[----------] 2 tests from gncnumeric_stream (0 ms total)

[----------] 6 tests from gncnumeric_operators
[ RUN      ] gncnumeric_operators.gnc_numeric_conversion
[       OK ] gncnumeric_operators.gnc_numeric_conversion (0 ms)
[ RUN      ] gncnumeric_operators.double_conversion
[       OK ] gncnumeric_operators.double_conversion (0 ms)
[ RUN      ] gncnumeric_operators.test_addition
[       OK ] gncnumeric_operators.test_addition (0 ms)
[ RUN      ] gncnumeric_operators.test_subtraction
[       OK ] gncnumeric_operators.test_subtraction (0 ms)
[ RUN      ] gncnumeric_operators.test_multiplication
[       OK ] gncnumeric_operators.test_multiplication (1 ms)
[ RUN      ] gncnumeric_operators.test_division
[       OK ] gncnumeric_operators.test_division (0 ms)
[----------] 6 tests from gncnumeric_operators (1 ms total)

[----------] 4 tests from gncnumeric_functions
[ RUN      ] gncnumeric_functions.test_cmp
[       OK ] gncnumeric_functions.test_cmp (0 ms)
[ RUN      ] gncnumeric_functions.test_invert
[       OK ] gncnumeric_functions.test_invert (0 ms)
[ RUN      ] gncnumeric_functions.test_reduce
[       OK ] gncnumeric_functions.test_reduce (0 ms)
[ RUN      ] gncnumeric_functions.test_convert
[       OK ] gncnumeric_functions.test_convert (0 ms)
[----------] 4 tests from gncnumeric_functions (0 ms total)

[----------] 2 tests from gnc_numeric_functions
[ RUN      ] gnc_numeric_functions.test_is_decimal
[       OK ] gnc_numeric_functions.test_is_decimal (0 ms)
[ RUN      ] gnc_numeric_functions.test_conversion_to_decimal
[       OK ] gnc_numeric_functions.test_conversion_to_decimal (0 ms)
[----------] 2 tests from gnc_numeric_functions (0 ms total)

[----------] Global test environment tear-down
[==========] 22 tests from 6 test cases ran. (6 ms total)
[  PASSED  ] 21 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] gncnumeric_stream.output_stream

 1 FAILED TEST
[Inferior 1 (process 4732) exited with code 01]

Can you point me to the relevant code for the exp-parser issue?

Is nl_langinfo() %y/%Y a bug compared to a standard (link?) or just an unexpected non-standardized difference?
Comment 15 John Ralls 2019-07-20 11:36:16 EDT
GTest: Looks like the libraries are linked in the wrong order, with libgtest.a before libgtest-main.a. That's controlled by ${GTEST_LIB}, used everywhere. It doesn't make sense that it would break in just that one test.

The expression parser code is in libgnucash/app-utils/gnc-expparser.c

You'll need a debug build to figure that out as well as for the gnc-timezone and gnc-numeric exceptions.

For the gnc-timezone exception we need to know what file it tried to open, so rather than another backtrace go to the find_tz_file frame (it was 6 in the backtrace above) and look at the contents of tzname. If it's a relative path, maybe $TZDIR isn't set or is wrong in your environment, so check that. See if you can find the tz file.

The gnc-numeric failure may be because that test tries to set fr_FR.UTF8 as the locale.   Set a breakpoint on gtest-gnc-numeric.cpp line 213 and when that's hit set another on __cxa_throw. That will stop on the throw. Note that there might be two; if NetBSD doesn't define fr_FR.utf8 it will throw once and catch it; if it also doesn't define fr_FR it will throw again from the catch. Note that C++ localization is somewhat separate from C localization, which might explain why the localization tests for test-gnc-numeric.c pass and this one throws.
Comment 16 Thomas Klausner 2019-07-20 14:41:55 EDT
Reversing the library order fixes a test, so please switch these two around (for whatever reason that improves tests...).

diff --git a/common/cmake_modules/GncAddTest.cmake b/common/cmake_modules/GncAddTest.cmake
index 10151eaf0..b5f4162f3 100644
--- a/common/cmake_modules/GncAddTest.cmake
+++ b/common/cmake_modules/GncAddTest.cmake
@@ -126,7 +126,7 @@ function(gnc_gtest_configure)
     find_package(Threads REQUIRED)
     set(GTEST_FOUND YES CACHE INTERNAL "Found GTest")
     if(GTEST_SHARED_LIB)
-      set(GTEST_LIB "${GTEST_SHARED_LIB};${GTEST_MAIN_LIB}" PARENT_SCOPE)
+      set(GTEST_LIB "${GTEST_MAIN_LIB};${GTEST_SHARED_LIB}" PARENT_SCOPE)
       unset(GTEST_SRC_DIR CACHE)
     else()
       set(GTEST_SRC "${GTEST_SRC_DIR}/src/gtest_main.cc" PARENT_SCOPE)

gives

The following tests FAILED:
          1 - test-exp-parser (Failed)
         32 - test-qof (Child aborted)
         55 - test-gnc-numeric (Failed)
         56 - test-gnc-timezone (Child aborted)


With 'CXXFLAGS="-g -O0" CFLAGS="-g -O0"' more tests fail, but I'll ignore that for now.

test-gnc-numeric:

Breakpoint 2, gncnumeric_stream_output_stream_Test::TestBody (this=0x798176ca1620) at ../libgnucash/engine/test/gtest-gnc-numeric.cpp:213
213         EXPECT_EQ("123/456", output.str());
(gdb) br __cxa_throw
Breakpoint 3 at 0x7981742bce61: file /disk/6/archive/foreign/src/external/gpl3/gcc/dist/libstdc++-v3/libsupc++/eh_throw.cc, line 75.
(gdb) c
Continuing.

Breakpoint 3, __cxxabiv1::__cxa_throw (obj=obj@entry=0x798176c803a0, tinfo=0x768740 <typeinfo for std::runtime_error@@GLIBCXX_3.4>, dest=0x7981742b3360 <std::runtime_error::~runtime_error()>)
    at /disk/6/archive/foreign/src/external/gpl3/gcc/dist/libstdc++-v3/libsupc++/eh_throw.cc:75
75      {
(gdb) bt
#0  __cxxabiv1::__cxa_throw (obj=obj@entry=0x798176c803a0, tinfo=0x768740 <typeinfo for std::runtime_error@@GLIBCXX_3.4>, dest=0x7981742b3360 <std::runtime_error::~runtime_error()>)
    at /disk/6/archive/foreign/src/external/gpl3/gcc/dist/libstdc++-v3/libsupc++/eh_throw.cc:75
#1  0x00007981742b21d5 in std::__throw_runtime_error (__s=__s@entry=0x79817433bdc8 "locale::facet::_S_create_c_locale name not valid")
    at /disk/6/archive/foreign/src/external/gpl3/gcc/dist/libstdc++-v3/src/c++11/functexcept.cc:102
#2  0x00007981742b1da7 in std::locale::facet::_S_create_c_locale (__cloc=@0x7f7fff75df30: 0x0, __s=<optimized out>, __s@entry=0x531298 "fr_FR.utf8") at c++locale.cc:227
#3  0x0000798174296785 in std::locale::_Impl::_Impl (this=0x798176c9ab70, __s=0x531298 "fr_FR.utf8", __refs=<optimized out>)
    at /disk/6/archive/foreign/src/external/gpl3/gcc/dist/libstdc++-v3/src/c++98/localename.cc:186
#4  0x000079817429730e in std::locale::locale (this=0x7f7fff75e098, __s=<optimized out>) at /disk/6/archive/foreign/src/external/gpl3/gcc/dist/libstdc++-v3/src/c++98/localename.cc:43
#5  0x00000000004b561d in gncnumeric_stream_output_stream_Test::TestBody (this=0x798176ca1620) at ../libgnucash/engine/test/gtest-gnc-numeric.cpp:216
#6  0x00000000005263e1 in testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void> (location=0x535850 "the test body", method=<optimized out>, object=0x798176ca1620)
    at /scratch/devel/googletest/work/googletest-release-1.8.1/googletest/src/gtest.cc:2443
#7  testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void> (object=object@entry=0x798176ca1620, method=<optimized out>, location=location@entry=0x535850 "the test body")
    at /scratch/devel/googletest/work/googletest-release-1.8.1/googletest/src/gtest.cc:2479
#8  0x00000000004e35cc in testing::Test::Run (this=this@entry=0x798176ca1620) at /scratch/devel/googletest/work/googletest-release-1.8.1/googletest/src/gtest.cc:2517
#9  0x00000000004e387b in testing::Test::Run (this=0x798176ca1620) at /scratch/devel/googletest/work/googletest-release-1.8.1/googletest/src/gtest.cc:2509
#10 testing::TestInfo::Run (this=0x798176c3cb40) at /scratch/devel/googletest/work/googletest-release-1.8.1/googletest/src/gtest.cc:2693
#11 0x00000000004e3a39 in testing::TestInfo::Run (this=<optimized out>) at /scratch/devel/googletest/work/googletest-release-1.8.1/googletest/src/gtest.cc:2668
#12 testing::TestCase::Run (this=0x798176c99a00) at /scratch/devel/googletest/work/googletest-release-1.8.1/googletest/src/gtest.cc:2811
#13 0x00000000004e3fe9 in testing::TestCase::Run (this=<optimized out>) at /scratch/devel/googletest/work/googletest-release-1.8.1/googletest/src/gtest.cc:2797
#14 testing::internal::UnitTestImpl::RunAllTests (this=0x798176c30000) at /scratch/devel/googletest/work/googletest-release-1.8.1/googletest/src/gtest.cc:5177
#15 0x00000000005268f1 in testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> (location=0x537ac8 "auxiliary test code (environments or event listeners)",
    method=<optimized out>, object=0x798176c30000) at /scratch/devel/googletest/work/googletest-release-1.8.1/googletest/src/gtest.cc:2443
#16 testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> (object=0x798176c30000, method=<optimized out>,
    location=location@entry=0x537ac8 "auxiliary test code (environments or event listeners)") at /scratch/devel/googletest/work/googletest-release-1.8.1/googletest/src/gtest.cc:2479
#17 0x00000000004e4209 in testing::UnitTest::Run (this=0x76a940 <testing::UnitTest::GetInstance()::instance>) at /scratch/devel/googletest/work/googletest-release-1.8.1/googletest/src/gtest.cc:4786
#18 0x00000000004e5f30 in RUN_ALL_TESTS () at /scratch/devel/googletest/work/googletest-release-1.8.1/googletest/include/gtest/gtest.h:2341
#19 main (argc=<optimized out>, argv=0x7f7fff75e868) at /scratch/devel/googletest/work/googletest-release-1.8.1/googletest/src/gtest_main.cc:36
(gdb) c            
Continuing.

Breakpoint 3, __cxxabiv1::__cxa_throw (obj=obj@entry=0x798176c80440, tinfo=0x768740 <typeinfo for std::runtime_error@@GLIBCXX_3.4>, dest=0x7981742b3360 <std::runtime_error::~runtime_error()>)
    at /disk/6/archive/foreign/src/external/gpl3/gcc/dist/libstdc++-v3/libsupc++/eh_throw.cc:75
75      {
(gdb) bt
#0  __cxxabiv1::__cxa_throw (obj=obj@entry=0x798176c80440, tinfo=0x768740 <typeinfo for std::runtime_error@@GLIBCXX_3.4>, dest=0x7981742b3360 <std::runtime_error::~runtime_error()>)
    at /disk/6/archive/foreign/src/external/gpl3/gcc/dist/libstdc++-v3/libsupc++/eh_throw.cc:75
#1  0x00007981742b21d5 in std::__throw_runtime_error (__s=__s@entry=0x79817433bdc8 "locale::facet::_S_create_c_locale name not valid")
    at /disk/6/archive/foreign/src/external/gpl3/gcc/dist/libstdc++-v3/src/c++11/functexcept.cc:102
#2  0x00007981742b1da7 in std::locale::facet::_S_create_c_locale (__cloc=@0x7f7fff75df30: 0x0, __s=<optimized out>, __s@entry=0x5312e0 "fr_FR") at c++locale.cc:227
#3  0x0000798174296785 in std::locale::_Impl::_Impl (this=0x798176c9ab70, __s=0x5312e0 "fr_FR", __refs=<optimized out>)
    at /disk/6/archive/foreign/src/external/gpl3/gcc/dist/libstdc++-v3/src/c++98/localename.cc:186
#4  0x000079817429730e in std::locale::locale (this=0x7f7fff75e418, __s=<optimized out>) at /disk/6/archive/foreign/src/external/gpl3/gcc/dist/libstdc++-v3/src/c++98/localename.cc:43
#5  0x00000000004b5e2d in gncnumeric_stream_output_stream_Test::TestBody (this=0x798176ca1620) at ../libgnucash/engine/test/gtest-gnc-numeric.cpp:228
#6  0x00000000005263e1 in testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void> (location=0x535850 "the test body", method=<optimized out>, object=0x798176ca1620)
    at /scratch/devel/googletest/work/googletest-release-1.8.1/googletest/src/gtest.cc:2443
#7  testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void> (object=object@entry=0x798176ca1620, method=<optimized out>, location=location@entry=0x535850 "the test body")
    at /scratch/devel/googletest/work/googletest-release-1.8.1/googletest/src/gtest.cc:2479
#8  0x00000000004e35cc in testing::Test::Run (this=this@entry=0x798176ca1620) at /scratch/devel/googletest/work/googletest-release-1.8.1/googletest/src/gtest.cc:2517
#9  0x00000000004e387b in testing::Test::Run (this=0x798176ca1620) at /scratch/devel/googletest/work/googletest-release-1.8.1/googletest/src/gtest.cc:2509
#10 testing::TestInfo::Run (this=0x798176c3cb40) at /scratch/devel/googletest/work/googletest-release-1.8.1/googletest/src/gtest.cc:2693
#11 0x00000000004e3a39 in testing::TestInfo::Run (this=<optimized out>) at /scratch/devel/googletest/work/googletest-release-1.8.1/googletest/src/gtest.cc:2668
#12 testing::TestCase::Run (this=0x798176c99a00) at /scratch/devel/googletest/work/googletest-release-1.8.1/googletest/src/gtest.cc:2811
#13 0x00000000004e3fe9 in testing::TestCase::Run (this=<optimized out>) at /scratch/devel/googletest/work/googletest-release-1.8.1/googletest/src/gtest.cc:2797
#14 testing::internal::UnitTestImpl::RunAllTests (this=0x798176c30000) at /scratch/devel/googletest/work/googletest-release-1.8.1/googletest/src/gtest.cc:5177
#15 0x00000000005268f1 in testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> (location=0x537ac8 "auxiliary test code (environments or event listeners)", 
    method=<optimized out>, object=0x798176c30000) at /scratch/devel/googletest/work/googletest-release-1.8.1/googletest/src/gtest.cc:2443
#16 testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> (object=0x798176c30000, method=<optimized out>, 
    location=location@entry=0x537ac8 "auxiliary test code (environments or event listeners)") at /scratch/devel/googletest/work/googletest-release-1.8.1/googletest/src/gtest.cc:2479
#17 0x00000000004e4209 in testing::UnitTest::Run (this=0x76a940 <testing::UnitTest::GetInstance()::instance>) at /scratch/devel/googletest/work/googletest-release-1.8.1/googletest/src/gtest.cc:4786
#18 0x00000000004e5f30 in RUN_ALL_TESTS () at /scratch/devel/googletest/work/googletest-release-1.8.1/googletest/include/gtest/gtest.h:2341
#19 main (argc=<optimized out>, argv=0x7f7fff75e868) at /scratch/devel/googletest/work/googletest-release-1.8.1/googletest/src/gtest_main.cc:36
(gdb) c
Continuing.
unknown file: Failure
C++ exception with description "locale::facet::_S_create_c_locale name not valid" thrown in the test body.
[  FAILED  ] gncnumeric_stream.output_stream (194827 ms)

iconv -l doesn't list them, but /usr/share/locale/ has:

/usr/share/locale/fr
/usr/share/locale/fr_BE.ISO8859-1
/usr/share/locale/fr_BE.ISO8859-15
/usr/share/locale/fr_BE.UTF-8
/usr/share/locale/fr_CA.ISO8859-1
/usr/share/locale/fr_CA.ISO8859-15
/usr/share/locale/fr_CA.UTF-8
/usr/share/locale/fr_CH.ISO8859-1
/usr/share/locale/fr_CH.ISO8859-15
/usr/share/locale/fr_CH.UTF-8
/usr/share/locale/fr_FR.ISO8859-1
/usr/share/locale/fr_FR.ISO8859-15
/usr/share/locale/fr_FR.UTF-8

so either of those should supposedly work.

As for test-gnc-timezone:

(gdb) fr 6
#6  0x000000000045aa77 in IANAParser::find_tz_file (name=...) at ../libgnucash/engine/gnc-timezone.cpp:386
386                 throw std::invalid_argument("The timezone string failed to resolve to a valid filename");
(gdb) p tzname
$1 = {static npos = 18446744073709551615, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x7f7fffe68310 ""}, _M_string_length = 0, {
    _M_local_buf = '\000' <repeats 15 times>, _M_allocated_capacity = 0}}

looks like no/an empty name was passed?

How can I run the exp-parser test in gdb?

I tried copying from Testing/Temporary/LastTest.log, but

env 'GNC_UNINSTALLED=YES;GNC_BUILDDIR=/disk/6/archive/foreign/gnucash/build;GNC_UNINSTALLED=yes;GNC_BUILDDIR=/disk/6/archive/foreign/gnucash/build;LD_LIBRARY_PATH=/disk/6/archive/foreign/gnucash/build/lib:/disk/6/archive/foreign/gnucash/build/lib/gnucash;GNC_MODULE_PATH=/disk/6/archive/foreign/gnucash/build/lib:/disk/6/archive/foreign/gnucash/build/lib/gnucash;GUILE=/usr/pkg/guile/2.2/bin/guile;GUILE_LOAD_COMPILED_PATH=/disk/6/archive/foreign/gnucash/build/lib/gnucash/scm/ccache/2.2;GUILE_LOAD_PATH=/disk/6/archive/foreign/gnucash/libgnucash/app-utils/test/mod-foo:/disk/6/archive/foreign/gnucash/libgnucash/app-utils/test/mod-bar:/disk/6/archive/foreign/gnucash/libgnucash/app-utils/test/mod-baz;' gdb /disk/6/archive/foreign/gnucash/build/bin/test-exp-parser

gives me a segfault:
Program received signal SIGSEGV, Segmentation fault.
0x000075e405c1157f in GC_find_limit_with_bound (p=0x606680 <environ> "", up=up@entry=0, bound=bound@entry=0x0) at extra/../os_dep.c:1004
1004    extra/../os_dep.c: No such file or directory.
(gdb) bt
#0  0x000075e405c1157f in GC_find_limit_with_bound (p=0x606680 <environ> "", up=up@entry=0, bound=bound@entry=0x0) at extra/../os_dep.c:1004
#1  0x000075e405c167a9 in GC_find_limit (up=0, p=<optimized out>) at extra/../os_dep.c:1016
#2  GC_init_netbsd_elf () at extra/../os_dep.c:498
#3  GC_init () at extra/../misc.c:1196
#4  0x000075e40605d79d in scm_storage_prehistory () at gc.c:477
#5  0x000075e406068fe7 in scm_i_init_guile (base=0x7f7fff0d9780) at init.c:388
#6  0x000075e4060c9f55 in scm_i_init_thread_for_guile (base=0x7f7fff0d9780, dynamic_state=0x0) at threads.c:586
#7  0x000075e4060c9f9f in with_guile (base=base@entry=0x7f7fff0d9780, data=data@entry=0x7f7fff0d97b0) at threads.c:654
#8  0x000075e405c10a1b in GC_call_with_stack_base (fn=fn@entry=0x75e4060c9f6b <with_guile>, arg=arg@entry=0x7f7fff0d97b0) at extra/../misc.c:2106
#9  0x000075e4060ca8bf in scm_i_with_guile (dynamic_state=<optimized out>, data=0x7f7fff0d97b0, func=0x75e406068cae <invoke_main_func>) at threads.c:704
#10 scm_with_guile (func=func@entry=0x75e406068cae <invoke_main_func>, data=data@entry=0x7f7fff0d97e0) at threads.c:710
#11 0x000075e406068f7c in scm_boot_guile (argc=1, argv=0x7f7fff0d9898, main_func=0x4033a2 <real_main>, closure=0x0) at init.c:323
#12 0x00000000004033fc in main (argc=1, argv=0x7f7fff0d9898) at ../libgnucash/app-utils/test/test-exp-parser.c:262
Comment 17 Thomas Klausner 2019-07-20 14:51:48 EDT
I tried this diff:

diff --git a/libgnucash/engine/test/gtest-gnc-numeric.cpp b/libgnucash/engine/test/gtest-gnc-numeric.cpp
index 680b6d82d..e4307ecdc 100644
--- a/libgnucash/engine/test/gtest-gnc-numeric.cpp
+++ b/libgnucash/engine/test/gtest-gnc-numeric.cpp
@@ -213,7 +213,7 @@ TEST(gncnumeric_stream, output_stream)
     EXPECT_EQ("123/456", output.str());
     try
     {
-        auto loc = std::locale("fr_FR.utf8");
+        auto loc = std::locale("fr_FR.UTF-8");
         auto thou_sep = std::use_facet<std::numpunct<wchar_t>>(loc).thousands_sep();
         output.imbue(loc);
         output.str("");
@@ -225,7 +225,7 @@ TEST(gncnumeric_stream, output_stream)
     }
     catch (std::runtime_error& err)
     {
-        output.imbue(std::locale("fr_FR"));
+        output.imbue(std::locale("fr"));
         output.str("");
         output << simple_int;
         EXPECT_EQ("123456", output.str());


but it didn't fix the test.
Comment 18 John Ralls 2019-07-20 19:47:31 EDT
Check with the NetBSD C++ Standard Library devs to find out if they support std::locale("fr_FR.UTF8"). 

Is $TZ set in the environment? If not, try that. It's a hole in the implementation, if it's not set it should either throw a different exception ("No timezone!") or default to UTC.

The ';' characters in the string you passed to gdb break it up into different logical commands in bash, so the variable settings are out of scope when the interpreter gets to gdb. ISTR you use csh but I don't remember how it handles inline environment variables. The safe way to set them is to start gdb and then set them inside of gdb, e.g.
gdb> set env GNC_UNINSTALLED YES
...

Or you can stick them in a script file and include `-x filename` on the gdb command line or say `source filename` at the start of your gdb session.
Comment 19 John Ralls 2019-07-20 21:07:07 EDT
I pushed your GncAddTest.cmake patch.
Comment 20 Thomas Klausner 2019-07-27 15:07:09 EDT
Ok, so the locale problem seems to be a bug in g++ (7.4.0 nb3 20190319) as used by NetBSD, see https://gnats.netbsd.org/54411

As for the timezone test, when I set TZ to "UTC+2" or "CEST" I get

terminate called after throwing an instance of 'std::invalid_argument'
  what():  The timezone string failed to resolve to a valid filename

and in frame 6:
(gdb) p name
$2 = (const std::__cxx11::string &) @0x7f7fffbbfbf0: {static npos = 18446744073709551615, 
  _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x7f7fffbbfc00 ""}, _M_string_length = 0, {
    _M_local_buf = '\000' <repeats 15 times>, _M_allocated_capacity = 0}}

When I set it to UTC, I get:
Running main() from /scratch/devel/googletest/work/googletest-release-1.8.1/googletest/src/gtest_main.cc
[==========] Running 9 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 9 tests from gnc_timezone_constructors
[ RUN      ] gnc_timezone_constructors.test_default_constructor
[       OK ] gnc_timezone_constructors.test_default_constructor (0 ms)
[ RUN      ] gnc_timezone_constructors.test_pacific_time_constructor
../libgnucash/engine/test/gtest-gnc-timezone.cpp:54: Failure
Value of: tz->std_zone_abbrev() == "PST"
  Actual: false
Expected: true
../libgnucash/engine/test/gtest-gnc-timezone.cpp:55: Failure
Value of: tz->dst_zone_abbrev() == "PDT"
  Actual: false
Expected: true
../libgnucash/engine/test/gtest-gnc-timezone.cpp:57: Failure
Expected equality of these values:
  -8
  tz->base_utc_offset().hours()
    Which is: -7
unknown file: Failure
C++ exception with description "Year is out of valid range: 1400..9999" thrown in the test body.
[  FAILED  ] gnc_timezone_constructors.test_pacific_time_constructor (7 ms)
[ RUN      ] gnc_timezone_constructors.test_posix_timezone
[       OK ] gnc_timezone_constructors.test_posix_timezone (0 ms)
[ RUN      ] gnc_timezone_constructors.test_gmt_timezone
[       OK ] gnc_timezone_constructors.test_gmt_timezone (0 ms)
[ RUN      ] gnc_timezone_constructors.test_GMT_plus_7_timezone
[       OK ] gnc_timezone_constructors.test_GMT_plus_7_timezone (1 ms)
[ RUN      ] gnc_timezone_constructors.test_IANA_Belize_tz
[       OK ] gnc_timezone_constructors.test_IANA_Belize_tz (0 ms)
[ RUN      ] gnc_timezone_constructors.test_IANA_Perth_tz
[       OK ] gnc_timezone_constructors.test_IANA_Perth_tz (0 ms)
[ RUN      ] gnc_timezone_constructors.test_IANA_Minsk_tz
[       OK ] gnc_timezone_constructors.test_IANA_Minsk_tz (1 ms)
[ RUN      ] gnc_timezone_constructors.test_bogus_time_constructor
[       OK ] gnc_timezone_constructors.test_bogus_time_constructor (0 ms)
[----------] 9 tests from gnc_timezone_constructors (10 ms total)

[----------] Global test environment tear-down
[==========] 9 tests from 1 test case ran. (10 ms total)
[  PASSED  ] 8 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] gnc_timezone_constructors.test_pacific_time_constructor

Is there a simple c++ I can use to test the C++ timezone implementation in NetBSD (since I guess that is what you'll ask next? ;) ).

As for test-exp-parser, I put the variables in a file and sourced it in the gdb session, verified that they were set (with "show env" in gdb) but I get the same backtrace:

Program received signal SIGSEGV, Segmentation fault.
0x000073a52061157f in GC_find_limit_with_bound (p=0x606680 <environ> "", up=up@entry=0, bound=bound@entry=0x0) at extra/../os_dep.c:1004
1004    extra/../os_dep.c: No such file or directory.
(gdb) bt
#0  0x000073a52061157f in GC_find_limit_with_bound (p=0x606680 <environ> "", up=up@entry=0, bound=bound@entry=0x0) at extra/../os_dep.c:1004
#1  0x000073a5206167a9 in GC_find_limit (up=0, p=<optimized out>) at extra/../os_dep.c:1016
#2  GC_init_netbsd_elf () at extra/../os_dep.c:498
#3  GC_init () at extra/../misc.c:1196
#4  0x000073a520a5dafd in scm_storage_prehistory () at gc.c:477
#5  0x000073a520a69497 in scm_i_init_guile (base=0x7f7fff69a270) at init.c:389
#6  0x000073a520aca655 in scm_i_init_thread_for_guile (base=0x7f7fff69a270, dynamic_state=0x0) at threads.c:586
#7  0x000073a520aca69f in with_guile (base=base@entry=0x7f7fff69a270, data=data@entry=0x7f7fff69a2a0) at threads.c:654
#8  0x000073a520610a1b in GC_call_with_stack_base (fn=fn@entry=0x73a520aca66b <with_guile>, arg=arg@entry=0x7f7fff69a2a0) at extra/../misc.c:2106
#9  0x000073a520acafbf in scm_i_with_guile (dynamic_state=<optimized out>, data=0x7f7fff69a2a0, func=0x73a520a6915e <invoke_main_func>) at threads.c:704
#10 scm_with_guile (func=func@entry=0x73a520a6915e <invoke_main_func>, data=data@entry=0x7f7fff69a2d0) at threads.c:710
#11 0x000073a520a6942c in scm_boot_guile (argc=1, argv=0x7f7fff69a388, main_func=0x4033a2 <real_main>, closure=0x0) at init.c:324
#12 0x00000000004033fc in main (argc=1, argv=0x7f7fff69a388) at ../libgnucash/app-utils/test/test-exp-parser.c:262
Comment 21 John Ralls 2019-07-27 20:54:57 EDT
The NetBSD bug you pointed at isn't right, your libstdc++ is throwing when creating the locale; the bug user is getting a fr_FR locale and expecting a single character thousands separator while the NetBSD libstdc++ uses U+00A0, which is 2 characters in UTF-8. That test may still fail once you get the locale problem sorted.

I noticed this path in the backtrace just now: 
/disk/6/archive/foreign/src/external/gpl3/gcc/dist/libstdc++-v3/src/c++98/localename.cc
That's the gcc stdlibc++, the sources for which are at https://github.com/gcc-mirror/gcc/tree/master/libstdc%2B%2B-v3. But the actual throw is in frame 2 and the path is just c++locale.cc. That's not part of libstdc++, where does it come from? 

Timezones should be specified either as a filename from your zoneinfo directory (normally /usr/share/zoneinfo) or a POSIX timezone string. For UTC+2 you might use "Etc/GMT+2" or "Europe/Berlin" as filenames or "CEST+2" as a POSIX string. The string "UTC" is reserved for UTC.

Is "zdump" available on NetBSD? If it is, please run `zdump America/Los_Angeles` and report the output.

The guile segfault is actually in bdwgc, aka Boehm garbage collection. FWIW I'm able to debug test-exp-parser on Debian testing without any problems. BDWGC doesn't do releases AFAIK, can you figure out what git sha1 you have?
Comment 22 Thomas Klausner 2019-07-28 15:12:31 EDT
One point that came up in the c++ discussion is that in the test program, output is of type 'std::ostringstream'. However, for a UTF-8 locale a wide stream is needed because the thousands separator does not necessarily need to be a valid char. In the case of the french locale, it's a non-breaking space (0xC2A0).
Comment 23 Thomas Klausner 2019-07-28 15:18:58 EDT
As for timezone:

"set env TZ=America/Los_Angeles" works:

(gdb) r
Starting program: /disk/6/archive/foreign/gnucash/build/bin/test-gnc-timezone 
Running main() from /scratch/devel/googletest/work/googletest-release-1.8.1/googletest/src/gtest_main.cc
[==========] Running 9 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 9 tests from gnc_timezone_constructors
[ RUN      ] gnc_timezone_constructors.test_default_constructor
[       OK ] gnc_timezone_constructors.test_default_constructor (1 ms)
[ RUN      ] gnc_timezone_constructors.test_pacific_time_constructor
../libgnucash/engine/test/gtest-gnc-timezone.cpp:54: Failure
Value of: tz->std_zone_abbrev() == "PST"
  Actual: false
Expected: true
../libgnucash/engine/test/gtest-gnc-timezone.cpp:55: Failure
Value of: tz->dst_zone_abbrev() == "PDT"
  Actual: false
Expected: true
../libgnucash/engine/test/gtest-gnc-timezone.cpp:57: Failure
Expected equality of these values:
  -8
  tz->base_utc_offset().hours()
    Which is: -7
unknown file: Failure
C++ exception with description "Year is out of valid range: 1400..9999" thrown in the test body.
[  FAILED  ] gnc_timezone_constructors.test_pacific_time_constructor (7 ms)
[ RUN      ] gnc_timezone_constructors.test_posix_timezone
[       OK ] gnc_timezone_constructors.test_posix_timezone (1 ms)
[ RUN      ] gnc_timezone_constructors.test_gmt_timezone
[       OK ] gnc_timezone_constructors.test_gmt_timezone (0 ms)
[ RUN      ] gnc_timezone_constructors.test_GMT_plus_7_timezone
[       OK ] gnc_timezone_constructors.test_GMT_plus_7_timezone (0 ms)
[ RUN      ] gnc_timezone_constructors.test_IANA_Belize_tz
[       OK ] gnc_timezone_constructors.test_IANA_Belize_tz (0 ms)
[ RUN      ] gnc_timezone_constructors.test_IANA_Perth_tz
[       OK ] gnc_timezone_constructors.test_IANA_Perth_tz (1 ms)
[ RUN      ] gnc_timezone_constructors.test_IANA_Minsk_tz
[       OK ] gnc_timezone_constructors.test_IANA_Minsk_tz (0 ms)
[ RUN      ] gnc_timezone_constructors.test_bogus_time_constructor
[       OK ] gnc_timezone_constructors.test_bogus_time_constructor (0 ms)
[----------] 9 tests from gnc_timezone_constructors (11 ms total)

[----------] Global test environment tear-down
[==========] 9 tests from 1 test case ran. (11 ms total)
[  PASSED  ] 8 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] gnc_timezone_constructors.test_pacific_time_constructor

 1 FAILED TEST
[Inferior 1 (process 22686) exited with code 01]


as does:

# zdump America/Los_Angeles
America/Los_Angeles  Sun Jul 28 12:14:35 2019 PDT

I assume that bdwgc is part of boehm-gc, which does do releases, I have 8.0.4 installed, which is the current stable release according to http://www.hboehm.info/gc/

I don't see a c++locale.** file in my NetBSD source tree, so I'm stumped on that one.
Comment 24 John Ralls 2019-07-28 15:20:25 EDT
You and whoever you were discussing this with need to go study up on Unicode. UTF-8 is a multi-char encoding, not a wchar_t one. Non-breaking space U+00A0 and its UTF-8 encoding is 0xc2 0xa0, two chars.
Comment 25 John Ralls 2019-07-28 17:20:40 EDT
For test-gnc-timezone, please debug and set a break on line 54. When it stops do
  p tz->std_zone_abbrev()
  p tz->dst_zone_abbrev()

You might also run
  zdump -v America/Los_Angeles | 2012
from a command line just to make sure that your zone file isn't weird.

Looks like c++locale.cc is a build-time soft link in libstdc++:
https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/src/c%2B%2B98/Makefile.am#L92

I suspect that it's symlinking https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/config/locale/generic/c_locale.cc. That does indeed have a throw at line 227, with a comment above it:

"
  void
  locale::facet::_S_create_c_locale(__c_locale& __cloc, const char* __s,
				    __c_locale)
  {
    // Currently, the generic model only supports the "C" locale.
    // See http://gcc.gnu.org/ml/libstdc++/2003-02/msg00345.html
    __cloc = 0;
    if (strcmp(__s, "C"))
      __throw_runtime_error(__N("locale::facet::_S_create_c_locale "
			    "name not valid"));
  }
"

If I'm right, that means that NetBSD is like MinGW, C++ localization isn't supported. We worked around that by using boost::locale in gnc-numeric.cpp but since we don't try to test on MinGW I never fixed the test. Guess I need to do that.

Yup, boehm-gc. The crash reported in the stack trace is at
https://github.com/ivmai/bdwgc/blob/v8.0.4/os_dep.c#L1004, where it's trying to dereference result. You could examine the value of result after the crash, but even with that I wouldn't know how to proceed. I'm afraid you're going to have to use old-fashioned printfs in libgnucash/app-utils/calculation/expression_parser.c. I suggest building a little debug program, something like

#include <gnc-exp-parser.h>
int main (int argc, char** argv)
{
    char *error_loc = NULL;
    gnc_numeric result = {0, 0};
    gnc_exp_parser_init();
    gnc_exp_parser_parse ("1 ç", &result, &error_loc);
    assert(error_loc == 2); 
    exit 0;
}

That gets guile out of the way.
Comment 26 Thomas Klausner 2019-07-28 18:18:38 EDT
As for timezone:

Breakpoint 1, gnc_timezone_constructors_test_pacific_time_constructor_Test::TestBody (this=0x7de803dcc600) at ../libgnucash/engine/test/gtest-gnc-timezone.cpp:54
54          EXPECT_TRUE(tz->std_zone_abbrev() == "PST");
(gdb) p tz->std_zone_abbrev()
$1 = {static npos = 18446744073709551615, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x7f7fff6ea320 "PDT"},
  _M_string_length = 3, {_M_local_buf = "PDT\000\177\177\000\000?\243n\377\177\177\000", _M_allocated_capacity = 140183443096656}}
(gdb) p tz->dst_zone_abbrev()
$2 = {static npos = 18446744073709551615, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x7f7fff6ea320 ""}, 
  _M_string_length = 0, {_M_local_buf = "\000\243n\377\177\177\000\000?\243n\377\177\177\000", _M_allocated_capacity = 140187723014912}}
(gdb) 


# zdump -v America/Los_Angeles | grep 2012
America/Los_Angeles  Sun Mar 11 09:59:59 2012 UT = Sun Mar 11 01:59:59 2012 PST isdst=0 gmtoff=-28800
America/Los_Angeles  Sun Mar 11 10:00:00 2012 UT = Sun Mar 11 03:00:00 2012 PDT isdst=1 gmtoff=-25200
America/Los_Angeles  Sun Nov  4 08:59:59 2012 UT = Sun Nov  4 01:59:59 2012 PDT isdst=1 gmtoff=-25200
America/Los_Angeles  Sun Nov  4 09:00:00 2012 UT = Sun Nov  4 01:00:00 2012 PST isdst=0 gmtoff=-28800

As for locale support in libstdc++ on NetBSD: In the bug report I've been referencing, there's been progress on this issue, better locale support is currently being turned on. NetBSD 8 and older will not get it though.

As for boehm-gc:

(gdb) bt
#0  0x000077d22921157f in GC_find_limit_with_bound (p=0x600f80 <environ> "\370(\337\377\177\177", up=up@entry=0, bound=bound@entry=0x0) at extra/../os_dep.c:1004
#1  0x000077d2292167a9 in GC_find_limit (up=0, p=<optimized out>) at extra/../os_dep.c:1016
#2  GC_init_netbsd_elf () at extra/../os_dep.c:498
#3  GC_init () at extra/../misc.c:1196
#4  0x000077d229217d9f in GC_generic_malloc_inner (lb=lb@entry=20, k=k@entry=0) at extra/../malloc.c:174
#5  0x000077d22921959e in GC_generic_malloc (lb=20, k=0) at extra/../malloc.c:251
#6  0x000077d229219814 in GC_malloc_kind (lb=<optimized out>, k=k@entry=0) at extra/../malloc.c:327
#7  0x000077d229219914 in GC_malloc_atomic (lb=<optimized out>) at extra/../malloc.c:340
#8  0x000077d22965cf88 in do_gc_malloc_atomic (what=0x77d22970f624 "string", size=20) at gc-malloc.c:102
#9  scm_gc_malloc_pointerless (size=size@entry=20, what=what@entry=0x77d22970f624 "string") at gc-malloc.c:220
#10 0x000077d2296bfc6c in make_stringbuf (len=3) at strings.c:134
#11 0x000077d2296c03d1 in scm_i_make_string (len=len@entry=3, charsp=charsp@entry=0x7f7fffdf27b0, read_only_p=read_only_p@entry=0) at strings.c:308
#12 0x000077d2296c2dd2 in scm_from_utf8_stringn (str=0x77d22ec3bbc8 "fin", len=3) at strings.c:1659
#13 0x000077d22ec1edd5 in gnc_exp_parser_real_init (addPredefined=1) at ../libgnucash/app-utils/gnc-exp-parser.c:84
#14 0x000077d22ec1edac in gnc_exp_parser_init () at ../libgnucash/app-utils/gnc-exp-parser.c:70
#15 0x0000000000400ac6 in main (argc=1, argv=0x7f7fffdf28e8) at test.c:8


Second try:

Breakpoint 1, gnc_exp_parser_real_init (addPredefined=1) at ../libgnucash/app-utils/gnc-exp-parser.c:80
80          if (parser_inited)
(gdb) n
84          scm_primitive_load_path(scm_from_utf8_string("fin"));
(gdb) 

Program received signal SIGSEGV, Segmentation fault.
0x00007a6ee261157f in GC_find_limit_with_bound (p=0x600f80 <environ> "\210\334\313\377\177\177", up=up@entry=0, bound=bound@entry=0x0) at extra/../os_dep.c:1004
1004    extra/../os_dep.c: No such file or directory.

For this program:
#include <assert.h>
#include <gnc-numeric.h>
#include <gnc-exp-parser.h>
int main (int argc, char** argv)
{
    char *error_loc = NULL;
    gnc_numeric result = {0, 0};
    gnc_exp_parser_init();
    gnc_exp_parser_parse ("1 ç", &result, &error_loc);
    printf("result: %p, error_loc: %p\n", result, error_loc);
//    assert(error_loc == 2); 
    exit (0);
}

(error_loc is a pointer and 2 is an integer, so I commented this out)

and this compile command line:

gcc -g -O0 -DHAVE_SCANF_LLD=1 -I ../libgnucash/app-utils/ -I ../libgnucash/engine `pkg-config --cflags glib-2.0` -I . test.c  -Llib/gnucash  -Wl,-Rlib/gnucash -lgncmod-app-utils

Do I need environment variables set for the scm load path?
Comment 27 Thomas Klausner 2019-07-28 18:20:38 EDT
Forgot to mention, for the timezone test, I did set the TZ in gdb. I think it was your example:
set env TZ=America/Los_Angeles
Comment 28 John Ralls 2019-07-28 19:15:31 EDT
There's nothing to be done about localization, unfortunately. I mis-remembered about the Win32 workaround: boost::locale doesn't work either though for different reasons. We've simply disabled C++ localization on Windows. I expect the same will happen on NetBSD until std::locale gets sorted out there.

Rats, I didn't realize that gnc_exp_parser_init() requires scheme. It looks like expression_parser.c and gnc-exp-parser.c are too tightly coupled to be able to create a stand-alone program for gdb, and starting up guile doesn't work in GDB on your system so that tack won't work.

I think you're going to have to just skip those two tests along with the two GncNumeric::operator<< tests that depend on std::locale. Is there something like __NetBSD__ defined that you can just #ifndef them away?

As for the timezone test it seems that IANAParser::IANAParser(fileblock) is somehow getting the wrong offset for America/Los_Angeles so it's getting the DST abbreviation and UTC offset for the base one. Of course that's the only one that's tested so it might be wrong on all of the zone files. It seems very unlikely that NetBSD would have their own zone files so I'm puzzled how that could happen.
Comment 29 John Ralls 2019-07-28 19:16:55 EDT
No that last bit is wrong, several TZs get tested and only that one is goofy. Weird.
Comment 30 Thomas Klausner 2019-07-29 14:39:37 EDT
I think it'd be good to fix the low-hanging fruit:
* set TZ to something valid when running the timezone test
* fix the year 2-digit vs 4-digit issue

C++ locale support will hopefully get better in NetBSD really soon now.

I would not disable the tests, I don't think that helps.
Comment 31 Christian G. 2019-11-15 17:07:12 EST
Can this bug ticket be resolved?
Comment 32 John Ralls 2021-01-28 20:25:19 EST
Closing, the OP seems to have lost interest. If someone comes along who wants to revive this--on the current maint HEAD--by all means reopen it.

Note You need to log in before you can comment on or make changes to this bug.