I also wouldn't suggest taking anything right before or during an activity. If there is an underlying problem causing the pain, it definitely isn't going to resolve itself without rest.
Also, ibuprofen, and most other NSAID's can be hard on the kidneys and body if you do not have plenty of water - more than typical. This would be hard to regulate during a workout.
Just take it easy and recover.