[LON-CAPA-admin] Perl Script Function "ln" supported?

Stuart Raeburn raeburn at msu.edu
Wed Nov 21 22:11:41 EST 2012


>>>>> The perl script function "ln" (not "log" or "log10") seems to be
>>>>> supported by LON-CAPA, but not officially.

The ability to enter an expression such as:

$a = &ln(N);

in a perl script block in LON-CAPA to set the scalar $a to the natural  
log of a number N became available starting in LON-CAPA 2.1 (December  
2005), as a side effect of the introduction of Math::Complex  
availability in safe space (where perl code within a script block in a  
LON-CAPA problem is evaluated).

However, given that the advertised function for natural log both in  
CAPA, and LON-CAPA has always been log(), e.g., see:


it seems that support for ln() was likely an unintended side effect.

>>>>> So, why does it work on some servers?

The perl module Math::Complex which provides access to the ln()  
function in safe space is one of the set of core packages which are  
installed whenever perl is installed on a Linux system.

As it turns out a change made to Math::Complex between versions 1.49  
and 1.51 introduced the use of a separate perl module Config.pm, which  
includes functionality that means it can not be used in safe space.   
Accordingly, Math::Complex can only be used in LON-CAPA's safe space  
where the perl version is 5.10.0 or older.
[perl 5.10.0 uses Math::Complex 1.37; perl 5.10.1 uses Math::Complex 1.56]

For Linux distros on which LON-CAPA is supported this means ln() is  
available for any LON-CAPA release from 2.1.0 to 2.10.1 for:

RHEL 4,5; CentOS 5; Scientific Linux 5; Ubuntu 8.04 LTS; SLES 9,10,11;  
Debian 5;  SuSE 11.1, 11.2; Fedora 9, 10, 11, 12.

but is unavailable for:

RHEL 6, CentOS 6; Scientific Linux 6; Ubuntu 10.04 LTS; Debian 6; SuSE  
11.3, 11.4, 12.1; Fedora 13, 14, 15, 16

For servers in this second group (if running LON-CAPA 2.10.1), a  
system administrator can replace rev. of  
default_homework.lcpm with rev. as follows:

wget -O /home/httpd/html/res/adm/includes/default_homework.lcpm  

/etc/init.d/httpd reload

After that patch has been applied, CentOS 6, Ubuntu 10.04 LTS etc.  
running 2.10.1 will no longer see the error message about a missing  
subroutine: main::ln, when viewing a resources in which &ln() is used  
in a perl script block.

An alternative to patching default_homework.lcpm is to replace use of  
&ln() with &log() in the perl script block in any resources where this  
issue occurs, and republish each resource. How desirable that is, of  
course, depends on how widespread the use of &ln() has been.

The error seen on the CentOS 5 development server has a different  
origin, which is not seen in production. cvs update of lonxml.pm will  
eliminate that issue.
(see bug 6629 -- http://bugs.loncapa.org/show_bug.cgi?id=6629#c4 for details).

Stuart Raeburn
LON-CAPA Academic Consortium

Quoting Stefan Bisitz <st.bisitz at ostfalia.de>:

> Ok, this needs to work again. I've filed a bug report:
> http://bugs.loncapa.org/show_bug.cgi?id=6629
> Stefan Bisitz
> Am 20.11.2012 15:31 schrieb Lucas, Mark:
>> The particular problem on which this issue occurred is
>> http://capa2.phy.ohiou.edu/res/ohiou/OUp250lib/SHM/dampedspring.problem
>> It has been used in the past without these error messages.
>> On capa2 and capa4 (our two library servers), I don't see any error  
>>  in construction
>> space or in student space.
>> I upgraded most of my access servers to Centos 6 in the summer, but did not
>> mess with my library servers because of time issues. It may be that there is
>> a new perl library with newer releases.
>> Mark
>> On Nov 20, 2012, at 8:51 AM, Stefan Bisitz wrote:
>>> Hi Mark,
>>> Thanks for your information.
>>> I just talked to the LON-CAPA administrator of the domain where the
>>> issue occurred "here" for the first time. He confirmed the issue, as CC
>>> and AU. It's an Ubuntu Server with 64 Bit.
>>> Sorry to ask again: Are you sure you don't get an error message in
>>> Construction Space? We get the error message on the other server and on
>>> our (development) server where the function doesn't work.
>>> ----------------
>>> <problem>
>>> <script type="loncapa/perl">
>>> $a = ln(0.05);
>>> </script>
>>> <startouttext />
>>> a: $a
>>> <endouttext />
>>> </problem>
>>> ----------------
>>> I need to ask more:
>>> Do you have evidence that these problems using ln() have ever worked on
>>> the machines where the error occurs now?
>>> From what we found in our debugging session yesterday (nothing...), we
>>> still wonder where and how this function is offered by LON-CAPA anyway.
>>> I plan to file a bug report - especially if it can be confirmed that the
>>> function should work, used to work and doesn't work anymore.
>>> Stefan Bisitz
>>> Am 19.11.2012 20:51 schrieb Lucas, Mark:
>>>> Stefan,
>>>> I was just getting ready to ask about this. We had this pop up   
>>>> just last night.
>>>> We had an instructor start getting 'bombs' on a problem that uses ln().
>>>> It did not get caught in construction space.
>>>> I just checked out a problem and I get the error messages on all   
>>>> our access
>>>> servers when I log in as a student and check out problem, but I   
>>>> don't get the
>>>> message on our library servers when I do the same thing. I also, as stated
>>>> above, do not get the error message in construction space (necessarily in
>>>> construction space).
>>>> What is different about perl on the library servers? One of my   
>>>> library servers
>>>> is 64-bit (Centos5.3) and the other is 32-bit (Centos 5.3).
>>>> Mark
>>>> On Nov 19, 2012, at 12:59 PM, Stefan Bisitz wrote:
>>>>> Hi,
>>>>> The perl script function "ln" (not "log" or "log10") seems to be
>>>>> supported by LON-CAPA, but not officially. The Script Functions help
>>>>> doesn't list it and it's not a perl function.
>>>>> The issue:
>>>>> Some LON-CAPA servers do not support "ln" and complain "Undefined
>>>>> subroutine &main::ln ..." while others calculate the correct value.
>>>>> So, why does it work on some servers? Should it work on all? If so, why
>>>>> isn't it currently?
>>>>> Any hints?
>>>>> Thanks,
>>>>> Stefan Bisitz
>>>>> _______________________________________________

More information about the LON-CAPA-admin mailing list