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

  • SEARCH
  • Home
  • 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 9163673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:30:07+00:00 2026-06-17T14:30:07+00:00

Why when I do this: char teststrcpy[5]; strcpy(teststrcpy,thisisahugestring); I get this message in run

  • 0

Why when I do this:

char teststrcpy[5];

strcpy(teststrcpy,"thisisahugestring");

I get this message in run time:

Abort trap: 6

Shouldn’t it just overwrite what is in the right of the memory of teststrcpy? If not, what does Abort trap means?

I’m using the GCC compiler under MAC OSX

As a note, and in answer to some comments, I am doing this for playing around C, I’m not going to try to do this in production. Don’t you worry folkz! 🙂

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-06-17T14:30:08+00:00Added an answer on June 17, 2026 at 2:30 pm

    I don’t own one, but I’ve read that Mac OS treats overflow differently, it won’t allow you to overwrite memory incertian instances. strcpy() being one of them

    On Linux machine, this code successfully overwrite next stack, but prevented on mac os (Abort trap) due to a stack canary.

    You might be able to get around that with the gcc option -fno-stack-protector


    Ok, since you’re seeing an abort from __strcpy_chk that would mean it’s specifically checking strcpy (and probably friends). So in theory you could do the following*:

    char teststrcpy[5];
    gets(teststrcpy);
    

    Then enter your really long string and it should behave baddly as you wish.

    *I am only advising gets in this specific instance in an attempt to get around the OS’s protection mechanisms that are in place. Under NO other instances would I suggest anyone use the code. gets is not safe.

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

Sidebar

Related Questions

I just discovered a bug where the code looked something like this: char *foo
this: char *buf = NULL; scanf(%ms, &buf); will get a dynamically allocated char buffer.
I want to split sentences by a specific char but just if this char
Just wondering if it's safe to cast like this: char **cpp; // ... allocation
at design time I could have declare a variable like this: char szDesignTimeArray[120][128]; The
I was just wondering whether it was possible to do something like this: char
I'm reading a registry value like this: char mydata[2048]; DWORD dataLength = sizeof(mydata); DWORD
Is that safe to do something like this: char* charArray = new char[10]; strcat(charArray,
I have a C-array that looks like this: char hexc[] = { 0x41, 0x80,
If I want to return an empty char* , I can do this char*

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.