[PPL-devel] Re: [SWIPL] Is Cygwin special?

Roberto Bagnara bagnara at cs.unipr.it
Tue Jan 17 11:50:04 CET 2006


Jan Wielemaker wrote:
> Roberto,
> 
> On Tuesday 17 January 2006 11:18, Roberto Bagnara wrote:
>>> You can also check some cross-platform tricks. "pl -x
>>> test.exe" should load mymain as long as pl is running on the native
>>> platform regardless of the platform test.exe was created on.
>> This is on Cygwin:
>>
>> $ pl -x test.exe
>> Welcome to SWI-Prolog (Multi-threaded, Version 5.6.2)
>> Copyright (c) 1990-2005 University of Amsterdam.
>> SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
>> and you are welcome to redistribute it under certain conditions.
>> Please visit http://www.swi-prolog.org for details.
>>
>> For help, use ?- help(Topic). or ?- apropos(Word).
>>
>> 1 ?- mymain.
>> mymain/0 called!
>>
>> Yes
>> 2 ?-
> 
> test.exe was created on Linux?

On Cygwin.  (But see at the end of the message what happens if
I try to use on Cygwin a test.exe created on Linux.)

>> This is on GNU/Linux:
>>
>> $ pl -x test.exe
>> Segmentation fault
> 
> This test.exe was created on Cygwin? The crash in garbageCollect()
> suggests there is something very wrong with the saved state sitting at
> the end of text.exe. There are two options. One is that saved states do
> not work on Cygwin and the other is that the assembly of the executable
> and the state (simple concatenation) is wrong. The first can be tested
> by writing a state using pl -o state -c file.pl and see whether you can
> run the result with "pl -x state" (state should run using both the Linux
> and the Cygwin emulator).

On Cygwin:

$ pl -o state -c mymain.pl
% mymain.pl compiled 0.00 sec, 1,984 bytes

$ pl -x state
Welcome to SWI-Prolog (Multi-threaded, Version 5.6.2)
Copyright (c) 1990-2005 University of Amsterdam.
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.

For help, use ?- help(Topic). or ?- apropos(Word).

1 ?- mymain/0 called!

Yes
2 ?-

% halt
$

However, if I copy `state' to GNU/Linux:
$ gdb /usr/local/bin/pl
GNU gdb Red Hat Linux (6.3.0.0-1.84rh)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1".

(gdb) r -x state
Starting program: /usr/local/bin/pl -x state
Reading symbols from shared object read from target memory...done.
Loaded system supplied DSO at 0xca2000
[Thread debugging using libthread_db enabled]
[New Thread -1208210976 (LWP 4127)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208210976 (LWP 4127)]
0x08090b1a in garbageCollect ()
(gdb) info stack
#0  0x08090b1a in garbageCollect ()
#1  0x0806570f in PL_next_solution ()
#2  0x080a3746 in prologToplevel ()
#3  0x080dbb09 in PL_initialise ()
#4  0x08050706 in main ()
(gdb)

> I'm suspecting some text/binary file issue
> that either corrupts the state or the concatenation. Resource files are
> manipulated through the code in pl/src/rc. There are three
> implementations, one based on classical read/write, one based on Unix
> mmap() and one based on Windows CreateFileMapping().

I have made another test.  I have generated `test.exe' on GNU/Linux
and copied it to Cygwin, then, on Cygwin, I tried

$ pl -x test.exe
$

So I get the shell prompt back, not SWI-Prolog's prompt.
Thanks again,

     Roberto

-- 
Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bagnara at cs.unipr.it



More information about the PPL-devel mailing list