pgagroal icon indicating copy to clipboard operation
pgagroal copied to clipboard

malloc question

Open RekGRpth opened this issue 3 years ago • 2 comments

https://github.com/agroal/pgagroal/blob/ce557da1539ff92e052845d8a0cfd059e40bc236/src/libpgagroal/message.c#L952-L955 what happens if malloc returns null?

RekGRpth avatar Jan 17 '22 14:01 RekGRpth

While pgagroal has a very low memory allocation rate there is def work needed on all error paths - including the one you pointed out.

Likely need a fault injection framework like - https://github.com/jesperpedersen/libfaults - to get through them all; including call sites.

I welcome contributions to both projects within this space !

jesperpedersen avatar Jan 17 '22 15:01 jesperpedersen

try use

cppcheck -j"$(nproc)" --verbose --force --enable=all --suppress=variableScope . 2> check.err

and automate it on test builds

RekGRpth avatar Jan 17 '22 15:01 RekGRpth

In this case, do we return only the error code, something like if (m == NULL) return MESSAGE_STATUS_ERROR; ? Do we also need to log the error somewhere?

SudeepRed avatar Mar 20 '23 15:03 SudeepRed

Yeah, we should use a pgagroal_log_fatal()

jesperpedersen avatar Mar 21 '23 05:03 jesperpedersen