Skip to content

MTV fails to load events with index N>=1 #2139

@jdenaro98

Description

@jdenaro98

Issue:

  • MTV fails to load any events for a running/connected sim with index N>=1. This will cause the MTV to 'disconnect' and immediately, print the error signature as seen below in the screenshot/debug output.

Root Cause:

Debug/Screenshots:

MTV view of errors after attempting connection

Image

Debug output of those same errors

debug_output.txt

Suggestion

  • These changes properly address the dereferenced pointer and result in a working MTV for simulations with events of indexes >=

  • Suggested change for trick_source/sim_services/MemoryManager/Memorymanager_ref_dim.cpp lines 270-276

                    } else { // Dynamic array case
                        // Check if the index is out of bounds if the pointer points to a dynamic array.
                        // R->address is already dereferenced to the heap array.
                        if (index_value >= (get_size(R->address))) {
                            /* print out of bounds error message if MM debug_level is greater than 1 */
                            if (debug_level > 1) {
                                std::stringstream message;
                                message << index_value << " is out of bounds for " << R->reference << " (size=" << get_size(R->address) << ").";
                                emitError(message.str());
                            }
                            free(ref2);
                            return (TRICK_PARAMETER_ARRAY_SIZE);
                        }
                    }
  • Suggested change for trick_source/java/src/main/java/trick/mtv/MtvApp.java lines 277-286 under 'get cyclical event data' section
                for (int ii = 0; ii < mtv_list_count; ii++) {
                    if (!mtv_events.get(ii).show) {
                        continue;
                    }
                    // tell var server to get status info for each event that we will read cyclically
                    map[mtv_count] = ii;
                    event_vars = "trick.var_add(\"trick_ip.mtv.mtv_list[" + ii + "][0].active\"); ";
                    event_vars += "trick.var_add(\"trick_ip.mtv.mtv_list[" + ii + "][0].fired_time\"); ";
                    event_vars += "trick.var_add(\"trick_ip.mtv.mtv_list[" + ii + "][0].fired_count\"); ";
                    event_vars += "trick.var_add(\"trick_ip.mtv.mtv_list[" + ii + "][0].ran_time\"); ";
                    event_vars += "trick.var_add(\"trick_ip.mtv.mtv_list[" + ii + "][0].ran_count\"); ";
                    event_vars += "trick.var_add(\"trick_ip.mtv.mtv_list[" + ii + "][0].manual\"); ";
                    event_vars += "trick.var_add(\"trick_ip.mtv.mtv_list[" + ii + "][0].manual_fired\"); ";
                    event_vars += "trick.var_add(\"trick_ip.mtv.mtv_list[" + ii + "][0].hold\"); ";
                    event_vars += "trick.var_add(\"trick_ip.mtv.mtv_list[" + ii + "][0].added\"); ";
                    mtv_var_count += 9;
                    for (int jj = 0; jj < mtv_events.get(ii).cond_count; jj++) {
                        event_vars += "trick.var_add(\"trick_ip.mtv.mtv_list[" + ii + "][0].condition_list[" + jj + "][0].enabled\"); ";
                        event_vars += "trick.var_add(\"trick_ip.mtv.mtv_list[" + ii + "][0].condition_list[" + jj + "][0].fired_time\"); ";
                        event_vars += "trick.var_add(\"trick_ip.mtv.mtv_list[" + ii + "][0].condition_list[" + jj + "][0].fired_count\"); ";
                        event_vars += "trick.var_add(\"trick_ip.mtv.mtv_list[" + ii + "][0].condition_list[" + jj + "][0].hold\"); ";
                        mtv_var_count += 4;
                    }
                    for (int jj = 0; jj < mtv_events.get(ii).act_count; jj++) {
                        event_vars += "trick.var_add(\"trick_ip.mtv.mtv_list[" + ii + "][0].action_list[" + jj + "][0].enabled\"); ";
                        event_vars += "trick.var_add(\"trick_ip.mtv.mtv_list[" + ii + "][0].action_list[" + jj + "][0].ran_time\"); ";
                        event_vars += "trick.var_add(\"trick_ip.mtv.mtv_list[" + ii + "][0].action_list[" + jj + "][0].ran_count\"); ";
                        mtv_var_count += 3;
                    }

Working MTV view on example SIM_parachute for RUN_Baumgartner_jump which includes planned events for S/Cd changes

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions