fluent-asserts icon indicating copy to clipboard operation
fluent-asserts copied to clipboard

v1.0.0 cause Program exited with code -11 (v0.13.3 is fine)

Open mw66 opened this issue 3 years ago • 6 comments

maybe the problems caused by some sharedStaticCtor ?

Thread 1 "" received signal SIGSEGV, Segmentation fault.
0x0000555555ea28d1 in _D13fluentasserts4core6expect6Expect6__ctorMFNcNeSQBwQBk10evaluation15ValueEvaluationxAyaxmAyaZSQDqQDeQDcQCy (this=0x7fffd9638500, value=..., fileName=..., line=506, prependText="") at /.dub/packages/fluent-asserts-1.0.0/fluent-asserts/source/fluentasserts/core/expect.d:25
25	    evaluation.id = Lifecycle.instance.beginEvaluation(value);

(gdb) info threads
  Id   Target Id                                             Frame 
* 1    Thread 0x7fffe722f000 (LWP 3201287) "" 0x0000555555ea28d1 in _D13fluentasserts4core6expect6Expect6__ctorMFNcNeSQBwQBk10evaluation15ValueEvaluationxAyaxmAyaZSQDqQDeQDcQCy (this=0x7fffd9638500, 
    value=..., fileName=..., line=506, prependText="") at /.dub/packages/fluent-asserts-1.0.0/fluent-asserts/source/fluentasserts/core/expect.d:25
  2    Thread 0x7fffd771e000 (LWP 3201290) "ats-test-LIVE_T" __memmove_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:384

(gdb) where
#0  0x0000555555ea28d1 in _D13fluentasserts4core6expect6Expect6__ctorMFNcNeSQBwQBk10evaluation15ValueEvaluationxAyaxmAyaZSQDqQDeQDcQCy (this=0x7fffd9638500, value=..., fileName=..., line=506, prependText="")
    at /.dub/packages/fluent-asserts-1.0.0/fluent-asserts/source/fluentasserts/core/expect.d:25
#1  0x00005555557884bf in _D13fluentasserts4core6expect__TQkTlZQpFNeLlxAyaxmAyaZSQCbQBpQBn6Expect (testedValue=140737488344216, file=..., line=506, prependText="")
    at /.dub/packages/fluent-asserts-1.0.0/fluent-asserts/source/fluentasserts/core/expect.d:282
#2  0x0000555555778bed in _D13fluentasserts4core4base6Assert__T10opDispatchVAyaa11_677265617465725468616eTlTiZQBvFNfliQBqxAyaxmZv (actual=10281, expected=0, reason="", file=..., line=987)
    at /.dub/packages/fluent-asserts-1.0.0/fluent-asserts/source/fluentasserts/core/base.d:506


#5  0x00005555556e9c64 in _D ... 25_sharedStaticCtor_L321_C1FZv () at 
#6  0x0000555556074c79 in rt.minfo.rt_moduleCtor().__foreachbody1(ref rt.sections_elf_shared.DSO) ()
#7  0x000055555607549a in rt.sections_elf_shared.DSO.opApply(scope int(ref rt.sections_elf_shared.DSO) delegate) ()
#8  0x000055555606d0bf in rt_init ()
#9  0x000055555606d54d in rt.dmain2._d_run_main2(char[][], ulong, extern(C) int(char[][]) function).runAll() ()
#10 0x000055555606d486 in _d_run_main2 ()
#11 0x000055555606d2de in _d_run_main ()
#12 0x0000555555a22502 in main (argc=1, argv=0x7fffffffd8d8) at /ldc2-1.30.0-linux-x86_64/bin/../import/core/internal/entrypoint.d:42
#13 0x00007ffff4f04d90 in __libc_start_call_main (main=main@entry=0x555555a224e0 <main>, argc=argc@entry=1, argv=argv@entry=0x7fffffffd8d8) at ../sysdeps/nptl/libc_start_call_main.h:58
#14 0x00007ffff4f04e40 in __libc_start_main_impl (main=0x555555a224e0 <main>, argc=1, argv=0x7fffffffd8d8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffd8c8)
    at ../csu/libc-start.c:392
#15 0x00005555556e80d5 in _start ()


(gdb) thread 2
[Switching to thread 2 (Thread 0x7fffd771e000 (LWP 3201290))]
#0  __memmove_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:384
384	../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S: No such file or directory.
(gdb) where
#0  __memmove_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:384
#1  0x000055555607312d in _d_arraycatnTX ()
#2  0x0000555555edb948 in _D13fluentasserts4core10operations8registry8Registry8registerMFAyaQdQfDFNbNfKCQCyQCm10evaluation10EvaluationZACQEfQDt7results7IResultZCQFdQErQEpQEgQEa (this=0x7fffd82e0a50, valueType="long[]", 
    expectedValueType="byte[]", name="equal", operation=...) at /.dub/packages/fluent-asserts-1.0.0/fluent-asserts/source/fluentasserts/core/operations/registry.d:53
#3  0x0000555555edbaf6 in _D13fluentasserts4core10operations8registry8Registry8registerMFAyaQdQfPFNbNfKCQCyQCm10evaluation10EvaluationZACQEfQDt7results7IResultZCQFdQErQEpQEgQEa (this=0x7fffd82e0a50, valueType="long[]", 
    expectedValueType="byte[]", name="equal", operation=0x555555ec7d80 <_D13fluentasserts4core10operations10arrayEqualQmFNbNfKCQCbQBp10evaluation10EvaluationZACQDiQCw7results7IResult>)
    at /.dub/packages/fluent-asserts-1.0.0/fluent-asserts/source/fluentasserts/core/operations/registry.d:63
#4  0x0000555555eb6345 in _D13fluentasserts4core9lifecycle18_staticCtor_L31_C1FZv () at /.dub/packages/fluent-asserts-1.0.0/fluent-asserts/source/fluentasserts/core/lifecycle.d:106
#5  0x0000555556074cd9 in rt.minfo.rt_moduleTlsCtor().__foreachbody1(ref rt.sections_elf_shared.DSO) ()
#6  0x000055555607549a in rt.sections_elf_shared.DSO.opApply(scope int(ref rt.sections_elf_shared.DSO) delegate) ()
#7  0x0000555556065b1c in thread_entryPoint ()
#8  0x00007ffff4f6fb43 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#9  0x00007ffff5001a00 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

mw66 avatar Nov 20 '22 18:11 mw66

Would it be possible to share the test/project that triggers this error? also, the compiler version would also be helpful to know.

gedaiu avatar Nov 20 '22 19:11 gedaiu

Actually I think I found the problem:

In one of my own sharedStaticCtor, some function called Assert.equal(), I think maybe it means the fluent-asserts has not be fully init-ed yet?

Maybe in this case, all such Assert should be just ignored.

(I will try to remove such Assert, and see what happens).

mw66 avatar Nov 20 '22 19:11 mw66

yes, to improve the integration with the Trial test runner, I had to introduce some global states. It's better not to have asserts in a module constructor. I'm currently working on a better solution to it, but I don't have enough time...

gedaiu avatar Nov 20 '22 19:11 gedaiu

It is confirmed that this is the cause of the problem (I remove such Assert calls in the sharedStaticCtor call path, it works now).

I'm currently working on a better solution to it

As I suggested: for now, maybe just issue a warning message, and ignore such assert? (it should be detectable: just check a flag that fluent-asserts is not fully init-ed).

mw66 avatar Nov 20 '22 19:11 mw66

Hit by this issue again. Any update?

Another thought: make Assert only do real call in version (unittest), otherwise, just NO-OP.

mw66 avatar Feb 20 '24 23:02 mw66

I only had a little time for this library. I want to spend some time on Friday on this. I hope I can fix all open issues then. Otherwise, PRs are always welcomed.

gedaiu avatar Feb 21 '24 08:02 gedaiu