Project

General

Profile

Actions

Bug #11306

closed

Segmentation fault

Added by dsaronin (David Anderson) almost 9 years ago. Updated almost 9 years ago.

Status:
Third Party's Issue
Assignee:
-
Target version:
-
ruby -v:
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux]
[ruby-core:69736]

Description

bug is detected during CUPS call in cups gem (https://github.com/m0wfo/cups) v0.1.10. The complete core dump is attached as file 'dump.txt'.

the following works okay:

2.2.1 :001 > list = Cups.show_destinations
 => ["laserjet_1102w", "lp_null"] 
2.2.1 :002 > Cups.device_uri_for( list.first )
 => "hp:/net/HP_LaserJet_Professional_P_1102w?ip=192.168.0.65" 
2.2.1 :003 > Cups.device_uri_for( list.last )
 => "file:///dev/null" 

the following fails (the order is not important; the second call always fails with abort):

2.2.1 :001 > list = Cups.show_destinations
 => ["laserjet_1102w", "lp_null"] 
2.2.1 :002 > CupsDevice.testit( list.first )
 => "hp:/net/HP_LaserJet_Professional_P_1102w?ip=192.168.0.65" 
2.2.1 :003 > CupsDevice.testit( list.last )
/home/daudi/projectspace/swalapala/app/models/cups_device.rb:101: [BUG] Segmentation fault at 0x0000000a491862
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux]

where:

class CupsDevice < ActiveRecord::Base
  def self.testit( cups_name )
       Cups.device_uri_for( cups_name )
  end
end # class CupsDevice

and in the cups gem:

  rb_define_singleton_method(rubyCups, "device_uri_for", cups_get_device_uri, 1);


static VALUE cups_get_device_uri(VALUE self, VALUE printer)
{
   if (!printer_exists(printer))
   {
     rb_raise(rb_eRuntimeError, "The printer or destination doesn't exist!");
   }

   VALUE options_list;
   http_t *http;
   ipp_t *request;
   ipp_t *response;
   ipp_attribute_t *attr;
   char uri[1024];
   char *location;
   char *name = RSTRING_PTR(printer);

   request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES);
   httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, "localhost", 0, "/printers/%s", name);
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri);

   if ((response = cupsDoRequest(http, request, "/")) != NULL)
   {
     if((attr = ippFindAttribute(response, "device-uri", IPP_TAG_URI)) != NULL)
     {
       return rb_str_new2(attr->values[0].string.text);
     }
     ippDelete(response);
   }
   return Qtrue;
}

Files

dump.txt (206 KB) dump.txt core dump due to segmentation fault dsaronin (David Anderson), 06/25/2015 07:39 AM
cups_device.rb (3.43 KB) cups_device.rb class CupsDevice#testit which triggers the fault dsaronin (David Anderson), 06/25/2015 07:40 AM
cups.c (14.2 KB) cups.c cups gem C code for Cups#device_uri_for dsaronin (David Anderson), 06/25/2015 07:42 AM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0