Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 7 Nov 2012 15:59:30 GMT
From:      Imre Vadasz <imre@vdsz.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/173446: lang/polyml: segfaults on startup on amd64
Message-ID:  <201211071559.qA7FxU48097928@red.freebsd.org>
Resent-Message-ID: <201211071600.qA7G01mV052334@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         173446
>Category:       ports
>Synopsis:       lang/polyml: segfaults on startup on amd64
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Nov 07 16:00:00 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Imre Vadasz
>Release:        9.0-Release
>Organization:
>Environment:
FreeBSD Wega.fritz.box 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan  3 07:46:30 UTC 2012     root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
The /usr/local/bin/poly executable from lang/polyml-5.4.1 immediately crashes with a SIGSEGV under FreeBSD-9.0 amd64.
>How-To-Repeat:
Build/Install polyml-5.4.1 on FreeBSD-9.0 amd64 (not tested on other releases of FreeBSD).
The /usr/local/bin/poly crashes with a SIGSEGV whe trying to run it.
>Fix:
The problem is caused by a difference in the ELF64_R_INFO macro between FreeBSD and Linux. Linux explicitly casts the first parameter to Elf64_Xword, whereas FreeBSD does not.

The macro is used in libpolyml/elfexport{.h,.cpp}, expecting the Linux behaviour.
libpolyml/elfexport.cpp calls the ELF64_R_INFO macro, using an "unsigned" as the first parameter. Since ELF64_R_INFO shifts this parameter to the left by 32bits, this results in wrong code under FreeBSD.
The easiest fix is to add a cast to "Elf64_Xword" in the wrapper macro declared in libpolyml/elfexport.h
It should be decied whether /usr/include/sys/elf64.h should be fixed in FreeBSD or whether upstream has to use those macros in a portable way.

Patch attached with submission follows:

--- libpolyml/elfexport.h	2007-09-11 16:27:04.000000000 +0200
+++ libpolyml/elfexport.h	2012-11-07 16:20:22.475426587 +0100
@@ -37,7 +37,7 @@
 #define ElfXX_Sym   Elf64_Sym
 #define ElfXX_Ehdr  Elf64_Ehdr
 #define ElfXX_Shdr  Elf64_Shdr
-#define ELFXX_R_INFO(_y, _z)    ELF64_R_INFO(_y, _z)
+#define ELFXX_R_INFO(_y, _z)    ELF64_R_INFO((Elf64_Xword)(_y), _z)
 #define ELFXX_ST_INFO(_y, _z)   ELF64_ST_INFO(_y, _z)
 #define ELFCLASSXX      ELFCLASS64
 #else


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201211071559.qA7FxU48097928>