Merge lp:~gebner/compiz/compiz.vertexbuffer-autoprogram-uniform-segfault into lp:compiz/0.9.10

Proposed by Sam Spilsbury
Status: Merged
Approved by: Sam Spilsbury
Approved revision: 3645
Merged at revision: 3645
Proposed branch: lp:~gebner/compiz/compiz.vertexbuffer-autoprogram-uniform-segfault
Merge into: lp:compiz/0.9.10
Diff against target: 12 lines (+1/-1)
1 file modified
plugins/opengl/src/vertexbuffer.cpp (+1/-1)
To merge this branch: bzr merge lp:~gebner/compiz/compiz.vertexbuffer-autoprogram-uniform-segfault
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Sam Spilsbury Approve
Daniel van Vugt Pending
Review via email: mp+156468@code.launchpad.net

This proposal supersedes a proposal from 2013-03-31.

Commit message

Adding a uniform to a GLVertexBuffer that uses AutoProgram causes compiz to segfault.

Example:
  gWindow->addShaders("cms", "", fragment_shader);
  gWindow->vertexBuffer()->addUniform("cms_lut", unit);
  // segfault happens later in PrivateVertexBuffer::render

The patch modifies PrivateVertexBuffer::render to set the uniform on the generated AutoProgram instead of the provided program, which in this case is NULL, causing a segfault.

(LP: #1162598)

Description of the change

Adding a uniform to a GLVertexBuffer that uses AutoProgram causes compiz to segfault.

Example:
  gWindow->addShaders("cms", "", fragment_shader);
  gWindow->vertexBuffer()->addUniform("cms_lut", unit);
  // segfault happens later in PrivateVertexBuffer::render

The patch modifies PrivateVertexBuffer::render to set the uniform on the generated AutoProgram instead of the provided program, which in this case is NULL, causing a segfault.

This feature is used in a plugin for full-screen color management, compiz-cms[1], where the unit of a color transformation texture is passed as a uniform.

[1] https://github.com/gebner/compiz-cms

To post a comment you must log in.
Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

This makes sense, thanks.

This reminds me that I need to fix the VertexBuffer class to behave in a more sane way when it comes to having no active program set. At the moment it just crashes if you don't call setProgram or setAutoProgram. I remember I wanted to enforce something in its constructor, but at the time didn't want to break ABI. I've filed bug 1162597 about that.

One more thing before we merge this - can you add commit metadata to link this to a bug? I didn't see anything, so I've filed bug 1162598. You can link it by doing this:

bzr commit --empty --fixes lp:1162598
bzr push

On another note, nice work with the color management plugin. If you want it to be included in-tree, just file a bug about it on launchpad and we'll do the paperwork to get it in.

review: Approve
Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Please re-target this for lp:compiz/0.9.10

review: Needs Resubmitting
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

As above

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

The "server already running" thing could possibly be caused by:

1. A stale connection on the CI server
2. A race condition where multiple CI jobs are running on the same system (and they both pick :133)

We should probably fix the xorg-gtest code to try and pick another socket in that case, but for now.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/opengl/src/vertexbuffer.cpp'
--- plugins/opengl/src/vertexbuffer.cpp 2012-11-04 16:15:51 +0000
+++ plugins/opengl/src/vertexbuffer.cpp 2013-04-02 07:11:15 +0000
@@ -523,7 +523,7 @@
523 // set per-plugin uniforms523 // set per-plugin uniforms
524 for (unsigned int i = 0; i < uniforms.size (); i++)524 for (unsigned int i = 0; i < uniforms.size (); i++)
525 {525 {
526 uniforms[i]->set (program);526 uniforms[i]->set (tmpProgram);
527 }527 }
528528
529 //convert paint attribs to 0-1 range529 //convert paint attribs to 0-1 range

Subscribers

People subscribed via source and target branches