Bug 478644 - at can pick the wrong year when scheduling a job in the next year
Summary: at can pick the wrong year when scheduling a job in the next year
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora
Classification: Fedora
Component: at
Version: 10
Hardware: i386
OS: Linux
low
medium
Target Milestone: ---
Assignee: Marcela Mašláňová
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-01-02 18:53 UTC by Ali Corbin
Modified: 2009-11-18 10:38 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-11-18 08:33:32 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
Patch to add 'yearspec = 1;' in several places, for the end-of-year bug (1.12 KB, patch)
2009-03-06 21:51 UTC, Ali Corbin
no flags Details | Diff

Description Ali Corbin 2009-01-02 18:53:57 UTC
Description of problem:

at, when scheduling a job by day-of-week or number-of-days that should run in the coming year, actually schedules it in the year after.


Version-Release number of selected component (if applicable):

at-3.1.10-26.fc10


How reproducible:

every time


Steps to Reproduce:
1.  date
Tue Dec 30 10:13:05 PST 2008
2.  at -f atjob 1pm friday
or
3.  at -f atjob 1pm +3 days
  

Actual results:

job n at 2010-01-02 13:00


Expected results:

job n at 2009-01-02 13:00


Additional info:

at correctly schedules jobs that use the day-of-month to specify the day.

Comment 1 lexual 2009-02-26 13:06:29 UTC
Can't reproduce here.
at-3.1.10-26.fc10.i386

$ date
Fri Feb 27 00:01:25 EST 2009

$ at -f foo 1pm +3 days
job 4 at 2009-03-02 13:00

$ at -f foo 1pm +400 days
job 5 at 2010-04-03 13:00

$ atq
5	2010-04-03 13:00 a lex
4	2009-03-02 13:00 a lex

Ali, can you still reproduce this?
If so, can you provide a better testcase?

Comment 2 Ali Corbin 2009-02-26 20:01:45 UTC
It looks like the bug only occurs in the period between the first day of the coming year and a year from today:

# date
Thu Feb 26 11:52:44 PST 2009

# at -f foo 1pm +308 days
job 15 at 2009-12-31 13:00

# at -f foo 1pm +309 days
job 16 at 2011-01-01 13:00

# at -f foo 1pm +365 days
job 17 at 2010-02-26 13:00

# at -f foo 1pm +364 days
job 18 at 2011-02-25 13:00

# atq
16      2011-01-01 13:00 a root
15      2009-12-31 13:00 a root
18      2011-02-25 13:00 a root
17      2010-02-26 13:00 a root

Comment 3 lexual 2009-02-26 22:54:44 UTC
Wow!

reproduced Fedora 10.

$ date
Fri Feb 27 09:49:34 EST 2009

$ at -f foo 1pm +307 days
job 16 at 2009-12-31 13:00

$ at -f foo 1pm +308 days
job 17 at 2011-01-01 13:00

Comment 4 Ali Corbin 2009-03-06 21:51:06 UTC
Created attachment 334353 [details]
Patch to add 'yearspec = 1;' in several places, for the end-of-year bug

First a declaimer:  I don't know yacc, and am not really sure exactly how parsetime.y is working.

But I noticed that 'at now +301' worked correctly, while 'at today', 'tomorrow', 'noon', '1pm', etc failed.  So I poked around in the code and found that 'NOW' was setting yearspec = 1, while the other tokens weren't.

When I added yearspec = 1 to other places in the file, it seemed to work better.

Now I have no idea what this patch might break.  I tried to run 'make test' before I made any changes, but it complained about the panic() in parsetime.y and aborted.  (And even after I commented panic() out, nearly half of its tests still failed.)  So I couldn't do any regression tests.

Comment 5 Ali Corbin 2009-03-06 21:56:27 UTC
OK, I found at least one thing that the patch broke:

> at -f ~/foo noon 1 Jan
at: refusing to create job destined in the past

Comment 6 Ali Corbin 2009-03-07 00:09:07 UTC
Forget the patch.  The problem isn't that yearspec isn't being set correctly.  The problem is that exectm.tm_year is being incremented twice.

I added some debug statements to parsetime():

    exectm = *localtime(&currtime);
    ...
    yearspec = 0;
    fprintf(stderr,"after localtime, tm_year is %d\n", exectm.tm_year);

    if (yyparse() == 0) {
    fprintf(stderr,"after yyparse, tm_year is %d\n", exectm.tm_year);
	if (time_only)
	{
	    if ((exectm.tm_hour < currtm.tm_hour) ||
		((exectm.tm_hour == currtm.tm_hour &&
		    exectm.tm_min <= currtm.tm_min)))
		exectm.tm_mday++;
	} 
	else if (!yearspec) {
        fprintf(stderr,"before year++, year is %d\n", exectm.tm_year);
	    if ((exectm.tm_mon < currtm.tm_mon) ||
	        ((exectm.tm_mon == currtm.tm_mon &&
		     exectm.tm_mday < currtm.tm_mday)))
		exectm.tm_year++;
        fprintf(stderr,"after year++, year is %d\n", exectm.tm_year);
	}

> at -f ~/foo noon +301 days
after localtime, tm_year is 109
after yyparse, tm_year is 110
before year++, year is 110
after year++, year is 111
job 96 at 2011-01-01 12:00

So it's getting incremented once somewhere in yyparse(), and then again in the 'if (!yearspec)' paragraph.  I haven't a clue where in the yacc code it's getting incremented.

Comment 7 Marcela Mašláňová 2009-03-11 09:41:58 UTC
Yes, that's the same problem as I have ;-) I can't track down the problem in yacc. I plan go through whole yacc and fix all reported problems, but not now. I won't break with changes in grammar things which were working.

Comment 8 Ansgar Burchardt 2009-11-16 15:37:02 UTC
This issue is also tracked in the Debian BTS [1] and will be fixed in at/3.1.12 [2].

There is also a similar bug when using "at 23.55 + 7 minutes", which is also fixed [3].

[1] http://bugs.debian.org/404965
[2] http://git.debian.org/?p=collab-maint/at.git;a=commit;h=2160392be1716fc9895f09e3fd1ce148ec0325c9
[3] http://git.debian.org/?p=collab-maint/at.git;a=commit;h=2fe813274cc6bb9f98f85e5c8d0763ab8a7fa34d

Comment 9 Marcela Mašláňová 2009-11-18 08:33:32 UTC
Thank you for a fix. I'm closing as upstream.

Comment 10 Bug Zapper 2009-11-18 10:38:00 UTC
This message is a reminder that Fedora 10 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 10.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '10'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 10's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 10 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping


Note You need to log in before you can comment on or make changes to this bug.