• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

C++: Seg fault when writing large output file

Carlis

Senior member
Hi

I am writing a piece of software that creates a start guess for a simulation of Ginsburg Landau theory. I have the following problem:

When I create a small system, with say 100*100*100*7 data points it all goes well, but when I create a big system (300*300*300*7) points, it seg faults.

So, I am not storing the data in my software in any array or so. Rather, I compute a value for a certain point and write it to file, and then the next...
After about 70,000,000 the software gets seg fault. So, I am wondering, is there a limit in the file size? This one is about 700 megs when it crashes. Do I need to split it into multiple files, or is the problem elsewhere?

I plot by using
ofstream out
out << someData


The code is 64 bit compiled with icc. I have tried under osx and linux with 4-8 gigs of ram.
Best
Carlis
 
There's no file limitation at 700 megs. I doubt that's the problem. You likely are stomping memory somewhere. We'd need to see more code.
 
There's no file limitation at 700 megs. I doubt that's the problem. You likely are stomping memory somewhere. We'd need to see more code.

I agree. It sounds like you are using pointer math which is most likely ending in you going too far. Somehow, it is corrupting data somewhere. (usually what a segfault means)
 
Hi again. Thanks. Yes I was apparently trying to write some data outside of an array so indeed there is no issue with the size of the file. Thanks!
 
fyi: if you write a 2 gig file by default a SIGXFSZ will be thrown. You have to compile with the appropriate options for enabling 64 bit file operations (this is not exactly the same as 64 bit code which has another meaning).
 
Just a side note, with that many elements are you writing it as an ASCII or binary file? If you are writing as an ASCII you can greatly condense the size of the file by using binary (though then you are limited on how to read the file but Matlab can read binaries).
 
The OP already posted that he located the problem, however the formerly deceased thread was waved back to life by the efforts of some meddling necromancer.
 
The OP already posted that he located the problem, however the formerly deceased thread was waved back to life by the efforts of some meddling necromancer.

Ha. I thought I had posted on the same day as the OP but I missed that the post was from the previous month.
 
Back
Top