This file is indexed.

/usr/share/doc/libpawlib2-dev/README.Debian is in libpawlib2-dev 1:2.14.04.dfsg.2-9.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
Notes on libpawlib2-dev
-----------------------

1) This package does not include the Lesstif-dependent parts of Pawlib.
Those can be found in the package libpawlib-lesstif3-dev.


2) Note that much of this library is functional on 64-bit machines only when
statically linked.  Please see the file README.64-bit for more information.
An example illustrating some other things to take care about is given
in /usr/share/doc/libpawlib2-dev/examples/comis-64bit-example.F .


3) On 32-bit architectures, please read this note carefully if you link against
pawlib dynamically so that the COMIS interpreter works correctly in your
application.  This is especially applicable if your application dies with this
error message:

	CSALLO: heap below bss?!

If you link statically, this note does not concern you.  The default output of
the "cernlib" script includes the -static compiler flag, so a program linked
via a command like one of these:

	gfortran myprogram.F -o myprogram `cernlib pawlib`
	gcc file1.o file2.o file3.o -o myprogram `cernlib pawlib`

is statically linked to pawlib.

If you have doubts, run ldd on your executable; a statically linked program
should NOT have the output of ldd include a line similar to this:

	libpawlib.so.2 => /usr/lib/*/libpawlib.so.2 (0x0f7eb000)

Executive summary
-----------------

a) If your executable's main source code file is written in FORTRAN, it should

	#include <comis/mdpool.inc>

immediately after the "      PROGRAM programname" line.

b) If your executable's main source code file is written in C or C++, it should

	#include <comis/mdpool.h>

at the top of the source code.

It is only necessary for one file of your source code to include mdpool.inc or
mdpool.h, and may in fact cause linking problems if more than one file does so.
Do not include mdpool.inc or mdpool.h in a header file unless that file is
itself only #included by one source file.

Technical details
-----------------

The authors of COMIS (the PAW interpreter) used two memory allocation areas;
one is the integer array IQ (size: 50006 integers) in the COMMON block MDPOOL,
and the other is dynamically allocated by malloc() in the CSALLO function.  The
difference between the malloc()ed pointer address and the address of the common
block is returned to FORTRAN code, so it can access the new memory by using the
appropriate array subscript in MDPOOL/IQ.

The idea is similar to that expressed in the following C code:

#include <stdlib.h>

typedef struct { int iq[50006]; } mdpool_def;
mdpool_def mdpool;

int main()
{
  unsigned long iqpntr = (unsigned long)mdpool.iq;
  unsigned long lpntr  = (unsigned long)malloc(sizeof(int));
  int           index  = (lpntr - iqpntr) / sizeof(int);

  mdpool.iq[index] = 5;
  return mdpool.iq[index];
}

The problem is that the FORTRAN code in pawlib expects the address difference
(the variable "index" in the above example) to be positive.  This is fine when
an executable is statically linked to pawlib, since then the malloc()ed space
in the heap is always at a larger address than MDPOOL in the binary's bss
segment.  But on some (most?) architectures, shared libraries, including MDPOOL
in libpawlib.so, are mapped into memory beyond the program stack, yielding a
negative address offset.

After a lot of trying, I concluded that tracking down all the places in the
FORTRAN code that expected a positive pointer offset from MDPOOL would be very
difficult and error-prone, so the solution is to attack the problem from the
other end.  That is, declare MDPOOL/IQ in the dynamically linked executable.
Then MDPOOL will always be present in these executables' bss segments, whose
address is always less than that of space allocated on the heap.  This is
accomplished by #include'ing <comis/mdpool.inc> or <comis/mdpool.h> in the
source code for the executable.  See, e.g., the file
/usr/share/doc/libpawlib2-dev/examples/pamain.c .

-- Kevin McCarty <kmccarty@debian.org>, Mon, 29 Nov 2004