From jan@swi.psy.uva.nl Wed Feb 27 10:18:47 2002
Received: from there (jan@gollem.swi.psy.uva.nl [145.18.152.30])
	by swi.psy.uva.nl (8.11.6/8.11.2) with SMTP id g1R9Ilu06463;
	Wed, 27 Feb 2002 10:18:47 +0100 (MET)
Message-Id: <200202270918.g1R9Ilu06463@swi.psy.uva.nl>
Content-Type: text/plain;
  charset="iso-8859-1"
From: Jan Wielemaker <jan@swi.psy.uva.nl>
Organization: SWI, University of Amsterdam
To: Yan Guiborat <yan.guiborat@caramail.com>, prolog@swi.psy.uva.nl
Subject: Re: [SWIPL] Creating terms from external C under FreeBSD.
Date: Wed, 27 Feb 2002 10:17:11 +0100
X-Mailer: KMail [version 1.3.2]
References: <1014800364022098@caramail.com>
In-Reply-To: <1014800364022098@caramail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Could you turn this into a program I can test or, if this
is not easy give the little bit of C-code constructing the
terms and some overview of the overall control in the 
application, as well as a backtrace of the crash?

I found a problem using mmapped() stacks for MacOS X (based
on OpenBSD).  You can check whether your system is victim
by running

	make check

The Mac never finished the `resource' tests, where the system
tries to run out of stack and handle this gracefully.  It turns
out PROT_NONE (creating non-accessible memory) doesn't work on
this platform.  Configure now tests for this and sets 
#define NO_SEGV_HANDLING 1 to do software stack-guarding.

	Cheers --- Jan

On Wednesday 27 February 2002 10:59, Yan Guiborat wrote:
> Hello,
>
> I wrote, a little while ago, about a problem while creating
> term in a C foreign predicate.
>
> At Term creation, with PL_new_term_ref() or
> PL_new_term_refs functions, my application started being
> swapped by the pager, and them, after a while, I receive a
> nice core file of 600 Megs wich is the size of my swap
> partition.
> I guessed there could be something wrong with mmap()
> function under FreeBSD, I so reconfigured SWI-Prolog, with
> this time the mmapping desabled, and compile it with its
> debug information.
> This time, my application get a segmentation fault instead
> of going into its weird swapping.
>
> It seems to come from the file PL_wam.c, in function
> open_foreign_frame() where "fr" pointer is on 0x0 and a
> make the segmentation fault a few lines after.
>
> Here is the point where I am, and I don't feel so
> confortable modifying the Wam machine and the way it manage
> the stack.
>
> I must add that I just remembered that my pl library is
> compiled as a .a file, could it be the reason of my
> problem ?
>
> Any help will be great thanks, may be someone have already
> found the same problem ?
>
> --------------------------------------
> Yan Guiborat.
> French Exchange Student,
> Tampere University of Technology.
> e-mail:yan.guiborat@caramail.com.
> --------------------------------------
> ______________________________________________________
> Boîte aux lettres - Caramail - http://www.caramail.com

