Bug#786916: berkeley-abc: Crashes on some architectures because of memory alignment problems

Ruben Undheim ruben.undheim at gmail.com
Tue May 26 18:32:50 UTC 2015


Package: berkeley-abc
Version: 1.01+20140822hg4d547a5+dfsg
Severity: important
Tags: jessie, patch


Dear Maintainer,

This patch fixes the issue (already fixed in unstable):


Index: berkeley-abc/Makefile
===================================================================
--- berkeley-abc.orig/Makefile
+++ berkeley-abc/Makefile
@@ -45,6 +45,9 @@ ARCHFLAGS ?= $(shell $(CC) arch_flags.c
 OPTFLAGS  ?= -g -O #-DABC_NAMESPACE=xxx
 
 CFLAGS   += -Wall -Wno-unused-function -Wno-write-strings -Wno-sign-compare $(OPTFLAGS) $(ARCHFLAGS) -Isrc
+ifneq ($(findstring arm,$(shell uname -m)),)
+   CFLAGS += -DABC_MEMALIGN=4
+endif
 
 # Set -Wno-unused-bug-set-variable for GCC 4.6.0 and greater only
 ifneq ($(or $(findstring gcc,$(CC)),$(findstring g++,$(CC))),)
Index: berkeley-abc/src/aig/aig/aigMem.c
===================================================================
--- berkeley-abc.orig/src/aig/aig/aigMem.c
+++ berkeley-abc/src/aig/aig/aigMem.c
@@ -366,6 +366,10 @@ void Aig_MmFlexStop( Aig_MmFlex_t * p, i
 char * Aig_MmFlexEntryFetch( Aig_MmFlex_t * p, int nBytes )
 {
     char * pTemp;
+#ifdef ABC_MEMALIGN
+    // extend size to max alignment
+    nBytes += (ABC_MEMALIGN - nBytes % ABC_MEMALIGN) % ABC_MEMALIGN;
+#endif
     // check if there are still free entries
     if ( p->pCurrent == NULL || p->pCurrent + nBytes > p->pEnd )
     { // need to allocate more entries
@@ -535,6 +539,10 @@ char * Aig_MmStepEntryFetch( Aig_MmStep_
 {
     if ( nBytes == 0 )
         return NULL;
+#ifdef ABC_MEMALIGN
+    // extend size to max alignment
+    nBytes += (ABC_MEMALIGN - nBytes % ABC_MEMALIGN) % ABC_MEMALIGN;
+#endif
     if ( nBytes > p->nMapSize )
     {
         if ( p->nChunks == p->nChunksAlloc )
@@ -564,6 +572,10 @@ void Aig_MmStepEntryRecycle( Aig_MmStep_
 {
     if ( nBytes == 0 )
         return;
+#ifdef ABC_MEMALIGN
+    // extend size to max alignment
+    nBytes += (ABC_MEMALIGN - nBytes % ABC_MEMALIGN) % ABC_MEMALIGN;
+#endif
     if ( nBytes > p->nMapSize )
     {
 //        ABC_FREE( pEntry );





Ruben



More information about the debian-science-maintainers mailing list