Bug 173446 - lang/polyml: segfaults on startup on amd64
Summary: lang/polyml: segfaults on startup on amd64
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-07 16:00 UTC by imre
Modified: 2013-02-08 08:30 UTC (History)
0 users

See Also:


Attachments
file.diff (457 bytes, patch)
2012-11-07 16:00 UTC, imre
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description imre 2012-11-07 16:00:00 UTC
The /usr/local/bin/poly executable from lang/polyml-5.4.1 immediately crashes with a SIGSEGV under FreeBSD-9.0 amd64.

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:
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.
Comment 1 Edwin Groothuis freebsd_committer 2012-11-07 16:00:07 UTC
Maintainer of lang/polyml,

Please note that PR ports/173446 has just been submitted.

If it contains a patch for an upgrade, an enhancement or a bug fix
you agree on, reply to this email stating that you approve the patch
and a committer will take care of it.

The full text of the PR can be found at:
    http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/173446

-- 
Edwin Groothuis via the GNATS Auto Assign Tool
edwin@FreeBSD.org
Comment 2 Edwin Groothuis freebsd_committer 2012-11-07 16:00:08 UTC
State Changed
From-To: open->feedback

Awaiting maintainers feedback (via the GNATS Auto Assign Tool)
Comment 3 Timothy Beyer 2012-11-08 08:24:14 UTC
It doesn't break anything on my i386 machine, approved.

Regards,
Tim
Comment 4 Timothy Beyer 2013-02-05 09:58:45 UTC
Hi,

Can someone commit this patch please? I would definitely like to see it committed before I make another update to the port, and recently people have sent me questions on how to apply this patch to the existent tree...

Perhaps there was a misunderstanding regarding my prior approval of the patch? My apologies if the confusing way that I worded my approval confused committers, or lead to any other ambiguity.

Regards,
Tim
Comment 5 Mark Linimon freebsd_committer freebsd_triage 2013-02-06 02:05:06 UTC
State Changed
From-To: feedback->open

Maintainer approved.
Comment 6 Martin Wilke freebsd_committer 2013-02-08 08:24:20 UTC
State Changed
From-To: open->closed

Committed. Thanks!
Comment 7 dfilter service freebsd_committer 2013-02-08 08:24:30 UTC
Author: miwi
Date: Fri Feb  8 08:24:18 2013
New Revision: 311918
URL: http://svnweb.freebsd.org/changeset/ports/311918

Log:
  - Fix a segfault on startup
  - While here trim header
  
  PR:		ports/173446
  Submitted by:	Imre Vadasz <imre@vdsz.com>
  Approved by:	maintainer

Added:
  head/lang/polyml/files/
  head/lang/polyml/files/patch-elfexport.h   (contents, props changed)
Modified:
  head/lang/polyml/Makefile   (contents, props changed)

Modified: head/lang/polyml/Makefile
==============================================================================
--- head/lang/polyml/Makefile	Fri Feb  8 08:10:15 2013	(r311917)
+++ head/lang/polyml/Makefile	Fri Feb  8 08:24:18 2013	(r311918)
@@ -1,12 +1,9 @@
-# New ports collection makefile for:   polyml
-# Date created:        09 July 2005
-# Whom:                Timothy Bourke <timbob@bigpond.com>
-#
+# Created by: Timothy Bourke <timbob@bigpond.com>
 # $FreeBSD$
-#
 
 PORTNAME=	polyml
 PORTVERSION=	5.4.1
+PORTREVISION=	1
 CATEGORIES=	lang
 MASTER_SITES=	SF
 DISTNAME=	${PORTNAME}.${PORTVERSION}

Added: head/lang/polyml/files/patch-elfexport.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/lang/polyml/files/patch-elfexport.h	Fri Feb  8 08:24:18 2013	(r311918)
@@ -0,0 +1,11 @@
+--- libpolyml/elfexport.h.orgi	2013-02-08 16:01:09.000000000 +0800
++++ libpolyml/elfexport.h	2013-02-08 16:01:43.000000000 +0800
+@@ -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
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"