Bug 5042 - Backtrace in snmp status
: Backtrace in snmp status
Status: RESOLVED FIXED
: Roxen WebServer
Core
: 4.5
: All All
: P3 (normal) normal
: ---
Assigned To:
:
:
:
  Show dependency treegraph
 
Reported: 2009-10-20 17:09 CET by
Modified: 2010-11-25 15:21 CET (History)
Scrum Prio:
In scrum?: ---
Story included in sprints:
Unplanned in sprints: 37


Attachments


Description From 2009-10-20 17:09:31 CET
I can trig the following by clicking on the Status tab for the 4.6 feed-import
module before it has finished its "Starting up" phase:

Bad argument 1 to ctime(). Expected int
Unknown program: ctime(0)
etc/modules/Roxen.pmod (version 1.226):1853: Roxen->short_date(0)
config_interface/sites/site_content.pike (version 1.149):335:
/var/tmp/roxen/server-4.5.378/config_interface/sites/site_content()->get_snmp(RoxenModule(rep-test/feed-import#0),ModuleInfo(feed-import),RequestID(/sites/site.html/rep-test/Feed%20Import!0/feed-import!0/?section=Status))
config_interface/sites/site_content.pike (version 1.149):410:
/var/tmp/roxen/server-4.5.378/config_interface/sites/site_content()->find_module_doc("rep-test","feed-import!0",RequestID(/sites/site.html/rep-test/Feed%20Import!0/feed-import!0/?section=Status))
config_interface/sites/site_content.pike (version 1.149):538:
/var/tmp/roxen/server-4.5.378/config_interface/sites/site_content()->module_page(RequestID(/sites/site.html/rep-test/Feed%20Import!0/feed-import!0/?section=Status),"rep-test","feed-import!0")
config_interface/sites/site_content.pike (version 1.149):819:
/var/tmp/roxen/server-4.5.378/config_interface/sites/site_content()->parse(RequestID(site_content.pike))
modules/scripting/pikescript.pike (version 1.73):133:
RoxenModule(asdf/pikescript#0)->call_script(/var/tmp/roxen/server-4.5.378/config_interface/sites/site_content()->parse,RequestID(site_content.pike),Stdio.File("config_interface/sites/site_content.pike",
"r", 777 /* fd=34 */))

The error is logged in the web page, not in the debug log.

It appears that ctime() is fed some sort of object that is not quite so much a
zero as it makes itself out to be. I suspect something in SNMP.pmod.
------- Comment #1 From 2009-10-20 17:18:52 CET -------
Could be a Gmp.mpz object from asn1_integer. In 7.4 it is confusingly formatted
as a zero with %O:

Pike v7.4 release 629 running Hilfe v3.5 (Incremental Pike Frontend)
> mixed v = Gmp.mpz(0);
> ctime(v);
Bad argument 1 to ctime(). Expected int
Unknown program: ctime(0)
HilfeInput:1: HilfeInput()->___HilfeWrapper()
------- Comment #2 From 2009-10-20 17:24:35 CET -------
Sounds likely. The line that breaks is most likely in SNMP.Tick()->_sprintf():

  static string _sprintf(int t)
  {
    if (t == 's') {
      return Roxen.short_date(time(1) - ((int)value)/100);
    }
    return ::_sprintf(t);
  }
------- Comment #3 From 2010-11-25 14:37:24 CET -------
*** Bug 5753 has been marked as a duplicate of this bug. ***
------- Comment #4 From 2010-11-25 15:01:50 CET -------
> object_program(p);
(2) Result: _static_modules.Gmp()->bignum
> ctime(o/100);
Bad argument 1 to ctime(). Expected int.
Unknown program: ctime(Gmp.mpz(1290692546))
HilfeInput:1: HilfeInput()->___HilfeWrapper()
> ctime(p/100);
(3) Result: "Thu Nov 25 14:42:26 2010\n"

But in Pike 7.4 the Gmp.mpz isn't converted by the cast:

> object o = Gmp.mpz(time()*100);
> mixed p = (int)o;
> object_program(o);
(1) Result: Gmp.mpz
> object_program(p);
(2) Result: Gmp.mpz
> ctime(o/100);
Bad argument 1 to ctime(). Expected int
Unknown program: ctime(1290692546)
HilfeInput:1: HilfeInput()->___HilfeWrapper()
> ctime(p/100);
Bad argument 1 to ctime(). Expected int
Unknown program: ctime(1290692546)
HilfeInput:1: HilfeInput()->___HilfeWrapper()
------- Comment #5 From 2010-11-25 15:03:07 CET -------
Oops, lost the start of the previous comment.

The problem is probably that value is > 0x7fffffff, and the cast to int thus is
a no-op.

It probably ought to convert the object from a Gmp.mpz to a Gmp.bignum. This
seems to work in Pike 7.8:

> object o = Gmp.mpz(time()*100);
> mixed p = (int)o;
> object_program(o);
(1) Result: _static_modules.Gmp()->mpz
> object_program(p);
(2) Result: _static_modules.Gmp()->bignum
> ctime(o/100);
Bad argument 1 to ctime(). Expected int.
Unknown program: ctime(Gmp.mpz(1290692546))
HilfeInput:1: HilfeInput()->___HilfeWrapper()
> ctime(p/100);
(3) Result: "Thu Nov 25 14:42:26 2010\n"

But in Pike 7.4 the Gmp.mpz isn't converted by the cast:

> object o = Gmp.mpz(time()*100);
> mixed p = (int)o;
> object_program(o);
(1) Result: Gmp.mpz
> object_program(p);
(2) Result: Gmp.mpz
> ctime(o/100);
Bad argument 1 to ctime(). Expected int
Unknown program: ctime(1290692546)
HilfeInput:1: HilfeInput()->___HilfeWrapper()
> ctime(p/100);
Bad argument 1 to ctime(). Expected int
Unknown program: ctime(1290692546)
HilfeInput:1: HilfeInput()->___HilfeWrapper()
------- Comment #6 From 2010-11-25 15:21:44 CET -------
Fixed in Roxen 4.5 and 5.0, and backported the casting fix from Pike 7.8 to
Pike 7.4.

Note

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