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

crash when logging loading of job attributes #4658

Closed
michaelrsweet opened this issue Jun 30, 2015 · 2 comments
Closed

crash when logging loading of job attributes #4658

michaelrsweet opened this issue Jun 30, 2015 · 2 comments

Comments

@michaelrsweet
Copy link
Collaborator

Version: 2.1b1
CUPS.org User: jpopelka

Running 2.1b1 results in crash:

(gdb) bt
#0 0x0000555555594ea8 in cupsdLogJob (job=job@entry=0x555555836c40, level=level@entry=8, message=message@entry=0x5555555b0a5b "Loading attributes...") at log.c:687
#1 0x000055555558af28 in cupsdLoadJob (job=0x555555836c40) at job.c:1812
#2 0x000055555558bdce in load_request_root () at job.c:4690
#3 0x00005555555923d2 in cupsdLoadAllJobs () at job.c:1762
#4 0x0000555555580daa in cupsdReadConfiguration () at conf.c:1762
#5 0x000055555556d72f in main (argc=, argv=) at main.c:580

It crashes because cupsdLogJob() tries to print out info about not yet loaded job.

(gdb) display *job
2: *job = {id = 1, priority = 0, dirty = 0, state_value = 0, pending_timeout = 0, username = 0x0, dest = 0x0, name = 0x0, koctets = 0, dtype = 0, printer = 0x0, num_files = 0, filetypes = 0x0, compressions = 0x0, impressions = 0x0, sheets = 0x0, access_time = 0, cancel_time = 0, creation_time = 0, completed_time = 0, file_time = 0, history_time = 0, hold_until = 0, kill_time = 0, state = 0x0, reasons = 0x0, job_sheets = 0x0, printer_message = 0x0, printer_reasons = 0x0, current_file = 0, attrs = 0x555555836e20, print_pipes = {-1, -1}, back_pipes = {-1, -1}, side_pipes = {-1, -1}, status_pipes = {-1, -1}, status_buffer = 0x0, status_level = 0, cost = 0, pending_cost = 0, filters = {0 <repeats 21 times>}, backend = 0, status = 0, tries = 0, completed = 0, retry_as_raster = 0, auth_env = {0x0, 0x0, 0x0}, auth_uid = 0x0, profile = 0x0, bprofile = 0x0, history = 0x0, progress = 0, num_keywords = 0, keywords = 0x0, scon = 0x0, auid = 0}

(gdb) display job->printer
4: job->printer = (cupsd_printer_t *) 0x0

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

Fixed in Subversion repository.

@michaelrsweet
Copy link
Collaborator Author

"str4658.patch":

Index: scheduler/log.c

--- scheduler/log.c (revision 12773)
+++ scheduler/log.c (working copy)
@@ -595,6 +595,7 @@
asl_object_t m; /* Log message /
char job_id[32], /
job-id string /
completed[32]; /
job-impressions-completed string */

  • cupsd_printer_t printer = job->printer ? job->printer : cupsdFindDest(job->dest);
    static const char * const job_states[] =
    { /
    job-state strings */
    "Pending",
    @@ -611,7 +612,7 @@
    m = asl_new(ASL_TYPE_MSG);
    asl_set(m, ASL_KEY_FACILITY, "org.cups.cupsd");
    asl_set(m, PWG_Event, "JobStateChanged");
  • asl_set(m, PWG_ServiceURI, job->printer->uri);
  • asl_set(m, PWG_ServiceURI, printer->uri);
    asl_set(m, PWG_JobID, job_id);
    asl_set(m, PWG_JobState, job_states[job->state_value - IPP_JSTATE_PENDING]);

@@ -632,6 +633,7 @@
#elif defined(HAVE_SYSTEMD_SD_JOURNAL_H)
if (!strcmp(ErrorLog, "syslog"))
{

  • cupsd_printer_t printer = job->printer ? job->printer : cupsdFindDest(job->dest);
    static const char * const job_states[] =
    { /
    job-state strings */
    "Pending",
    @@ -658,7 +660,7 @@
    sd_journal_send("MESSAGE=%s", log_line,
    "PRIORITY=%i", log_levels[level],
    PWG_Event"=JobStateChanged",

  •       PWG_ServiceURI"=%s", job->printer->uri,
    
  •       PWG_ServiceURI"=%s", printer->uri,
        PWG_JobID"=%d", job->id,
        PWG_JobState"=%s", job_states[job->state_value - IPP_JSTATE_PENDING],
        PWG_JobImpressionsCompleted"=%d", ippGetInteger(job->impressions, 0),
    

    @@ -887,7 +889,7 @@
    break;

     case 'p' :         /* Printer name */
    
  •   strlcpy(bufptr, job->printer->name, sizeof(buffer) - (size_t)(bufptr - buffer));
    
  •   strlcpy(bufptr, job->dest, sizeof(buffer) - (size_t)(bufptr - buffer));
    bufptr += strlen(bufptr);
    break;
    

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