Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.apple2.programmer > #1322

Re: memcpy crash

From Kelvin Sherlock <email@domain.com>
Newsgroups comp.sys.apple2.programmer
Subject Re: memcpy crash
Date 2014-09-26 14:47 -0400
Organization A noiseless patient Spider
Message-ID <m04cd1$u8l$1@dont-email.me> (permalink)
References <63dd489a-6736-45ab-bff3-0012e4a60e41@googlegroups.com>

Show all headers | View raw


The third parameter of memcpy (defined in <string.h>) is an unsigned 
long.  Without the prototype, orca/c assumes it's an integer and there 
will be stack corruption.  #pragma lint 1 will warn about that. (I 
suggest #pragma lint -1 to enable all warnings). #pragma debug 16 will 
also generate stack-checking code to catch that at runtime (which can 
be useful with variadic functions like printf).



On 2014-09-26 08:57:27 +0000, AppleIIGSMarc said:

> I've been working on a program in ORCA/C (version 2.1.0) and, for some 
> reason, it crashes anytime I try to call memcpy.  In an effort to 
> figure out what's going on, I wrote the simplest program I could think 
> of to test it out...
> 
> //--------------------------------------
> 
> #include <memory.h>
> 
> int source[64];
> int dest[64];
> 
> int main(void)
> {
>    memcpy(dest, source, 16);
> 
>    return 0;
> }
> 
> //--------------------------------------
> 
> This crashes for me every time I try to run it.  The number of bytes 
> transferred doesn't seem to matter, it crashes even if it's set to 1 
> byte.  Also, manually copying the data with a for loop and setting each 
> element one-by-one works with no problems.  It's late, so I may be 
> doing something really stupid, but I'm not seeing it.  Does anyone have 
> any idea what the problem may be?
> Thanks!

Back to comp.sys.apple2.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

memcpy crash AppleIIGSMarc <appleiigsmarc@gmail.com> - 2014-09-26 01:57 -0700
  Re: memcpy crash Charlie <charlieDOTd@verEYEzon.net> - 2014-09-26 11:54 -0400
    Re: memcpy crash AppleIIGSMarc <appleiigsmarc@gmail.com> - 2014-09-26 10:06 -0700
      Re: memcpy crash Charlie <charlieDOTd@verEYEzon.net> - 2014-09-26 14:17 -0400
      Re: memcpy crash Steven Hirsch <snhirsch@gmail.com> - 2014-09-26 16:31 -0400
        Re: memcpy crash dempson@actrix.gen.nz (David Empson) - 2014-09-27 13:22 +1200
          Calling conventions (was Re: memcpy crash) "Anton Treuenfels" <teamtempest@yahoo.com> - 2014-09-27 11:11 -0500
            Re: Calling conventions dempson@actrix.gen.nz (David Empson) - 2014-09-28 14:13 +1300
            Re: Calling conventions (was Re: memcpy crash) Michael J. Mahon <mjmahon@aol.com> - 2014-09-28 14:56 -0500
              Re: Calling conventions (was Re: memcpy crash) "Anton Treuenfels" <teamtempest@yahoo.com> - 2014-09-28 23:21 -0500
  Re: memcpy crash Kelvin Sherlock <email@domain.com> - 2014-09-26 14:47 -0400

csiph-web