• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Calling fopen() from a simple C++ program in Xcode 5.0.2 raises EXC_BAD_ACCESS, code=2
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Calling fopen() from a simple C++ program in Xcode 5.0.2 raises EXC_BAD_ACCESS, code=2


  • Subject: Re: Calling fopen() from a simple C++ program in Xcode 5.0.2 raises EXC_BAD_ACCESS, code=2
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Wed, 25 Dec 2013 11:32:39 +0100

Depending how the server enforce limitation, you may managed to do what you want using curl and the '-r' option, which let you specify a range of the file you want to download.

Maybe requesting "small enough" ranges one after an other will work.


Le 24 déc. 2013 à 19:31, Dan Korn <email@hidden> a écrit :

Thanks Ken.  That was it.  That also explains why removing the code that declares that variable prevents the crash.

FWIW, the same program built and debugged in Visual Studio raises a stack overflow exception, which is much more helpful feedback than just "bad access."

I guess I failed at my little C++ 101 project here.  (I'm also getting zero back from the call to fread; I need to put specify the item size of 1 before the size in bytes.)

By the way, what I'm really trying to do is download a very large .dmg file that was my setup from my old MacBook Pro, so that I can restore it to a partition on the new one.  It's on a server which apparently has no limit on the size of files you can upload, but does have a limit on the size of a file you can download.

Thanks again,
Dan

On Mon, Dec 23, 2013 at 11:45 PM, Ken Thomases <email@hidden> wrote:
On Dec 23, 2013, at 9:49 PM, Dan Korn wrote:

    const size_t inBufferSize = 10000000; // about 10 MB

        char buffer[inBufferSize];

The default stack size is 8MB.  Your "buffer" variable exceeds that.  I suspect that's the problem.  Don't put such large buffers on the stack.  Allocate them on the heap.

Regards,
Ken




On Mon, Dec 23, 2013 at 11:45 PM, Ken Thomases <email@hidden> wrote:
On Dec 23, 2013, at 9:49 PM, Dan Korn wrote:

    const size_t inBufferSize = 10000000; // about 10 MB

        char buffer[inBufferSize];

The default stack size is 8MB.  Your "buffer" variable exceeds that.  I suspect that's the problem.  Don't put such large buffers on the stack.  Allocate them on the heap.

Regards,
Ken


-- Jean-Daniel




 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Calling fopen() from a simple C++ program in Xcode 5.0.2 raises EXC_BAD_ACCESS, code=2
      • From: Dan Korn <email@hidden>
References: 
 >Calling fopen() from a simple C++ program in Xcode 5.0.2 raises EXC_BAD_ACCESS, code=2 (From: Dan Korn <email@hidden>)
 >Re: Calling fopen() from a simple C++ program in Xcode 5.0.2 raises EXC_BAD_ACCESS, code=2 (From: Ken Thomases <email@hidden>)
 >Re: Calling fopen() from a simple C++ program in Xcode 5.0.2 raises EXC_BAD_ACCESS, code=2 (From: Dan Korn <email@hidden>)

  • Prev by Date: Re: Adding a breakpoint creates three entries in the breakpoints list
  • Next by Date: Re: Adding a breakpoint creates three entries in the breakpoints list
  • Previous by thread: Re: Calling fopen() from a simple C++ program in Xcode 5.0.2 raises EXC_BAD_ACCESS, code=2
  • Next by thread: Re: Calling fopen() from a simple C++ program in Xcode 5.0.2 raises EXC_BAD_ACCESS, code=2
  • Index(es):
    • Date
    • Thread