Skip to content

[BUG] Illegal module insertion occurred #13

@kazogihara

Description

@kazogihara

Issue description

Hi!
I found a bug at module insertion function in context menu.
Module can be inserted even if clicking non connector portion.

Context (Environment)

What's the expected result?

  • Can not insert block when click non connector portion

What's the actual result?

  • Can insert block when click non connector portion

Steps to reproduce the issue

Note: This may not be happen depending on memory state.
Video:
https://www.youtube.com/watch?v=l8awqUfgwUA&ab_channel=TEMMIEHOIHOI

config.xml

<?xml version="1.0" standalone="no" ?>
<world gridSize="5,5,5">
    <blockList blockSize="10,10,10">
        <block position="1,1,1" color="255,140,0" orientation="3" />
    </blockList>
</world>

Possible Solution

Set a value({0, 0, 0}) when clicking non connector portion to tabConnectorPositions.

In my view, the reason is that tabConnectorPositions doesn't have argument corresponding to non-connector spot.
This caused a buffer overrun, which resulted in an incorrect value for realPos.
Following is log of that time.

Thread 1 "myMotionTest" hit Breakpoint 1, Catoms3D::Catoms3DBlock::getNeighborPos (this=0xe15c8980, connectorID=56 '8', pos=...) at robots/catoms3D/catoms3DBlock.cpp:160
160         bool Catoms3DBlock::getNeighborPos(uint8_t connectorID, Cell3DPosition &pos) const {
(gdb) n
161             Vector3D realPos;
(gdb) n
163             Catoms3DWorld *wrl = getWorld();
(gdb) n
164             const Vector3D bs = wrl->lattice->gridScale;
(gdb) n
166             realPos.set(tabConnectorPositions[connectorID], 3, 1);
(gdb) p bs
$4 = {_pt = {10, 10, 10, 0}}
(gdb) n
167             realPos *= bs;
(gdb) p realPos
$5 = {_pt = {0.000748447317, 7.13885687e+31, 5.66773757e-08, 1}}
(gdb) n
168             realPos.set(3,1.0); // A vérifier
(gdb) p realPos
$6 = {_pt = {0.00748447329, 7.13885668e+32, 5.66773735e-07, 0}}
(gdb) n
169             realPos = ((Catoms3DGlBlock *) ptrGlBlock)->mat * realPos;
(gdb) p realPos
$7 = {_pt = {0.00748447329, 7.13885668e+32, 5.66773735e-07, 1}}
(gdb) n
170             if (realPos[2] < 0) return false;
(gdb) p realPos
$8 = {_pt = {3.56942795e+32, 3.56942795e+32, -5.04793378e+32, 1}}

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