Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Valgrind Invalid write of size 8 with QGLBuffer map
QtWS25 Last Chance

Valgrind Invalid write of size 8 with QGLBuffer map

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    belimawr
    wrote on last edited by
    #1

    I am using Qt + OpenGL + GLSL to draw a lot points in a 3D scene and I need to change the color of some points.

    To initialize the color VBO I did that:

    @cores = new QVector3D[num_vertices];
    for(int i = 0; i < num_vertices; i++)
    cores[i] = QVector3D(1.0, 1.0, 1.0);
    m_vboCores = new QGLBuffer(QGLBuffer::VertexBuffer);
    m_vboCores->create();
    m_vboCores->bind();
    m_vboCores->setUsagePattern(QGLBuffer::DynamicDraw);
    m_vboCores->allocate(cores, num_vertices*sizeof(QVector3D));@

    In the application I change the value of some elements in cores vector, and in the paintGL function I am doing that:

    @m_vboCores->bind();
    QVector3D vCores = (QVector3D) m_vboCores->map(QGLBuffer::WriteOnly);
    for(i = 0; i < num_vertices; i++)
    vCores[i] = cores[i];
    m_vboCores->unmap();
    m_shaderProgram->enableAttributeArray("Cor_Vertice");
    m_shaderProgram->setAttributeBuffer("Cor_Vertice", GL_FLOAT, 0, 3, 0);@

    And Valgrind says that are invalid write in this line:

    @vCores[i] = cores[i];@

    But I have used printf to check the value of i, and the index i is not out of bound... What can I doing wrong?

    Or how can I check the size of memory "returned" by

    @m_vboCores->map(QGLBuffer::WriteOnly)@

    1 Reply Last reply
    0
    • B Offline
      B Offline
      belimawr
      wrote on last edited by
      #2

      I tested this code in other machines and in some of them it worked well, so the problem looks be in some combination of hardware + kernel + video driver + system libraries.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved