Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some kind of recursion crash #1439

Closed
michaelrsweet opened this issue Feb 24, 2006 · 6 comments
Closed

Some kind of recursion crash #1439

michaelrsweet opened this issue Feb 24, 2006 · 6 comments

Comments

@michaelrsweet
Copy link
Collaborator

Version: 1.1.23
CUPS.org User: twaugh.redhat

See bugzilla bug #178999:

https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=178999

cupsd can get into a state where it apparently runs out of stack while timing out a browsed printer:
#0 DeletePrinterFromClasses (p=0x5555556e6060) at classes.c:218
#1 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#2 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556e52d0)

at classes.c:222

#3 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#4 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556eaca0)

at classes.c:222

#5 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#6 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556e3f90)

at classes.c:222

#7 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#8 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556e31f0)

at classes.c:222

#9 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#10 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556e2460)

at classes.c:222

#11 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#12 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556e16c0)

at classes.c:222

#13 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#14 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556e0930)

at classes.c:222

#15 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
---Type to continue, or q to quit---
#16 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556dfbc0)

at classes.c:222

#17 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#18 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556e4820)

at classes.c:222

#19 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#20 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556dda80)

at classes.c:222

#21 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#22 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556dccf0)

at classes.c:222

#23 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#24 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556dbf50)

at classes.c:222

#25 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#26 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556db1c0)

at classes.c:222

#27 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#28 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556da420)

at classes.c:222

#29 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#30 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556dee50)

at classes.c:222

---Type to continue, or q to quit---
#31 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#32 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556d8fc0)

at classes.c:222

#33 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#34 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556d8230)

at classes.c:222

#35 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#36 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556d74d0)

at classes.c:222

#37 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#38 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556d6740)

at classes.c:222

#39 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#40 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556d59a0)

at classes.c:222

#41 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#42 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556d9920)

at classes.c:222

#43 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#44 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556d3940)

at classes.c:222

#45 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#46 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556d2bf0)

---Type to continue, or q to quit---
at classes.c:222
#47 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#48 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556d1e90)

at classes.c:222

#49 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#50 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556cf960)

at classes.c:222

#51 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#52 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556cebf0)

at classes.c:222

#53 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#54 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556c4880)

at classes.c:222

#55 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#56 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556a2e30)

at classes.c:222

#57 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#58 0x000055555555eca9 in DeletePrinterFromClasses (p=0x555555712050)

at classes.c:222

#59 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#60 0x000055555555eca9 in DeletePrinterFromClasses (p=0x555555707fe0)

at classes.c:222

#61 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
---Type to continue, or q to quit---
#62 0x000055555555eca9 in DeletePrinterFromClasses (p=0x555555707280)

at classes.c:222

#63 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#64 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555557064f0)

at classes.c:222

#65 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#66 0x000055555555eca9 in DeletePrinterFromClasses (p=0x555555705740)

at classes.c:222

#67 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#68 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555557049b0)

at classes.c:222

#69 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#70 0x000055555555eca9 in DeletePrinterFromClasses (p=0x555555703c10)

at classes.c:222

#71 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#72 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556fddb0)

at classes.c:222

#73 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#74 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556fd010)

at classes.c:222

#75 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#76 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556fc2c0)

at classes.c:222

---Type to continue, or q to quit---
#77 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#78 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556fb510)

at classes.c:222

#79 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#80 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556fa780)

at classes.c:222

#81 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#82 0x000055555555eca9 in DeletePrinterFromClasses (p=0x555555700630)

at classes.c:222

#83 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#84 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556f5aa0)

at classes.c:222

#85 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#86 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556f3f20)

at classes.c:222

#87 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#88 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556eb8f0)

at classes.c:222

#89 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#90 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556f16c0)

at classes.c:222

#91 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#92 0x000055555555eca9 in DeletePrinterFromClasses (p=0x5555556a2020)

---Type to continue, or q to quit---
at classes.c:222
#93 0x00005555555804d5 in DeletePrinter (p=Variable "p" is not available.

) at printers.c:632
#94 0x0000555555569923 in SendBrowseList () at dirsvc.c:619
#95 0x000055555556c9e9 in main (argc=Variable "argc" is not available.

) at main.c:889

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: till.kamppeter

Is it possible that there are relationships between this CUPS 1.1.x bug and the CUPS 1.2.x bugs STR #1417 and STR #1432. At least according to the error_log output of STR #1417 crashes also happen on timing out remote printers.

Links:
http://www.cups.org/str.php?U1417
http://www.cups.org/str.php?U1432

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

I'm not able to reproduce this in 1.2, but I'm not aware of any specific fixes we've made for this...

What patches have you made, if any, to classes.c, dirsvc.c, or printers.c?

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

OK, a quick update - I ran 1.2 through Valgrind with a variable load of remote classes with multiple servers and was able to identify a possible cause of the problem - the printer MIME type is not getting reassociated when the remote printer/class is renamed, which could cause a crash due to a double-free of the MIME type.

I'll be committing a fix for this shortly to trunk that adds a new "cupsdRenamePrinter()" function that the dirsvc.c and ipp.c code can use when renaming printers and classes. Feel free to back-port the fix to your 1.1.23 packages...

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

Till: It is possible; this is the first case where I was able to a) reproduce it, and b) localize the problem to printer timeouts.

Tim/Till: I've commited a fix for this in r5164, and attached the patch which you may be able to backport to 1.1.23. Basically, any place we rename a printer we want to update the filetype to point to the new MIME type. I added a function in 1.2, but you might just use:

p->filetype = mimeNewType(MimeDatabase, "printer", p->name);

in all the places where the p->name is set.

Please let me know if you continue to have problems...

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

This STR has not been updated by the submitter for two or more weeks and has been closed as required by the CUPS Configuration Management Plan. If the issue still requires resolution, please re-submit a new STR.

@michaelrsweet
Copy link
Collaborator Author

"str1439.patch":

Index: ipp.c

--- ipp.c (revision 5163)
+++ ipp.c (working copy)
@@ -773,6 +773,7 @@
const char dest; / Printer or class name /
ipp_attribute_t *attr; /
Printer attribute /
int modify; /
Non-zero if we just modified */

  • char newname[IPP_MAX_NAME]; /* New class name /
    int need_restart_job; /
    Need to restart job? */

@@ -864,9 +865,8 @@

 if (ImplicitAnyClasses)
 {
  •  cupsArrayRemove(Printers, pclass);
    
  •  cupsdSetStringf(&pclass->name, "Any%s", resource + 9);
    
  •  cupsArrayAdd(Printers, pclass);
    
  •  snprintf(newname, sizeof(newname), "Any%s", resource + 9);
    
  •  cupsdRenamePrinter(pclass, newname);
    

    }
    else
    cupsdDeletePrinter(pclass, 1);
    @@ -884,11 +884,8 @@

    • Rename the remote class to "Class"...
      */
  • cupsdDeletePrinterFilters(pclass);

  • cupsArrayRemove(Printers, pclass);

  • cupsdSetStringf(&pclass->name, "%s@%s", resource + 9, pclass->hostname);

  • cupsdSetPrinterAttrs(pclass);

  • cupsArrayAdd(Printers, pclass);

  • snprintf(newname, sizeof(newname), "%s@%s", resource + 9, pclass->hostname);

  • cupsdRenamePrinter(pclass, newname);

/*

  • Add the class as a new local class...
    @@ -1993,6 +1990,7 @@
    char srcfile[1024], /* Source Script/PPD file /
    dstfile[1024]; /
    Destination Script/PPD file /
    int modify; /
    Non-zero if we are modifying */
  • char newname[IPP_MAX_NAME]; /* New printer name /
    int need_restart_job; /
    Need to restart job? */

@@ -2083,9 +2081,8 @@

 if (ImplicitAnyClasses)
 {
  •  cupsArrayRemove(Printers, printer);
    
  •  cupsdSetStringf(&printer->name, "Any%s", resource + 10);
    
  •  cupsArrayAdd(Printers, printer);
    
  •  snprintf(newname, sizeof(newname), "Any%s", resource + 10);
    
  •  cupsdRenamePrinter(printer, newname);
    

    }
    else
    cupsdDeletePrinter(printer, 1);
    @@ -2103,11 +2100,9 @@

    • Rename the remote printer to "Printer@server"...
      */
  • cupsdDeletePrinterFilters(printer);

  • cupsArrayRemove(Printers, printer);

  • cupsdSetStringf(&printer->name, "%s@%s", resource + 10, printer->hostname);

  • cupsdSetPrinterAttrs(printer);

  • cupsArrayAdd(Printers, printer);

  • snprintf(newname, sizeof(newname), "%s@%s", resource + 10,

  •         printer->hostname);
    
  • cupsdRenamePrinter(printer, newname);

/*

  • Add the printer as a new local printer...

    Index: dirsvc.c

    --- dirsvc.c (revision 5163)
    +++ dirsvc.c (working copy)
    @@ -792,7 +792,8 @@
    p->name);

    cupsdLogMessage(CUPSD_LOG_INFO,

  •               "Remote destination \"%s\" has timed out; deleting it...",
    
  •               "Remote destination \"%s\" has timed out; "
    
  •       "deleting it...",
                p->name);
    
     cupsArraySave(Printers);
    

    @@ -805,7 +806,8 @@

    /*

  • * 'cupsdSendCUPSBrowse()' - Send new browsing information using the CUPS protocol.

  • * 'cupsdSendCUPSBrowse()' - Send new browsing information using the CUPS

    •                       protocol.
      
      */

    void
    @@ -2253,6 +2255,7 @@
    int update; /* Update printer attributes? /
    char finaluri[HTTP_MAX_URI], /
    Final URI for printer /
    name[IPP_MAX_NAME], /
    Name of printer */

  •   newname[IPP_MAX_NAME],  /* New name of printer */
    *hptr,          /* Pointer into hostname */
    *sptr;          /* Pointer into ServerName */
    

    char local_make_model[IPP_MAX_NAME];
    @@ -2391,10 +2394,8 @@
    "Class '%s' deleted by directory services.",
    p->name);

  •        cupsArrayRemove(Printers, p);
    
  •        cupsdSetStringf(&p->name, "%s@%s", p->name, p->hostname);
    
  •   cupsdSetPrinterAttrs(p);
    
  •   cupsArrayAdd(Printers, p);
    
  •        snprintf(newname, sizeof(newname), "%s@%s", p->name, p->hostname);
    
  •        cupsdRenamePrinter(p, newname);
    
    cupsdAddEvent(CUPSD_EVENT_PRINTER_ADDED, p, NULL,
                  "Class \'%s\' added by directory services.",
    

    @@ -2496,10 +2497,8 @@
    "Printer '%s' deleted by directory services.",
    p->name);

  •   cupsArrayRemove(Printers, p);
    
  •   cupsdSetStringf(&p->name, "%s@%s", p->name, p->hostname);
    
  •   cupsdSetPrinterAttrs(p);
    
  •   cupsArrayAdd(Printers, p);
    
  •        snprintf(newname, sizeof(newname), "%s@%s", p->name, p->hostname);
    
  •        cupsdRenamePrinter(p, newname);
    
    cupsdAddEvent(CUPSD_EVENT_PRINTER_ADDED, p, NULL,
                  "Printer \'%s\' added by directory services.",
    

    @@ -2767,6 +2766,9 @@

     cupsdLogMessage(CUPSD_LOG_INFO, "Added implicit class \"%s\"...",
                name);
    
  • cupsdAddEvent(CUPSD_EVENT_PRINTER_ADDED, p, NULL,

  •                  "Implicit class \'%s\' added by directory services.",
    
  •         name);
    

    }

    if (first != NULL)

    Index: printers.c

    --- printers.c (revision 5163)
    +++ printers.c (working copy)
    @@ -32,6 +32,7 @@

    • cupsdFindPrinter() - Find a printer in the list.
    • cupsdFreePrinterUsers() - Free allow/deny users.
    • cupsdLoadAllPrinters() - Load printers from the printers.conf file.
    • cupsdRenamePrinter() - Rename a printer.
    • cupsdSaveAllPrinters() - Save all printer definitions to the
    •                             printers.conf file.
      
    • cupsdSetPrinterAttrs() - Set printer attributes based upon the PPD
      @@ -1226,6 +1227,53 @@

    /*

  • * 'cupsdRenamePrinter()' - Rename a printer.

  • */
    +
    +void
    +cupsdRenamePrinter(

  • cupsd_printer_t p, / I - Printer */

  • const char name) / I - New name */
    +{

  • /*

  • * Remove the printer from the array(s) first...

  • */

  • cupsArrayRemove(Printers, p);
  • if (p->type & CUPS_PRINTER_IMPLICIT)
  • cupsArrayRemove(ImplicitPrinters, p);
  • /*
  • * Rename the printer type...
  • */
  • mimeDeleteType(MimeDatabase, p->filetype);
  • p->filetype = mimeAddType(MimeDatabase, "printer", name);
  • /*
  • * Rename the printer...
  • */
  • cupsdSetStringf(&p->name, name);
  • /*
  • * Reset printer attributes...
  • */
  • cupsdSetPrinterAttrs(p);
  • /*
  • * Add the printer back to the printer array(s)...
  • */
  • cupsArrayAdd(Printers, p);
  • if (p->type & CUPS_PRINTER_IMPLICIT)
  • cupsArrayAdd(ImplicitPrinters, p);
    +}

+/*

  • 'cupsdSaveAllPrinters()' - Save all printer definitions to the printers.conf
  •                        file.
    

    */
    Index: printers.h

    --- printers.h (revision 5163)
    +++ printers.h (working copy)
    @@ -126,6 +126,7 @@
    extern void cupsdFreePrinterUsers(cupsd_printer_t *p);
    extern void cupsdFreeQuotas(cupsd_printer_t *p);
    extern void cupsdLoadAllPrinters(void);
    +extern void cupsdRenamePrinter(cupsd_printer_t *p, const char *name);
    extern void cupsdSaveAllPrinters(void);
    extern void cupsdSetPrinterAttrs(cupsd_printer_t *p);
    extern void cupsdSetPrinterReasons(cupsd_printer_t *p, const char *s);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant