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 8901893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:28:26+00:00 2026-06-15T01:28:26+00:00

I am trying to port my C GNU/Linux code to FreeBSD. At first I

  • 0

I am trying to port my C GNU/Linux code to FreeBSD. At first I thought it wouldn’t compile and act abnormally, but it didn’t act up on me because it didn’t use functions that the other OS does not have native to it. Although it compiles fine (no errors or warnings using -Wall) the application keeps seg faulting on a line that works normally as intended on a GNU/Linux install.

What I am doing is creating a pointer to a struct and then passing the pointer to a function as a void pointer and then recreating it inside the function.

ex:

typedef struct
{
   int i;
}some_struct;

int main()
{
   some_struct *test = malloc(sizeof(some_struct));
   test->i = -1;
   function(test);

return 0;
}

void *function(void *prarm)
{
   some_struct test = *((some_struct *)param);  //segfaults on this line.
   free(param);


return NULL;
}

On my GNU/Linux install this would allow me to recreate the struct with the passed pointer data locally inside the function and allow me to free the malloced memory from main() but on FreeBSD it seg faults and I do not know why.

If I break at function in gdb and type

p *(some_struct *)param

It successfully prints out my command struct that is created from the pointer and all its variables from inside the function.

Im at a lost at why this is working GNU/Linux and seg faulting on my FreeBSD test machine.

Thanks for any help towards this problem I am having.

  • 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-06-15T01:28:28+00:00Added an answer on June 15, 2026 at 1:28 am

    I don’t see any reason for it to segfault, especially if -Wall is silent.

    One thing that bothers me about this is that there is no apparent declaration in effect for function() at the point of the call in main(). Without a declaration, C assumes the parameter is passed as an integer, and so should give a warning. You could fix this in several ways—add a function declaration above main(), move the function definition above main, or put the declaration in a header file included before main().

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

Sidebar

Related Questions

I am trying to port my working code from Mac OS X to GNU/Linux.
We are trying to port our code from HPX to AIX but getting core
I'm trying to port a computer game from windows to GNU/Linux. It uses Ogre3D,CEGUI,
I'm trying to port some code to 64-bit, but it seems that the thread
I'm trying to port some assembly code written in Visual Studio into GNU inline
I'm trying to port some code from FreeBSD to OS X. The code is
I am trying to port some code form java do F# that generates a
I am trying to port an application from Windows to Linux. In Windows I
I am trying to port this algorithm to clojure. My code is (defn calc-iterations
I trying to port a WinForms project to WPF. But I am have some

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.