flatcc: All testcases crash when use -DFLATCC_USE_GENERIC_ALIGNED_ALLOC

I wonder there exists some errors in include/flatcc/flatcc_alloc.h at line 107: https://github.com/dvidelabs/flatcc/blob/8f88bf257d3d652b53b89e5298bda9badb833ab0/include/flatcc/flatcc_alloc.h#L99-L109

I think it should define FLATCC_ALIGNED_FREE rather than FLATCC_ALIGNED, it will effect when FLATCC_USE_GENERIC_ALIGNED_ALLOC defined. I try this:

  • set macro -DFLATCC_USE_GENERIC_ALIGNED_ALLOC in CMakeLists.txt
  • run scripts/initbuild.sh make
  • run scripts/test.sh

all test cases crash because of invalid pointer when do free.

Moreover, I find some errors in test code of test/json_test/test_json.c:114 https://github.com/dvidelabs/flatcc/blob/8f88bf257d3d652b53b89e5298bda9badb833ab0/test/json_test/test_json.c#L113-L126

when flatbuffer is not used and assigned above, it is zero when call flatcc_builder_aligned_free, it will lead to segment fault in function __flatcc_aligned_free In addition, the test case 3 monster_test always fails but I can not find the reason.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15 (15 by maintainers)

Most upvoted comments

Perhaps it is just unreliable code because of other things going wrong and a clean rebuild fixes that?

Yes, I made a mistake, I used unreliable code because I modified some other things in my branch. A clean rebuild is OK Thank you very much!