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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:33:32+00:00 2026-05-25T01:33:32+00:00

I am using fread to read a large chunk of image data (> 1

  • 0

I am using fread to read a large chunk of image data (> 1 MB) from a file. I recently encountered a bug on MinGW with Windows network shares where a single call to fread like

fread(file, 4, 100000, data);

fails reliably with an “Invalid argument” error, but 10 calls of

fread(file, 4, 10000, data); data += 10000;

succeed and yield the right result. I deduce there must be a maximum size for an fread, which I was not aware of before. I bisected the allowed size of fread and found it to be between 31000 and 32000 blocks of 4 bytes. Has anyone encountered this before? Is this a bug in MinGW? Is there any way to determine the maximum “safe” size for fread?

  • 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-25T01:33:32+00:00Added an answer on May 25, 2026 at 1:33 am

    It’s a known bug in MSVCRT (the Microsoft Visual C Runtime, which mingw uses) that fread (and perhaps also the underlying _read or whatever..?) fails on moderately long read lengths. You can either break the read down into smaller parts, write your own version of fread to replace the system one (but only do this when compiling on broken systems!), or switch to a better runtime environment (like cygwin) that’s not full of bugs…

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

Sidebar

Related Questions

I'm trying to read encrypted struct data from file using fread(). once i get
when I read from a file using fread (C language), the return value of
I want to read pcm samples from a file using fread and want to
Right now I am using fread() to read a file, but in other language
I am using XML serialization to read a large user input file. If there
I'm trying to read use fread to read in values from an external file
I discovered a nice abstraction whereby I can read in data from UDP using
I've read a file into an array of characters using fread. Now I want
In PHP, a simple read and write file can be done by using fread()
I am using fopen() and fread() to read files if( file_exists( $file ) ){

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.