Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1098847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:38:34+00:00 2026-05-17T00:38:34+00:00

i’v got an dynamic-Lib which i build with OBJECTS=keys.o etc2.o foo.o $(CC) -DSYS_MACOSX -g

  • 0

i’v got an dynamic-Lib which i build with

OBJECTS=keys.o etc2.o foo.o
$(CC) -DSYS_MACOSX  -g -fPIC -flat_namespace -L. -lpthread  -Wl,-flat_namespace -dynamiclib  -shared -o libmylib.dylib $(OBJECTS)

My test progam links with this library

$(CC) -DSYS_MACOSX  -g -fPIC testmain.c -o testmain -I. -flat_namespace -L. -lpthread  -lmylib 

When CC=gcc-4.2 I get following error in gdb, when I try to access const symbols in libmylib.dylib:

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000112dd0
0x0000000100004ec7 in extractKeyFromList (keyList=0x112dd0, key=0x1002001e0 "Adresse1.aName1") at keys.c:148

The programm works, with:

  • gcc-4.0 on SnowLeopard
  • gcc-4.3.2 on Debian i386
  • gcc-4.1.2 for arm-angstrom-linux-gnueabi

Update: Here is some debug-output main=main loadKeyList=function in Lib

GCC 4.0:

main:            sizeof KeyList =  149480
loadKeyList:     sizeof KeyList =  149480
loadKeyList:     list at 0xfe88c
loadKeyList:     sizeof list =  149480
loadKeyList:     list->count 3086
main:            sizeof handle->keyList = 149480
main:            handle->keyList at 0xfe88c
main:            handle->keyList->count 3086

GCC4.2

(gdb) run
Starting program: keyextractor -k Adresse1.aName1
Reading symbols for shared libraries ++. done
main:            sizeof KeyList =  166088
loadKeyList:     sizeof KeyList =  166088
loadKeyList:     list at 0x112dd0
loadKeyList:     sizeof list =  166088
loadKeyList:     list->count 3086
main:            sizeof handle->keyList = 166088
main:            handle->keyList at 0x112dd0

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000112dd0
0x0000000100001940 in main (argc=3, argv=0x7fff5fbfefb8) at keyextractor.c:110
110     printf("main:            handle->keyList->count %i\n", handle->keyList->count);
(gdb) 

The Struct looks like this:

typedef struct _KeyList {
    int count;
    Key keys[4152];
} KeyList;

Update 2: This works in gcc-4.2 from main

printf("KEYMAP.keyList[5] at 0x%x count = %i\n", &KEYMAP.keyList[5], KEYMAP.keyList[5].count);
Output: KEYMAP.keyList[5] at 0x112dd0 count = 3086

That’s the same adress like pointer handle->keyList!

KEYMAP looks like:

typedef struct _KeyMapList {
    int count;
    KeyList keyList[];
} KeyMapList;

const KeyMapList KEYMAP = {
  .count = 6,
  .keyList = {
   { ... }, { .... },
   { ... }, { .... },
   { ... }, { .count=3086, keys.... }
   }
};

So whats the problem with gcc-4.2?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T00:38:34+00:00Added an answer on May 17, 2026 at 12:38 am

    My program failed on Linux-x86_64, too

    But the real answer is: you should listen to gcc warnings and compile with -Wall

     keyextractor.c:114: warning: cast to pointer from integer of different size
    

    This warning was in the line, where I called a function from the Lib, without #include-ing the respective Header-File.
    Without function-declartion it worked:

    • i386-architecture as shared lib and static
    • x86_64-architecture only static

    So, after including the right header-file, everything worked fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a text area in my form which accepts all possible characters from
I'm trying to select an H1 element which is the second-child in its group

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.