[Ecls-list] [DODGY PATCH] Re: Two-level dependency "segmentation violation"

William Robinson airbaggins at gmail.com
Sun Jan 27 21:39:06 UTC 2008


William Robinson wrote:

<snip>
> if you put the linker flags (for GCC anyway) --whole-archive before 
> the mention of liblibrary.a (and --no-whole-archive after, as you get 
> an ungodly mess of multiply defined symbols), the resulting .fas is 
> then loadable, and it runs correctly.
The attached patch is an attempt to fix these problems. It patches the 
system-ld-flag (renaming to system-ld-flags) function to perform two 
extra functions, depending on the library (when an asdf system to be 
included) and also the target, the different functionality is:
* When target is a shared library of any kind, include the library's 
whole-archive. The problem with just including the object is that 
functions in the static archive are silently dropped if not used by the 
shared library (eg. the init_lib_LIBRARYNAME)
* When the target is another static library (ie. an ASDF depending on 
another ASDF), as you cannot simply include another archive in another, 
it will attempt to unpack the archive and add its objects.

Now, this patch was working with me when I was compiling via SLIME 
(using C-M-x to just evaluate the forms as i fixed them). However, when 
compiled as part of the main ECL there is another segfault just after I 
call ext:run-program.

The precise line that it segfaults at, is in generated code:
V4= 
si_run_program(8,VV[68],T1,ECL_SYM("INPUT",1248),Cnil,ECL_SYM("OUTPUT",1275),ECL_SYM("STREAM",1305),ECL_SYM("ERROR",1225),Ct) 
/* RUN-PROGRAM */;
if((V4)!=Cnil){ // <------------ HERE
goto L280;}

Or in the lisp code:
(let ((files (ext:run-program
"ar"
(list "t" (namestring lib-path))
:input nil :output :stream :error t)))
(unless files ; <------------- HERE (i guess)
(error "Could not extract archive ~s" lib-path))
(loop for file = (read-line files nil nil)
while file
collect
(progn
(when (probe-file file)
(warn "Overwriting file ~s" file))
file)))

Perhaps run-program doesn't work in the "cmp" package properly.

When I run it in the debugger, V4 turns out to be this:
(gdb) print type_of(V4)
$5 = t_stream
(gdb) print V4->stream
$4 = {t = 16 '\020', m = 0 '\0', mode = 6 '\006', closed = 0 '\0', 
char_stream_p = 0 '\0', signed_bytes = 0 '\0', file = 0x0, object0 = 
0x851aba0,
object1 = 0x808ffc0, int0 = 0, int1 = 0, buffer = 0x0, byte_size = 0, 
bit_buffer = 0 '\0', bits_left = 0 '\0', buffer_state = 0 '\0', header = 
0 '\0',
last_op = 0 '\0'}

Which I guess isn't so great.

Anyway, the functionality seems to basically work, it makes a bit of a 
mess with the .o files getting unpacked in the current directory, wasn't 
sure what to do about that.

If anyone can either give me a clue or help me finish off this patch, or 
offer advice on how to debug, improve it, and/or to get it eventually 
accepted, that would be great.

Yours hopefully.
Bill
(“baggles” on freenode)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: general-shared-static-libraries.patch
Type: text/x-patch
Size: 3897 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20080127/87f0e3c0/attachment.bin>


More information about the ecl-devel mailing list