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

Memory error in trace buffer initialization #451

Open
cmnrd opened this issue Jun 24, 2024 · 1 comment
Open

Memory error in trace buffer initialization #451

cmnrd opened this issue Jun 24, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@cmnrd
Copy link
Contributor

cmnrd commented Jun 24, 2024

When I compile the RTI (using gcc 14), then I get the following error:

/home/cmenard/projects/lf/lingua-franca/core/src/main/resources/lib/c/reactor-c/trace/impl/src/trace_impl.c: In function ‘start_trace’:
/home/cmenard/projects/lf/lingua-franca/core/src/main/resources/lib/c/reactor-c/trace/impl/src/trace_impl.c:155:57: error: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
  155 |   trace->_lf_trace_buffer_size = (size_t*)calloc(sizeof(size_t), trace->_lf_number_of_trace_buffers + 1);
      |                                                         ^~~~~~
/home/cmenard/projects/lf/lingua-franca/core/src/main/resources/lib/c/reactor-c/trace/impl/src/trace_impl.c:155:57: note: earlier argument should specify number of elements, later size of each element

This hints at a bug in

trace->_lf_trace_buffer_size = (size_t*)calloc(sizeof(size_t), trace->_lf_number_of_trace_buffers + 1);
, which seems to have transposed arguments for the call to calloc.

I wanted to push a simple fix, but then I realized that there are more strange artifacts around this code. In particular:

  • Why is the array size to be allocated incremented by 1?
  • Why is trace->_lf_trace_buffer_size (the pointer to the newly allocated array) incremented by one in
    trace->_lf_trace_buffer_size++;
    ?
  • I could not find a call to free for this array.
@cmnrd cmnrd added the bug Something isn't working label Jun 24, 2024
@petervdonovan
Copy link
Contributor

Since this is a potential bug in the version of tracing that saves traces to local binary files, it is not a blocker for anything that has a specific deadline. Therefore, I am giving it low priority.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants