06 Dec, 2009, Brinson wrote in the 1st comment:
Votes: 0
So I get the following errors on two separate but related pieces of code, one is a fork of the other.

Sun Dec  6 16:10:04 2009 :: [*****] BUG: Error creating area html file

Program received signal SIGSEGV, Segmentation fault.
_IO_new_fclose (fp=0x0) at iofclose.c:52
52 iofclose.c: No such file or directory.
in iofclose.c
(gdb) quit
A debugging session is active.


Program received signal SIGSEGV, Segmentation fault.
_IO_fwrite (buf=0x831f3bf, size=1, count=7, fp=0x0) at iofwrite.c:43
43 iofwrite.c: No such file or directory.
in iofwrite.c


Bugs spawn from the use of fwrite, fread, fopen, ect. It was my understanding there were in stdio.h, which I have included. Any ideas? These pieces of code ran pretty recently. I'm forced to believe this error is because of some kind of change outside the mud, but don't know other than that.
06 Dec, 2009, Tyche wrote in the 2nd comment:
Votes: 0
fp=0x0

The file handle is a null pointer. I would guess the file was never opened successfully.
06 Dec, 2009, Davion wrote in the 3rd comment:
Votes: 0
If you're using a diku-rivative that uses fpReserve, and somewhere in your code, you're using it improperly, this can lead to bad juju. If you don't want to look all over the place for proper uses, you can simply remove every reference to fpReserve in the code. If this doesn't clear it up… uhh, come back! :).

Edit: First look into what Tyche said above (ninja'd! :redface:)
06 Dec, 2009, Runter wrote in the 4th comment:
Votes: 0
Davion said:
If you're using a diku-rivative that uses fpReserve, and somewhere in your code, you're using it improperly, this can lead to bad juju. If you don't want to look all over the place for proper uses, you can simply remove every reference to fpReserve in the code. If this doesn't clear it up… uhh, come back! :).

Edit: First look into what Tyche said above (ninja'd! :redface:)


I would remove fpReserve anyways.
06 Dec, 2009, Brinson wrote in the 5th comment:
Votes: 0
I'll toy with it. Have no experience with fpReserve, though, and it seems half the files in the code I'm toying with use it.
06 Dec, 2009, Runter wrote in the 6th comment:
Votes: 0
Brinson said:
I'll toy with it. Have no experience with fpReserve, though, and it seems half the files in the code I'm toying with use it.


fpReserve is more than likely doing nothing for you but additional overhead. Not that it's really that much, anyways.
06 Dec, 2009, Brinson wrote in the 7th comment:
Votes: 0
The codebase seems to use it extensively in its code which generates static html pages based upon IG stuff, such as combat, character deaths, ect.

Also seems to be used for logs. I'm still pretty much a newbie when it comes to coding.
06 Dec, 2009, Davion wrote in the 8th comment:
Votes: 0
Then listen to Tyche ;).

Tyche said:
fp=0x0

The file handle is a null pointer. I would guess the file was never opened successfully.


Find out where the calls to fopen are, and add proper error checking. Should look something like this ->
if( !(fp = fopen(PATH, 'r') ) )
{ perror(fp);
return;
}
07 Dec, 2009, Runter wrote in the 9th comment:
Votes: 0
Brinson said:
The codebase seems to use it extensively in its code which generates static html pages based upon IG stuff, such as combat, character deaths, ect.

Also seems to be used for logs. I'm still pretty much a newbie when it comes to coding.


Yeah, well, you could remove every reference to fpReserve and it would still operate the same way.

All that fpReserve does is reserve a file stream—the logic is because you always keep one "reserved" it will be ready when you need it.

It may have had a place years and years ago when maybe you would need a reserve. But today it's similar to something
like:

static void *strReserve = malloc(MAX_STR_LENGTH); // just to make sure we have that memory available for us to use.
free(i);

actual_string = strdup("ROARRR"); // Yay, had memory available to roar!!
free(actual_string);

strReserve = malloc(MAX_STR_LENGTH);
07 Dec, 2009, Mudder wrote in the 10th comment:
Votes: 0
"Yay, had memory available to roar!!" - I lol'd.
07 Dec, 2009, Runter wrote in the 11th comment:
Votes: 0
For anyone reading that I actually messed the code example up a little bit and didn't catch it before the edit option went away. Boo.

Here's the small change:
static void *strReserve = malloc(MAX_STR_LENGTH); // just to make sure we have that memory available for us to use.

@@free(strReserve);
//Was free(i); for some reason.

actual_string = strdup("ROARRR"); // Yay, had memory available to roar!!
free(actual_string);

strReserve = malloc(MAX_STR_LENGTH);
07 Dec, 2009, David Haley wrote in the 12th comment:
Votes: 0
Runter, are you posting your code with random languages (lolcode, fortran) as an act of protest to the syntax coloring? :wink:
0.0/12