Simulator crashes when creating an instance of an object

I don’t know if this is the right place to post this question. Please move it if it fits better somewhere else.

The logic is simplified for the sake of explaining the problem.

I have a game.lua class calling my bump.lua and ball.lua classes
[lua]-- vars
local bumps = {};
–Classes
local ball = require(“ball”);
local bump = require(“bump”);[/lua]

I have two functions in game.lua. The first initiate the bumps creating 30 instances of a bump like this:
[lua] local function initBumps(30)
local yPos = HEIGHT * 0.5;
–Create an instance of a bump
for i = 0, numberOfBumps do
local b = bump.newBump();
bumps[b] = b;
bumps[b].x = m.random(bumps[b].width / 2, WIDTH - bumps[b].width / 2);
bumps[b].y = yPos;
yPos = yPos - m.random(50, 400);
background:insert(bumps[b]);
end
end[/lua]

Then I have another function to create additional instances of a bump
[lua] local function spawnBumps()
local b = bump.newBump();
end[/lua]

bump.lua
[lua]module(…, package.seeall);

function newBump()

local bump = display.newRect(0, 0, 50, 15);

–Custom properties
bump.type = “bump”;
bump.hit = false;
bump.points = 1;

physics.addBody(bump, “static”);
bump.isSensor = true;

function bump:remove()
–immediately hide the object;
self.isVisible = false;
self:removeSelf();
self = nil;
collectgarbage(“collect”);
end

return bump;

end[/lua]

The ball.lua class checks for collision against a bump and calls
[lua]e.other:remove();[/lua]

So far everything is working fine. I initiate 30 bumps on the screen and when the ball collides with a bump, the bump is removed.

Problem occurs when I also try to create a new instance of a bump when the ball collides with a bump. Trying to find what line causes the simulator to crash, I have found that it is this code:
[lua]physics.addBody(bump, “static”);[/lua]

The only error message I get is different numbers of “Bus error”.

Am I doing something very wrong here or what? [import]uid: 41041 topic_id: 9295 reply_id: 309295[/import]

I’m going to answer my own question here. Apparently this is caused by a problem in Box2d. It is explained here - Corona Collision No-No. [import]uid: 41041 topic_id: 9295 reply_id: 33946[/import]