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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:39:23+00:00 2026-05-15T17:39:23+00:00

So I have a problem that I can not figure out. I am writing

  • 0

So I have a problem that I can not figure out. I am writing some code in C. I kept winding up with issues where reading from the network would seemly randomly work.

I finally traced it down to the number of strings in the code. I cant believe it but I have verified it pretty in depth.

The code base is rather massive so I am not sure of the overall number of strings parity. However I know that if i add an odd number then the program works, and if i add an even number it doesnt.

Just to clarify when I say it doesnt work, It does still build and execute, but everytime I try to read anything over the network all i get is 0’s. When its working I get the correct data.

has anyone ever heard of anything like this? Or have any idea what could be causing this? I could see if the data portion of the program was getting too large and starting to impede on other code’s space but the fact that its an odd/even thing completely confuses me.

thanks

EDIT (Adding more info):

The platform is a custom designed device. the code base is redboot but its been altered significantly for the custom device.

snipped for example:

//This will work because its an odd number of strings.

char* str1 = "test";
char* str2 = "test2";
char* str3 = "test3";

int i = strlen(str1) + strlen(str2) + strlen(str3);

………………………………..

if i were to change the last line to

int i = strlen(str1) + str(len2);

so that str3 gets optimized out by the compiler then the code will no longer work. I have tested this many times with various lenghts of strings all result in the same odd/even behavior. (i is just sent to a debug log so that its not optimized out. nothing fancy is done with it).

Edit2: The above code can be placed anywhere in the codebase and it causes the same problem. It doesnt matter if its been executed or not, which leads me to believe its not a stack overflow.

  • 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-15T17:39:24+00:00Added an answer on May 15, 2026 at 5:39 pm

    Here is a guess.

    Assume the platform is 32 bit.

    Perhaps the compiler aligns some of the data structutres of your program in memory on eight byte boundaries. You have a whole load of string pointers in your data segment and maybe some other stuff too. If there is an odd number of strings, the next thing that needs an eight byte alignment has four bytes of padding in front of it. If there is an even number of strings, there is no padding.

    Whatever piece of data that is just before that eight byte aligned object has an overflow bug that just destroys the contents of between one and four bytes after it. If there is padding after this thing, nothing bad happens. If there is no padding, the eight byte aligned object gets zapped.

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

Sidebar

Related Questions

No related questions found

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.