Test fail and longjmp crash

2 views
Skip to first unread message

IJsbrand Wijnands

unread,
Dec 2, 2025, 9:22:59 AM (3 days ago) Dec 2
to ThrowTheSwitch Forums
Hi Folks,

I'm seeing an issue I've not seen before and I'm a little puzzled by it. I'm adding UT to an existing project, and when doing that I noticed the following crash.

Thread 1 "test_new_project." received signal SIGSEGV, Segmentation fault.
__longjmp () at ../sysdeps/x86_64/__longjmp.S:111
111 ../sysdeps/x86_64/__longjmp.S: No such file or directory.
(gdb) bt
#0  __longjmp () at ../sysdeps/x86_64/__longjmp.S:111
#1  0xdbe0560592ca501c in ?? ()
Backtrace stopped: Cannot access memory at address 0xdbe0560592ca501c
(gdb) quit

I traced through it and found it was triggered by function call that I did not yet declare, as soon as I did (like with IgnoreAndReturn()) , the problem went away. What I was expected is the message "Called more times than expected.".  I now keep running into this issue adding more code into the test, and its harder to figure out which function call is missing each time..

Any suggestions?

Thx,

Ice.

Mark Vander Voord

unread,
Dec 2, 2025, 10:41:07 AM (3 days ago) Dec 2
to throwth...@googlegroups.com
Hi Ice,

This is a good question. 

Are you creating your own test runners? In that case, it's likely that your test runner is missing one of the core features. Perhaps it is not wrapping the test function call in the RUN_TEST macro?

Since you're also using mocks, you'll want to either add the _Init and _Destroy functions for reach mock in the setUp and tearDown functions respectively... OR... you can replace the RUN_TEST macro with a version that does these things automatically.

If you're using Unity's test runner generator or Ceedling to generate your test runners, then you shouldn't have either of the problems above. If you're able to switch to one of these methods, they'll handle most of these kinds of issues and you'll get much more logical error messages.

Mark

--
You received this message because you are subscribed to the Google Groups "ThrowTheSwitch Forums" group.
To unsubscribe from this group and stop receiving emails from it, send an email to throwtheswitc...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/throwtheswitch/b6ccddff-7bcf-4d64-b288-8a0f94e537e5n%40googlegroups.com.

IJsbrand Wijnands

unread,
Dec 2, 2025, 11:32:21 AM (3 days ago) Dec 2
to ThrowTheSwitch Forums
Thanks Mark for your response and suggestions!

Found it, I was not wrapping a function inside a RUN_TEST macro that did make calls to the Mocked functions.

Glad it is solved :-)

Thx,

Ice.

Reply all
Reply to author
Forward
0 new messages