Framebuffer fbo unknown error

I really can’t see why this code results in an error. AFAIK I am only beginning and ending a single framebuffer, and the framebuffer is allocated correctly with fbo.allocate(blocks, trackHeight, GL_RGBA);

fbo.begin();

ofClear(0,0,0,0);
ofSetColor(255,255,255,255);
for(j = 0; j < blocks; j++)
{
ofDrawRectangle((float)j, trackHeight * 0.5, 0.0f, 1.0f, trackHeight * 0.5 * upWave[j]);
ofDrawRectangle((float)j, trackHeight * 0.5, 0.0f, 1.0f, trackHeight * 0.5 * dnWave[j]);
}
fbo.end();
fbo.readToPixels(trackPix);

The errors I get are as follows:

[ error ] ofFbo: UNKNOWN ERROR 0
[warning] Framebuffer with id: 0 cannot be bound onto itself.
Most probably you forgot to end() the current framebuffer before calling begin() again or you forgot to allocate() before calling begin().

I can’t see what I am doing wrong here.

Is “blocks” and “trackHeight” defined before in your case ?

I’ve just tested this and it works for me fine with blocks=640 and trackHeight=480, as @Dorald suggests, check that those variables are initialized and which value they have when allocating the fbo

After weeks of bashing my head against a brick wall I am finally getting this to work.
The major difference in what I have now is that the fbo is initialized separately from the drawing, i.e.

gFbo.begin();

gFbo.clear(0,0,0,0);
gFbo.end();

…followed by…

ofSetColor(255,255,255,255);

gFbo.begin();
for(j=0 ; j<blocks; j++)
{
//get values from a vector
float midPoint = 0.5 * (float)trackHeight;
float upLimit = waveUp[j] * (float)trackHeight * 0.5;
float dnLimit = waveDn[j] * (float)trackHeight * 0.5;
ofDrawRectangle((float)j, midPoint, 0.0f, 1.0f, upLimit);
ofDrawRectangle((float)j, midPoint, 0.0f, 1.0f, dnLimit);
}

This seems to work. Yes, blocks and trackHeight are initialised, although I’m having to send values back and forth from the ofxPd patch in the right order. I’ve also removed things like ofSetColor from within the fbo.begin() and fbo.end() statements.