[plt-scheme] Error Traces

From: Arend P. van der Veen (apvanderveen at att.net)
Date: Tue Feb 22 08:48:09 EST 2005


I have been having some problems with error traces in compiled modules. 
  Please consider the following example.

I created a module called module1 that consists of two files; module1.ss 
and info.ss.  I copy these two files into a directory called


I then created a program called sample3.ss that will force an error in 
module1.  When I run sample3.ss I get the following results:

/: division by zero
/usr/local/plt/collects/module1/module1.ss:8:6: (/ x y)
/usr/home/apvanderveen/work/sample3.ss:4:0: (display (sample-function 5 0))

This provides me with a nice trace of where the error occurred.  This is 
great for debugging.  Now I compile the module using the following 
command as root:

mzc --collection-zos module1

When I run sample3.ss I now get the following results:

/: division by zero
/usr/home/apvanderveen/work/sample3.ss:4:9: (sample-function 5 0)
/usr/home/apvanderveen/work/sample3.ss:4:0: (display (sample-function 5 0))

As you can see the error trace no longer shows me where the error is. 
It only tells me that an error occurred in sample-function.  In my old C 
days this was similar to what would happen if I did not compile with 
debug information.  I could not find any information in mzc about how to 
retain line numbers.

I want to compile my modules because of the performance increase. 
However, I need these error traces to track down latent bugs.

Thanks for any help,

Following is the sample code:

(require (lib "errortrace.ss" "errortrace"))
(require (lib "module1.ss" "module1"))

(display (sample-function 5 0))

-(module module1

   (require (lib "errortrace.ss" "errortrace"))

   (define sample-function
     (lambda (x y)
       (/ x y)))

   (provide sample-function))

(module info (lib "infotab.ss" "setup")
   (define name "MODULE1")
   (define primary-file "module1.ss"))

Posted on the users mailing list.