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

When CMock is out of memory it does not tell you so #463

Open
Letme opened this issue Oct 19, 2023 · 5 comments
Open

When CMock is out of memory it does not tell you so #463

Letme opened this issue Oct 19, 2023 · 5 comments

Comments

@Letme
Copy link

Letme commented Oct 19, 2023

I have following flags to compile CMock (tested the latest) with static memory size and alignment:

-DCMOCK_MEM_STATIC -DCMOCK_MEM_SIZE=$(CMOCK_MEMSIZE) -DCMOCK_MEM_ALIGN=$(CMOCK_MEMALIGN)

The values don't matter, but the behavior becomes strange if you overreach the CMOCK_MEMSIZE. It reports Expect was not expected and when you remove that Expect it tells you it actually expected it. So you are in chicken and egg situation. I checked the code and CMock_Guts_MemNew actually reports CMOCK_GUTS_NONE in this case, but the message CMockStringOutOfMemory is never triggered/displayed. I checked unit tests and I am missing this case. I am not sure if it was intended to be implemented, or not.

@mvandervoord
Copy link
Member

That definitely doesn't sound like the intended implementation! Like you, I would want it to report the out-of-memory error first and foremost, since it's the root reason for the failure. Thanks for noticing this!

When you say "overreach", I assume you mean selecting any size that can't actually be returned by the heap on that target?

@Letme
Copy link
Author

Letme commented Oct 19, 2023

Yes, well array size that is available for a static array is not big enough but instead of reporting out of memory error, I just got strange behavior above. Removing one init/verify file solved that problem (or increase in CMOCK_MEM_SIZE variable)

@mvandervoord
Copy link
Member

Thanks. I'm understanding. :)

@Letme
Copy link
Author

Letme commented Oct 19, 2023

return CMOCK_GUTS_NONE; /* nothing we can do; our static buffer is out of memory */
this line in C file gets hit, but then I loose why the out of memory message is not displayed (cant follow though Ruby scripts). Hope that helps, but I think tests in this repo could be enhanced to catch this case (not just reported error code but also to get the message reported).

@mvandervoord
Copy link
Member

Hey @Letme -- I'm not finding why this would be a problem yet... You're sure it's CMock_Guts_MemNew that is returning the error? I only see it getting called in one place in the scripts. It's immediately passed to CMock_Guts_GetAddressFor which correctly returns a null when encountered... and the null check is the next line of the base expectation.

Can you do me a favor? Can you send me a snapshot of your project.yml (or however you're configuring cmock) and one of the generated mock files (it'd be good if it was one giving you this problem)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants