This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/TM4C1294KCPDT: VMT corruption?

Part Number: TM4C1294KCPDT

Tool/software: TI C/C++ Compiler

Hello!

I have complex project originally designed in C++ for TM4C123F MCU, and also ported to TM4C1294 MCU. Now I faced very veird issue:

When I run the code I see one of my object behaves like VMT is corrupt, so when I debug call to a function of this object I see the call falls into another function.

Here is the details of the project:

1. I have application independent kernel library, built as static library, where abstract base class JCApp declared, and this class has virtual functions:

class JCApp: public EvtTarget, public GUI
{
    
    ...

public:
    virtual void DefaultConfig() {}
    virtual void Init() = 0;

    ...

};

2. I have application library, buill as static library, where application class derived from JCApp declared:

class ASMApp: public JCApp
{

    ...

    void DefaultConfig();

    ...

public:

    ...

    void Init();

    ...

}

3. In a framework project I have some other object, creating and accessing ASMApp object inside a constructor:

SummaryApp::SummaryApp(bool Selected)
{

    ...

    for(i = 0; i < nApps; i++)
    {
        ...

        Apps[i] = new ASMApp(true);
    }

    ...

    if((NewSign != Conf.AppSigns) || (NewSize != Conf.AppTotSize))
    {
        for(i = 0; i < nApps; i++)
        {
            Apps[i]->DefaultConfig();
        }

        ...

    }

    ...

}

During debug, I step on line "Apps[i]->DefaultConfig();" and when I step into, I unexpectly fall into Init() function. 

I tryed to replace this call to "Apps[i]->Init();" and when I fall into some other function of ASMApp.

So, it looks like VMT is corrupt.

The same code on TM4C123F MCU works fine. The toolchain in both pports is ti-cgt-arm_20.2.0.LTS

Could anyone help with this issue? Thank you!

  • When you run the code normally, does it operate correctly?  If so, this might be a case of compiler optimization making it difficult to debug the code.

    Oleg Kobrin said:
    During debug, I step on line "Apps[i]->DefaultConfig();" and when I step into, I unexpectly fall into Init() function. 

    Does DefaultConfig call Init?  If Init is inlined, it might appear that way while debugging.

    Thanks and regards,

    -George

  • The optimization is turned off for all projects.

    DefaultConfig does not call Init.

  • Additional information:

    The issue exists in every class derived from JCApp.

  • Unfortunately, I only see one way forward.  And that is for you to send me the CCS project so I can reproduce the problem.  Like everyone else, I'm working from home.  I don't have any TM4C systems to experiment with, but I do have a different system where the CPU is an ARM Cortex-M4F.  So, there is a reasonable chance I will reproduce the problem.

    To create a zip of the project, please follow the directions in the article Sharing Projects.  If you are not comfortable with attaching it to a forum post, you are welcome to send it to me privately.  Hover your mouse over my screen name or avatar. A box will pop up. Click on Send a private message. In the message compose interface which comes up, use the paper clip icon to attach the zip file. 

    Thanks and regards,

    -George

  • Thanks!

    I see a way better: As I work from home too, remotely on my office computer, I can grant you TeamViewer access to this computer, where all the projects are open in CCS, and device is connected with XDS100 and working. This system is on 24/7, so you can access it any time.

    Here the short brief on the projects:

    1. Stucture. 

    • JC2_Kernel is a kernel library, where JCApp class defined. The header is in "include/kernel" directory, and implementation is in "kernel" directory.
    • JC2_HPLC_SimpleApps, JC2_HPLC_SDS, JC2_HPLC_CD512, JC2_HPLC_ECD2000, JC2_HPLC_ASM is the application libraries, each defines at least one class, derived from JC2App. SimpleApps has additional abstract class SimpleApp, derived from JCApp.
    • JC2_HPLC is a framework project, which is used to build final executable. It also has a static objects creation file static_objects.cpp to ensure creation order. Application objects are created from this file using AppFactory object.

    2. Problem localization.

    Currently device is configured to run DFCSApp application. Setting the breakpoint in DFCSApp constructor and restarting the device (as this constructor are called before main()) will catch the breakpoint. Step into InitConfig() call, then step over until DefaultConfig() call and step into it. You will unfortunately fall into DFCSApp::Init(). 

    Temporaryly replacing DefaultConfig() with any other member function of JCApp will show the same behaviour: you will fall into different function.

    I will send the TeamViewer login and password for you in private message.

    Thank you.

  • Unfortunately, the security measures TI has in place prevent me from installing TeamViewer.

    And it is likely I still would need to obtain the CCS project. My role is to gather a test case that reproduces the problem in a concise way. I then submit a bug report which the development team uses to investigate. They typically execute the build of the problem source files while the compiler tools are under control of a debugger. This allows them to find the root cause and fix it. The main point: The problem project cannot be located remotely.

    Thanks and regards,

    -George

  • Wird. Too bad. Without hardware it s too comprehensive to catch the issue. Even if you are working at home you cannot use TeamViewer? Maybe we can use any other remote desctop access? I.e. I can grant a RDP access via some tunnel?

    I'll try to send a project (in fact, several projects) to you. The simpliest way is to pass a git access to the repositories, but I need to contact my management to ask to provide an access.

    My hope was tonight the issue will be solwed somehow, but let us wait until tomorrow evening (here, your morning). Thank you anyway.

  • A few other things to consider ...

    Make sure the stack has not overflowed, and the heap is not exhausted. Make them both as big as you can, and see if that helps.  I doubt either of these things are the root cause of the problem. But I'd appreciate if you would try anyway.

    Consider the possibility that some other error causes the virtual table to be overwritten.  This is hard to catch.  The virtual tables are in the section .const.  Nothing in the .const section should change during execution.  So, try to capture a copy of it right after the program loads, and after things go bad, make sure it has not changed.

    Thanks and regards,

    -George

  • Hi!

    Heap and stack are large ehough, and even not used for 10%.

    .const section is located in FLASH, and cannot be changed. Anyway, that looks like virtual table is not fully corrupt, but just shifted (one word, I guess), and again, issue does not reproduce on TM4C123F MCU, only on TM4C1294 MCU.

    There are very fiew differences in build configurations for different MCUs:

    • Different clock initilization, and pin map;
    • lwIP used for TM4C1294, and protocol link layer for TCP added.

    Here is the zipped projects:

    HPLC.zip.txt

    The build configuration in JC2_HPLC project is "IP_Conv".

    BTW, we have teamviewer account with commertial subscription activated, I will send you a private message with login and password for it so you can use it to connect the computer.

  • Thank you for submitting the project.  I had lots of problems building it.  Somehow I overlooked that I needed to change the build configuration to IP_Conv.  Once I did that, it builds fine.  I apologize for that mistake.

    However, I do not have the hardware to run it.  A colleague does, but he is no longer available today.  I'll get to it on Monday.

    Thanks and regards,

    -George

  • Thank you!

    However, I dfo not think project will run just on some EVM without some patches, as the board is our design. Attaching the shematic here.

    АКЛС 105 550 001 Плата управляющего модуля с ethernet.pdf.txt

  • One more thing - how to reproduce an issue.

    1. You will need a python3 to run a simple program I attached. Also you will need to install pyserial module in python with "pip install pyserial" command.

    2. Dependant on which python you are using, windows or cygwin build, you will need to patch a run.py file as the following: determine which COM port the board after loading a project creates in Device Manager; edit the code:

        return Serial(
                    port='/dev/ttyS6',
                    baudrate=19200,
                    parity=PARITY_NONE,
                    stopbits=STOPBITS_ONE,
                    bytesize=EIGHTBITS,
                    xonxoff=False,
                    timeout=15,
                    rtscts=False,
                    dsrdtr=False
        )
    

    and replace port='...' with COMx for windows build or /dev/ttySn where n = COM port number - 1 for cygwin build.

    3. Open the DFCSApp.cpp file from JC2_HPLC_SimpleApps project in CCS and set the breakpoint at InitConfig(); call in DFCSApp constructor.

    4. Run "python3 run.py" from command line, and wait for "Enter bytes:" prompt. Enter "050011" and press enter, when enter "13" and press enter. The device will reboot, and breakpoint will hit. Step into InitConfig(), and step untill DefaultConfig() call. Step into it, and if issue exist, you will get into Init() instead of DefaultConfig().

    PK�mP@Ҹ^��protohelper.py�W]o�0}���`�R�[�4�Z�D{��4�!䀓Z٦j����0�棝�m4i0�>����kC�m��U�8?Si�8?X)�o8�b��@^_�@���efex-�i�����
    �V�B6���D��SAJ
    �,`�Z���R��l.A�,,�LR��L�*�kV���h�b_��,�l>Z��:L�u�����,A0Y:L(˘�c'=�w|A5�J�Y��Râb��ޯC�[D�8��l�=�rL;)o�B���Ŷ��:1V���)z�Hf��C�^�N�u�C.@���i�I��-8������ÌP�C8H�1=.O��➓s�č�����b��� '\�V�Bij;ٺ�]�u�$M�%B�e�A
    ࢶ����!2k
    Ӫ�	�Yd��8�x��5��$�Y���t��w��)i�~깔A�GN~��g�W�M�~ ����%�WW�܀	���A
    o�L�M�ꌥ��n����Z�N�R�
    �fI�����i����Y��C�T\����,.v=�uîE�X���ZN�ȱ^n.�O{�s��&*����r���LOw!xY.UA���<ဖb�h��t�w�W�m��E��ER�A��NY/}A�`b�/4*8Nh=,��";�%��)��
    bP�MOD�U���K�F>Vs�f\ۣ�x��'o�X���Ŵc'i�!LZ�YF>��1T���M������]����z`Q}�v�߰�[\���!
    ��2�ϱ���m�OL�}����V�h4��xe%3� t���I��C�<�2���=��S�"U�t����y�`�(s��R˩��^0���9�	��цv�e
    �:8�ܖ���%[�%I-7[�*�3��,�����(x3����L�۽��m�^��]g~�曁�=�PKkoP͒��r
    run.py�V[o�6~7��p����l�A&D�"k�iP�e(RA�㄃E
    $��+��>R�]�{�S����\��9H4>�.l��%<���n�Ot���v	�݇���vۨz��{�ng�EP��3
    
    ʃ��D��|3�C��Ȉ8����I���1P��2�//�:m����&��L�
    ��ߟ1(bA�)��35��	U2d:�P��0l9�1:rv��}�w|�8�W4G^�p�jF)�L�<�I�)a�V�
    	N\"I9kH�Ǖ�,"J(#�|U�"�X�˵��[�_'�/V{.�X��}�(�֡=�1�J�4�0�o�g@%�s����������|P�KV��+b
    �TM�N����W5"5�`���� �޽&Z�Nd|��1{B�/��:u�/!&�o6������>Ij�ا�[�yskco2�.�Y��u�7Y���4����AuװRՠ��6nV�,tsA؛aga�C�Y&PJ�R;*#�,�LK�>U�T���3= �D٤CU�f�"��Y_yu)Bؚ|�ͣUX�V�	�2*0U��%��1c�7�^4ňfZ�N.���V�*����V�<�(��X׺it�+�2���I=zt#�~��e6�h������ꓳh�;&+<��!�{�P�qu�|�n�:�Z����'��9�͔�Ѧ����yS7`��#�d#�f�1n�֏�h�/�G->�GM�*�&���%5���_��7��)v�nO]6�W��x�|:�G�e+">��[��[��:kH��4ZiI�Kk�,&�}�ՠ�Mu�Qy�8z־��o�Zޭ��L �Do��K�6��Ø��$�b��K|&�7��f�]W�GU��f	nB�\���^�;_¼�L�n��iܼ��Tct�ܾ��!س��N7˱��p�ʟa�1�B�{<%<ٝ!Q��Z�f��PK�mP@Ҹ^��$ protohelper.py
     z��I�����I�����I�PKkoP͒��r
    $��run.py
     H5SoK�H5SoK�	���I�PK��

  • Further conversations on this issue were held via private messages.  It turns out the problem was a failure to predefine a preprocessor symbol while building one of the library sub-projects.

    Thanks and regards,

    -George