0

I have a porgram that I build successfully but when I run the program I get a segfault.

In the build of this program I make link to many libraries:

-llib1 -llib2 -llib3

the segfault is not related to the source code but it's related to the one of library load lib2.

I tried with a hello world program

#include <stdio.h>
#include <stdlib.h>

int main()
{
    printf("hello world! \n");
}

I get a segfault when I build with -llib1 -llib2 -llib3

But I do not get a segfault when I build with -llib1 -llib3

Generally (without details) What could be the possible cause of this segfault?

EDIT

the lib2 contains the following lines in one of its header files

#    ifdef __GNUC__
__attribute__ ((__format__ (__printf__, 3, 4)))
#    endif /* __GNUC__ */

Does the above code could cause a segfault?

from the open source libminixml

minixml.h

extern int      mxmlSetTextf(mxml_node_t *node, int whitespace,
                         const char *format, ...)
#    ifdef __GNUC__
__attribute__ ((__format__ (__printf__, 3, 4)))
#    endif /* __GNUC__ */
;
extern int      mxmlSetUserData(mxml_node_t *node, void *data);

the whole minixml.h file:

#ifndef _mxml_h_
#  define _mxml_h_

/*
 * Include necessary headers...
 */

#  include <stdio.h>
#  include <stdlib.h>
#  include <string.h>
#  include <ctype.h>
#  include <errno.h>


/*
 * Constants...
 */

#  define MXML_TAB      8   /* Tabs every N columns */

#  define MXML_NO_CALLBACK  0   /* Don't use a type callback */
#  define MXML_INTEGER_CALLBACK mxml_integer_cb
                    /* Treat all data as integers */
#  define MXML_OPAQUE_CALLBACK  mxml_opaque_cb
                    /* Treat all data as opaque */
#  define MXML_REAL_CALLBACK    mxml_real_cb
                    /* Treat all data as real numbers */
#  define MXML_TEXT_CALLBACK    0   /* Treat all data as text */
#  define MXML_IGNORE_CALLBACK  mxml_ignore_cb
                    /* Ignore all non-element content */

#  define MXML_NO_PARENT    0   /* No parent for the node */

#  define MXML_DESCEND      1   /* Descend when finding/walking */
#  define MXML_NO_DESCEND   0   /* Don't descend when finding/walking */
#  define MXML_DESCEND_FIRST    -1  /* Descend for first find */

#  define MXML_WS_BEFORE_OPEN   0   /* Callback for before open tag */
#  define MXML_WS_AFTER_OPEN    1   /* Callback for after open tag */
#  define MXML_WS_BEFORE_CLOSE  2   /* Callback for before close tag */
#  define MXML_WS_AFTER_CLOSE   3   /* Callback for after close tag */

#  define MXML_ADD_BEFORE   0   /* Add node before specified node */
#  define MXML_ADD_AFTER    1   /* Add node after specified node */
#  define MXML_ADD_TO_PARENT    NULL    /* Add node relative to parent */


/*
 * Data types...
 */

typedef enum mxml_sax_event_e       /**** SAX event type. ****/
{
  MXML_SAX_CDATA,           /* CDATA node */
  MXML_SAX_COMMENT,         /* Comment node */
  MXML_SAX_DATA,            /* Data node */
  MXML_SAX_DIRECTIVE,           /* Processing directive node */
  MXML_SAX_ELEMENT_CLOSE,       /* Element closed */
  MXML_SAX_ELEMENT_OPEN         /* Element opened */
} mxml_sax_event_t;

typedef enum mxml_type_e        /**** The XML node type. ****/
{
  MXML_IGNORE = -1,         /* Ignore/throw away node @since Mini-XML 2.3@ */
  MXML_ELEMENT,             /* XML element with attributes */
  MXML_INTEGER,             /* Integer value */
  MXML_OPAQUE,              /* Opaque string */
  MXML_REAL,                /* Real value */
  MXML_TEXT,                /* Text fragment */
  MXML_CUSTOM               /* Custom data @since Mini-XML 2.1@ */
} mxml_type_t;

typedef void (*mxml_custom_destroy_cb_t)(void *);
                    /**** Custom data destructor ****/

typedef void (*mxml_error_cb_t)(const char *);  
                    /**** Error callback function ****/

typedef struct mxml_attr_s      /**** An XML element attribute value. @private@ ****/
{
  char          *name;      /* Attribute name */
  char          *value;     /* Attribute value */
} mxml_attr_t;

typedef struct mxml_element_s       /**** An XML element value. @private@ ****/
{
  char          *name;      /* Name of element */
  int           num_attrs;  /* Number of attributes */
  mxml_attr_t       *attrs;     /* Attributes */
} mxml_element_t;

typedef struct mxml_text_s      /**** An XML text value. @private@ ****/
{
  int           whitespace; /* Leading whitespace? */
  char          *string;    /* Fragment string */
} mxml_text_t;

typedef struct mxml_custom_s        /**** An XML custom value. @private@ ****/
{
  void          *data;      /* Pointer to (allocated) custom data */
  mxml_custom_destroy_cb_t destroy; /* Pointer to destructor function */
} mxml_custom_t;

typedef union mxml_value_u      /**** An XML node value. @private@ ****/
{
  mxml_element_t    element;    /* Element */
  int           integer;    /* Integer number */
  char          *opaque;    /* Opaque string */
  double        real;       /* Real number */
  mxml_text_t       text;       /* Text fragment */
  mxml_custom_t     custom;     /* Custom data @since Mini-XML 2.1@ */
} mxml_value_t;

struct mxml_node_s          /**** An XML node. @private@ ****/
{
  mxml_type_t       type;       /* Node type */
  struct mxml_node_s    *next;      /* Next node under same parent */
  struct mxml_node_s    *prev;      /* Previous node under same parent */
  struct mxml_node_s    *parent;    /* Parent node */
  struct mxml_node_s    *child;     /* First child node */
  struct mxml_node_s    *last_child;    /* Last child node */
  mxml_value_t      value;      /* Node value */
  int           ref_count;  /* Use count */
  void          *user_data; /* User data */
};

typedef struct mxml_node_s mxml_node_t; /**** An XML node. ****/

struct mxml_index_s          /**** An XML node index. @private@ ****/
{
  char          *attr;      /* Attribute used for indexing or NULL */
  int           num_nodes;  /* Number of nodes in index */
  int           alloc_nodes;    /* Allocated nodes in index */
  int           cur_node;   /* Current node */
  mxml_node_t       **nodes;    /* Node array */
};

typedef struct mxml_index_s mxml_index_t;
                    /**** An XML node index. ****/

typedef int (*mxml_custom_load_cb_t)(mxml_node_t *, const char *);
                    /**** Custom data load callback function ****/

typedef char *(*mxml_custom_save_cb_t)(mxml_node_t *);  
                    /**** Custom data save callback function ****/

typedef int (*mxml_entity_cb_t)(const char *);
                    /**** Entity callback function */

typedef mxml_type_t (*mxml_load_cb_t)(mxml_node_t *);
                    /**** Load callback function ****/

typedef const char *(*mxml_save_cb_t)(mxml_node_t *, int);
                    /**** Save callback function ****/

typedef void (*mxml_sax_cb_t)(mxml_node_t *, mxml_sax_event_t, void *);  
                    /**** SAX callback function ****/


/*
 * C++ support...
 */

#  ifdef __cplusplus
extern "C" {
#  endif /* __cplusplus */

/*
 * Prototypes...
 */

extern void     mxmlAdd(mxml_node_t *parent, int where,
                    mxml_node_t *child, mxml_node_t *node);
extern void     mxmlDelete(mxml_node_t *node);
extern void     mxmlElementDeleteAttr(mxml_node_t *node,
                                  const char *name);
extern const char   *mxmlElementGetAttrValue(mxml_node_t *node, const char *name);
extern const char   *mxmlElementGetAttrName(mxml_node_t *node, const char *value);
extern void     mxmlElementSetAttr(mxml_node_t *node, const char *name,
                               const char *value);
extern void     mxmlElementSetAttrf(mxml_node_t *node, const char *name,
                                const char *format, ...)
#    ifdef __GNUC_ttt__
__attribute__ ((__format__ (__printf__, 3, 4)))
#    endif /* __GNUC__ */
;
extern int      mxmlEntityAddCallback(mxml_entity_cb_t cb);
extern const char   *mxmlEntityGetName(int val);
extern int      mxmlEntityGetValue(const char *name);
extern void     mxmlEntityRemoveCallback(mxml_entity_cb_t cb);
extern mxml_node_t  *mxmlFindElement(mxml_node_t *node, mxml_node_t *top,
                     const char *name, const char *attr,
                     const char *value, int descend);
extern mxml_node_t  *mxmlFindElementText(mxml_node_t *node, mxml_node_t *top,
                         const char  *text, int descend);
extern mxml_node_t  *mxmlFindPath(mxml_node_t *node, const char *path);
extern const char   *mxmlGetCDATA(mxml_node_t *node);
extern const void   *mxmlGetCustom(mxml_node_t *node);
extern const char   *mxmlGetElement(mxml_node_t *node);
extern mxml_node_t  *mxmlGetFirstChild(mxml_node_t *node);
extern int      mxmlGetInteger(mxml_node_t *node);
extern mxml_node_t  *mxmlGetLastChild(mxml_node_t *node);
extern mxml_node_t  *mxmlGetNextSibling(mxml_node_t *node);
extern const char   *mxmlGetOpaque(mxml_node_t *node);
extern mxml_node_t  *mxmlGetParent(mxml_node_t *node);
extern mxml_node_t  *mxmlGetPrevSibling(mxml_node_t *node);
extern double       mxmlGetReal(mxml_node_t *node);
extern int      mxmlGetRefCount(mxml_node_t *node);
extern const char   *mxmlGetText(mxml_node_t *node, int *whitespace);
extern mxml_type_t  mxmlGetType(mxml_node_t *node);
extern void     *mxmlGetUserData(mxml_node_t *node);
extern void     mxmlIndexDelete(mxml_index_t *ind);
extern mxml_node_t  *mxmlIndexEnum(mxml_index_t *ind);
extern mxml_node_t  *mxmlIndexFind(mxml_index_t *ind,
                           const char *element,
                           const char *value);
extern int      mxmlIndexGetCount(mxml_index_t *ind);
extern mxml_index_t *mxmlIndexNew(mxml_node_t *node, const char *element,
                          const char *attr);
extern mxml_node_t  *mxmlIndexReset(mxml_index_t *ind);
extern mxml_node_t  *mxmlLoadFd(mxml_node_t *top, int fd,
                        mxml_type_t (*cb)(mxml_node_t *));
extern mxml_node_t  *mxmlLoadFile(mxml_node_t *top, FILE *fp,
                          mxml_type_t (*cb)(mxml_node_t *));
extern mxml_node_t  *mxmlLoadString(mxml_node_t *top, const char *s,
                            mxml_type_t (*cb)(mxml_node_t *));
extern mxml_node_t  *mxmlNewCDATA(mxml_node_t *parent, const char *string);
extern mxml_node_t  *mxmlNewCustom(mxml_node_t *parent, void *data,
                           mxml_custom_destroy_cb_t destroy);
extern mxml_node_t  *mxmlNewElement(mxml_node_t *parent, const char *name);
extern mxml_node_t  *mxmlNewInteger(mxml_node_t *parent, int integer);
extern mxml_node_t  *mxmlNewOpaque(mxml_node_t *parent, const char *opaque);
extern mxml_node_t  *mxmlNewReal(mxml_node_t *parent, double real);
extern mxml_node_t  *mxmlNewText(mxml_node_t *parent, int whitespace,
                         const char *string);
extern mxml_node_t  *mxmlNewTextf(mxml_node_t *parent, int whitespace,
                          const char *format, ...)
#    ifdef __GNUC_ttt__
__attribute__ ((__format__ (__printf__, 3, 4)))
#    endif /* __GNUC__ */
;
extern mxml_node_t  *mxmlNewXML(const char *version);
extern int      mxmlRelease(mxml_node_t *node);
extern void     mxmlRemove(mxml_node_t *node);
extern int      mxmlRetain(mxml_node_t *node);
extern char     *mxmlSaveAllocString(mxml_node_t *node,
                             mxml_save_cb_t cb);
extern int      mxmlSaveFd(mxml_node_t *node, int fd,
                       mxml_save_cb_t cb);
extern int      mxmlSaveFile(mxml_node_t *node, FILE *fp,
                         mxml_save_cb_t cb);
extern int      mxmlSaveString(mxml_node_t *node, char *buffer,
                           int bufsize, mxml_save_cb_t cb);
extern mxml_node_t  *mxmlSAXLoadFd(mxml_node_t *top, int fd,
                           mxml_type_t (*cb)(mxml_node_t *),
                           mxml_sax_cb_t sax, void *sax_data);
extern mxml_node_t  *mxmlSAXLoadFile(mxml_node_t *top, FILE *fp,
                             mxml_type_t (*cb)(mxml_node_t *),
                             mxml_sax_cb_t sax, void *sax_data);
extern mxml_node_t  *mxmlSAXLoadString(mxml_node_t *top, const char *s,
                               mxml_type_t (*cb)(mxml_node_t *),
                               mxml_sax_cb_t sax, void *sax_data);
extern int      mxmlSetCDATA(mxml_node_t *node, const char *data);
extern int      mxmlSetCustom(mxml_node_t *node, void *data,
                          mxml_custom_destroy_cb_t destroy);
extern void     mxmlSetCustomHandlers(mxml_custom_load_cb_t load,
                                  mxml_custom_save_cb_t save);
extern int      mxmlSetElement(mxml_node_t *node, const char *name);
extern void     mxmlSetErrorCallback(mxml_error_cb_t cb);
extern int      mxmlSetInteger(mxml_node_t *node, int integer);
extern int      mxmlSetOpaque(mxml_node_t *node, const char *opaque);
extern int      mxmlSetReal(mxml_node_t *node, double real);
extern int      mxmlSetText(mxml_node_t *node, int whitespace,
                        const char *string);
extern int      mxmlSetTextf(mxml_node_t *node, int whitespace,
                         const char *format, ...)
#    ifdef __GNUC_ttt__
__attribute__ ((__format__ (__printf__, 3, 4)))
#    endif /* __GNUC__ */
;
extern int      mxmlSetUserData(mxml_node_t *node, void *data);
extern void     mxmlSetWrapMargin(int column);
extern mxml_node_t  *mxmlWalkNext(mxml_node_t *node, mxml_node_t *top,
                          int descend);
extern mxml_node_t  *mxmlWalkPrev(mxml_node_t *node, mxml_node_t *top,
                          int descend);


/*
 * Semi-private functions...
 */

extern void     mxml_error(const char *format, ...);
extern mxml_type_t  mxml_ignore_cb(mxml_node_t *node);
extern mxml_type_t  mxml_integer_cb(mxml_node_t *node);
extern mxml_type_t  mxml_opaque_cb(mxml_node_t *node);
extern mxml_type_t  mxml_real_cb(mxml_node_t *node);


/*
 * C++ support...
 */

#  ifdef __cplusplus
}
#  endif /* __cplusplus */
#endif /* !_mxml_h_ */

It's defined 3 times in the minixml.h

strace

 strace ./test
execve("./test", ["./test"], [/* 10 vars */]) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|0x4000000, -1, 0) = 0x77885000
stat("/etc/ld.so.cache", 0x7fa6a5a0)    = -1 ENOENT (No such file or directory)
open("/lib/libmicroxml.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/libmicroxml.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/libmicroxml.so.1", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=40128, ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|0x4000000, -1, 0) = 0x77884000
read(3, "\177ELF\1\2\1\0\0\0\0\0\0\0\0\0\0\3\0\10\0\0\0\1\0\0\34@\0\0\0004"..., 4096) = 4096
old_mmap(NULL, 106496, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x77856000
old_mmap(0x77856000, 37332, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x77856000
old_mmap(0x7786f000, 3264, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x9000) = 0x7786f000
close(3)                                = 0
munmap(0x77884000, 4096)                = 0
open("/lib/libgcc_s.so.1", O_RDONLY)    = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=78232, ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|0x4000000, -1, 0) = 0x77884000
read(3, "\177ELF\1\2\1\0\0\0\0\0\0\0\0\0\0\3\0\10\0\0\0\1\0\0006\320\0\0\0004"..., 4096) = 4096
old_mmap(NULL, 147456, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x77832000
old_mmap(0x77832000, 76928, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x77832000
old_mmap(0x77855000, 408, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x13000) = 0x77855000
close(3)                                = 0
munmap(0x77884000, 4096)                = 0
open("/lib/libc.so.0", O_RDONLY)        = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=413076, ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|0x4000000, -1, 0) = 0x77884000
read(3, "\177ELF\1\2\1\0\0\0\0\0\0\0\0\0\0\3\0\10\0\0\0\1\0\0\253`\0\0\0004"..., 4096) = 4096
old_mmap(NULL, 503808, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x777b7000
old_mmap(0x777b7000, 405592, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x777b7000
old_mmap(0x7782a000, 7572, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x63000) = 0x7782a000
old_mmap(0x7782c000, 21036, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7782c000
close(3)                                = 0
munmap(0x77884000, 4096)                = 0
open("/usr/lib/libgcc_s.so.1", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=169712, ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|0x4000000, -1, 0) = 0x77884000
read(3, "\177ELF\1\2\1\0\0\0\0\0\0\0\0\0\0\3\0\10\0\0\0\1\0\0\307\220\0\0\0004"..., 4096) = 4096
old_mmap(NULL, 237568, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7777d000
old_mmap(0x7777d000, 169036, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x7777d000
old_mmap(0x777b6000, 1776, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x29000) = 0x777b6000
close(3)                                = 0
munmap(0x77884000, 4096)                = 0
open("/usr/lib/libc.so.0", O_RDONLY)    = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=425968, ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|0x4000000, -1, 0) = 0x77884000
read(3, "\177ELF\1\2\1\0\0\0\0\0\0\0\0\0\0\3\0\10\0\0\0\1\0\0\267`\0\0\0004"..., 4096) = 4096
old_mmap(NULL, 516096, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x776ff000
old_mmap(0x776ff000, 418924, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x776ff000
old_mmap(0x77775000, 8176, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x66000) = 0x77775000
old_mmap(0x77777000, 21784, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x77777000
close(3)                                = 0
munmap(0x77884000, 4096)                = 0
open("/lib/libc.so.0", O_RDONLY)        = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=413076, ...}) = 0
close(3)                                = 0
stat("/lib/ld-uClibc.so.0", {st_mode=S_IFREG|0755, st_size=28976, ...}) = 0
open("/lib/libc.so.0", O_RDONLY)        = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=413076, ...}) = 0
close(3)                                = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|0x4000000, -1, 0) = 0x77884000
set_thread_area(0x7788b440)             = 0
mprotect(0x7782a000, 4096, PROT_READ)   = 0
mprotect(0x77775000, 4096, PROT_READ)   = 0
mprotect(0x77886000, 4096, PROT_READ)   = 0
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++
Segmentation fault
JJJ
  • 31,545
  • 20
  • 84
  • 99
MOHAMED
  • 35,883
  • 48
  • 140
  • 238
  • Generally, bug in the library. – Shahbaz Oct 10 '13 at 08:05
  • Could you also add output of `nm liblib2.so | grep printf`? (of course substitute with correct library name) – keltar Oct 10 '13 at 08:34
  • 1
    Please show few lines right **before** this `#ifdef` block: this block is affecting some function definition preceding it – mvp Oct 10 '13 at 08:36
  • It does not seem like mxmlSetTextf() is actual culprit - it is not like it is trying to redefine something as trivial as `printf`. You may have some luck starting your executable under `strace` and of course the best is to debug the whole thing under `gdb`. – mvp Oct 10 '13 at 09:24
  • @mvp I added the strace output. could you find out the reason now? – MOHAMED Oct 10 '13 at 09:45
  • @keltar the `nm liblib2.so | grep printf` return U fprintf U snprintf U sprintf U vsnprintf – MOHAMED Oct 10 '13 at 09:53
  • I may be off here, but it seems like some code is using `old_mmap()` syscall to map some file into memory, then uses `mprotect()` with `PROT_READ` to make it read-only, and then some code is trying to write into that memory location. This is causing `SIGSEGV` – mvp Oct 10 '13 at 09:54
  • @Shahbaz I found out the reason of the segmentation fault bit I do not understand the reason. Please refer to the following link to see the cause of the segfault: http://stackoverflow.com/questions/19319392/adding-usr-lib-in-the-build-options-of-a-shared-library-cause-a-segfault – MOHAMED Oct 11 '13 at 13:41

1 Answers1

1

In shared library, if function is defined with __attribute__((constructor)), it will be automatically executed when shared library is loaded.

Since you are not calling any functions from that shared library, crash must be occurring in initialization code of that library (one that was defined with constuctor attribute). That is most likely bug in the library or some assumptions of that library which are not met. Quite possibly, it requires presence of yet another shared library, which is not present on your system.

mvp
  • 94,368
  • 12
  • 106
  • 137
  • It is also possible that this library redefined `printf`. Unlikely, but still. – keltar Oct 10 '13 at 08:18
  • the lib2 code contains ` # ifdef __GNUC__ __attribute__ ((__format__ (__printf__, 3, 4))) # endif /* __GNUC__ */` . could this be the reason of the segfault? – MOHAMED Oct 10 '13 at 08:24
  • The `__attribute__ ((__format__ (__printf__, 3, 4)))` is a hint that the previous function takes a printf-like parameter that can be checked for content and quantity of parameters passed. It, in itself, is not triggering the problem. – Petesh Oct 10 '13 at 09:31
  • @Petesh: you are correct. But in this case it affects function `mxmlSetTextf()`, which OP is not calling. So, this cannot be the culprit. – mvp Oct 10 '13 at 09:36
  • @mvp I should have directed this directly at the OP. There don't look to be constructors in the library. There are some pthread shenanigans, though, which means the code needs to be compiled & linked multithreaded – Petesh Oct 10 '13 at 09:56
  • @Petesh In fact there is a part of thread code in the minixml lib. But it's not builded. And it's under the `#ifdef` macro. `#ifdef HAVE_PTHREAD_H /**** POSIX threading ****/`. the compiltaor do not go over this bloc of threading code – MOHAMED Oct 10 '13 at 12:29
  • @Petesh I found out the reason of the segmentation fault bit I do not understand the reason. Please refer to the following link to see the cause of the segfault: http://stackoverflow.com/questions/19319392/adding-usr-lib-in-the-build-options-of-a-shared-library-cause-a-segfault – MOHAMED Oct 11 '13 at 13:40
  • @mvp I found out the reason of the segmentation fault bit I do not understand the reason. Please refer to the following link to see the cause of the segfault: http://stackoverflow.com/questions/19319392/adding-usr-lib-in-the-build-options-of-a-shared-library-cause-a-segfault – MOHAMED Oct 11 '13 at 13:41
  • @mohamed sounds like an environmental build issue - is this an lfs environment? I've seen this when some of the toolchain is built ever so slightly incorrectly. The run-time linker crashes when loading libraries that specify an rpath. It doesn't crash when the binary has the rpath, though. I've always worked around it by explicitly making sure that an rpath is not on the library, and have a tool for removing it from other third party supplied libraries. – Petesh Oct 11 '13 at 14:18
  • @Petesh Do you know why we have to remove rpath from building? Have an explaination fro that? – MOHAMED Oct 12 '13 at 09:12
  • It seemed to be an error with the run-time linker. I've never been able to consistently reproduce it. – Petesh Oct 12 '13 at 10:48