Reputation: 72
I have an multithreaded C++ application using GDK Cairo that inconsistently crashes on different lines but approximately all of the segmentation faults happen on the line Gdk::Cairo::set_source_pixbuf(cr, image, 0, 0);
under a certain condition when I click my a 'save' button. (Using Glade as a UI framework).
std::string DefectWindowBase::save_image(Glib::RefPtr<Gdk::Pixbuf>& image, std::string filename) {
int width = image->get_width();
int height = image->get_height();
Cairo::Format format = (image->get_has_alpha() ? Cairo::FORMAT_ARGB32 : Cairo::FORMAT_RGB24);
auto surface = Cairo::ImageSurface::create(format, width, height);
auto cr = Cairo::Context::create(surface);
Gdk::Cairo::set_source_pixbuf(cr, image, 0, 0);
cr->rectangle(0, 0, width, height);
cr->fill();
sig_draw_rawoverlay.emit(cr, width, height, false);
// Scale will not be drawn if it is not enabled
sig_draw_scale.emit(cr, width, height);
bool pathsHaveExternalFile = (mJobFilePaths.filePaths().size() >= 2);
// Create a worker to save the local and remote images to file
workers.push_back(std::make_shared<ImageWriteWorker>(surface, mJobFilePaths.getMainFilePath(),
pathsHaveExternalFile ? mJobFilePaths.filePaths().at(1) : "",
filename));
// Connect the workers "completed" signal to a tidy up function to clean up the memory used after the images are saved
workers.back()->sig_completed.connect(
sigc::bind(sigc::mem_fun(this, &DefectWindowBase::tidy_worker), workers.back()));
return filename;
}
Here is my IDE view with GDB pausing on the exception. libgdk3.0.0
seems to be segfaulting but I do not have symbols. Any ideas why I might be segfault-ing here or any advice to debug further? I would ideally like to see exactly the root cause of the segfault.
Upvotes: 0
Views: 74