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

Many tests fail on FreeBSD #164

Open
yurivict opened this issue Sep 6, 2021 · 9 comments
Open

Many tests fail on FreeBSD #164

yurivict opened this issue Sep 6, 2021 · 9 comments
Assignees
Labels
bug Something isn't working in-testing portability question Further information is requested requires investigation

Comments

@yurivict
Copy link

yurivict commented Sep 6, 2021

Test project /disk-samsung/freebsd-ports/devel/duma/work/.build
      Start  1: dumatest_static
 1/12 Test  #1: dumatest_static ..................***Exception: SegFault  0.00 sec
      Start  2: tstheap_static
 2/12 Test  #2: tstheap_static ...................***Exception: SegFault  0.00 sec
      Start  3: thread-test_static
 3/12 Test  #3: thread-test_static ...............   Passed    0.02 sec
      Start  4: dumatestpp_static
 4/12 Test  #4: dumatestpp_static ................***Exception: SegFault  0.00 sec
      Start  5: testoperators_static
 5/12 Test  #5: testoperators_static .............***Exception: SegFault  0.00 sec
      Start  6: testmemlimit_static
 6/12 Test  #6: testmemlimit_static ..............   Passed    0.00 sec
      Start  7: dumatest_shared
 7/12 Test  #7: dumatest_shared ..................***Exception: SegFault  0.00 sec
      Start  8: tstheap_shared
 8/12 Test  #8: tstheap_shared ...................***Exception: SegFault  0.00 sec
      Start  9: thread-test_shared
 9/12 Test  #9: thread-test_shared ...............***Exception: SegFault  0.00 sec
      Start 10: dumatestpp_shared
10/12 Test #10: dumatestpp_shared ................***Exception: SegFault  0.00 sec
      Start 11: testoperators_shared
11/12 Test #11: testoperators_shared .............***Exception: SegFault  0.00 sec
      Start 12: testmemlimit_shared
12/12 Test #12: testmemlimit_shared ..............***Exception: SegFault  0.00 sec

17% tests passed, 10 tests failed out of 12

Total Test time (real) =   0.06 sec

The following tests FAILED:
	  1 - dumatest_static (SEGFAULT)
	  2 - tstheap_static (SEGFAULT)
	  4 - dumatestpp_static (SEGFAULT)
	  5 - testoperators_static (SEGFAULT)
	  7 - dumatest_shared (SEGFAULT)
	  8 - tstheap_shared (SEGFAULT)
	  9 - thread-test_shared (SEGFAULT)
	 10 - dumatestpp_shared (SEGFAULT)
	 11 - testoperators_shared (SEGFAULT)
	 12 - testmemlimit_shared (SEGFAULT)

2_5_21-315-gdce042d
OS: FreeBSD 13

@yurivict
Copy link
Author

yurivict commented Sep 6, 2021

For example, the dumatest_static crashes here:
In FreeBSD libraries:

 605│         } else if (__predict_false(*m <= THR_MUTEX_DESTROYED)) {
 606│                 if (*m == THR_MUTEX_DESTROYED) {
 607│                         ret = EINVAL;
 608│                 } else {
 609├───────────────────────> ret = init_static(_get_curthread(), mutex);
 610│                         if (ret == 0)
 611│                                 *m = *mutex;
 612│                 }
 613│         }

called from here in duma:

130│ static void lock() {
131├─> if (pthread_mutex_trylock(&mutex)) {
132│     if (mutextid == pthread_self()) {
133│       ++locknr;
134│       return;
135│     } else {
136│       pthread_mutex_lock(&mutex);
137│     }
138│   }
139│   mutextid = pthread_self();
140│   locknr = 1;
141│ }

... during static initialization.

@johnsonjh
Copy link
Owner

@yurivict

Thank you for the report.

Are you able to replicate this using the GNU Make based build? I have a feeling this might have to do with the requirement for passing -pthread to the compiler and linker and/or defining _REENTRANT and/or _THREADSAFE on some platforms, or some combination of these.

I'll be able to look at this over the weekend - I have a FreeBSD/ARM64 system available locally, which I hope will be sufficient to reproduce and create a fix.

@johnsonjh johnsonjh self-assigned this Sep 10, 2021
@johnsonjh johnsonjh added bug Something isn't working portability requires investigation question Further information is requested labels Sep 10, 2021
@johnsonjh
Copy link
Owner

@yurivict I'll be running some tests this evening, thanks.

@yurivict
Copy link
Author

Same with GNU make-based build.

@johnsonjh
Copy link
Owner

$ uname -a
FreeBSD rpi3br1 13.0-RELEASE-p4 FreeBSD 13.0-RELEASE-p4 #0: Tue Aug 24 07:38:07 UTC 2021     [email protected]:/usr/obj/usr/src/arm64.aarch64/sys/GENERIC  arm64

Seeing the same results as you, same crash, so at least it's something I can debug here. Same with GCC and Clang as well.

As an experiment, I tried to build the non-threaded library (you'll need to use gmake -k to build as it tries to compile a threaded test when using cmake - I'll fix that) and still find some problems.

Test project /home/jhj/src/duma/build                                                                                
      Start  1: dumatest_static  
 1/12 Test  #1: dumatest_static ..................   Passed    0.01 sec           
      Start  2: tstheap_static      
 2/12 Test  #2: tstheap_static ...................   Passed    1.33 sec           
      Start  3: thread-test_static 
 3/12 Test  #3: thread-test_static ...............***Not Run   0.00 sec
      Start  4: dumatestpp_static
 4/12 Test  #4: dumatestpp_static ................   Passed    0.01 sec
      Start  5: testoperators_static
 5/12 Test  #5: testoperators_static .............   Passed    0.01 sec
      Start  6: testmemlimit_static
 6/12 Test  #6: testmemlimit_static ..............   Passed    0.49 sec
      Start  7: dumatest_shared
 7/12 Test  #7: dumatest_shared ..................***Exception: SegFault  0.27 sec
      Start  8: tstheap_shared
 8/12 Test  #8: tstheap_shared ...................***Exception: SegFault  2.97 sec
      Start  9: thread-test_shared
 9/12 Test  #9: thread-test_shared ...............***Exception: SegFault  2.98 sec
      Start 10: dumatestpp_shared
10/12 Test #10: dumatestpp_shared ................***Exception: SegFault  0.26 sec
      Start 11: testoperators_shared
11/12 Test #11: testoperators_shared .............***Exception: SegFault  0.25 sec
      Start 12: testmemlimit_shared
12/12 Test #12: testmemlimit_shared ..............***Exception: SegFault  0.26 sec

42% tests passed, 7 tests failed out of 12

Total Test time (real) =   8.87 sec

The following tests FAILED:
          3 - thread-test_static (Not Run)
          7 - dumatest_shared (SEGFAULT)
          8 - tstheap_shared (SEGFAULT)
          9 - thread-test_shared (SEGFAULT)
         10 - dumatestpp_shared (SEGFAULT)
         11 - testoperators_shared (SEGFAULT)
         12 - testmemlimit_shared (SEGFAULT)
Errors while running CTest

FreeBSD has changed a bit since I last looked at it - I'm reading about the "new" libthr vs. libpthread and hope to have a fix for you shortly, and some build enhancements.

@johnsonjh
Copy link
Owner

A local NetBSD systems seems OK - still investigating.

@johnsonjh
Copy link
Owner

Just to give you an update that I've not forgotten about this and hope to have a solution shortly. I can avoid the problem with inefficient management of the lock and not using trylock, but, that kind of defeats the purpose! I'm sure it's something I'm doing wrong.

@yurivict
Copy link
Author

Thanks!

@johnsonjh
Copy link
Owner

I've asked a friend who has some more FreeBSD experience to help and hopefully I'll hear something soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working in-testing portability question Further information is requested requires investigation
Projects
None yet
Development

No branches or pull requests

2 participants