This seg fault seems to be less common than the one seen in #47.
Occasionally (every 25 runs or so), write_fw1_cursorfile will return -1. This also usually (but not always) results in a crash complaining of memory corruption or double free with something like the following backtrace from turning on DEBUG:
where in this case, the write_fw1_cursorfile in submit_screen() is returning the -1.
I added additional logic to write_fw1_cursorfile just to see what errno was being returned by fprintf, and it is EBADF (Bad file descriptor). I am not sure if this indicates an early close somehow or some type of overwrite of static memory. If I compile a version without #37, I never experience the crash, but it is not clear to me whether that change is to blame or it is affected by some type of latent bug.
The only error messages seen are:
ERROR: Error when updating cursor.
ERROR: -1 characters written instead of 33.
A normal run through valgrind showed one explicit memory error that the string being passed to atoi in write_fw1_cursorfile is only NULL terminated due to undefined behavior (the position char string seems to rely on the underlying memory to be 0's which is not a guarantee even though it is likely). However, initializing this array fixed the memory error but did not seem to solve the problem unfortunately.
This seg fault seems to be less common than the one seen in #47.
Occasionally (every 25 runs or so), write_fw1_cursorfile will return -1. This also usually (but not always) results in a crash complaining of memory corruption or double free with something like the following backtrace from turning on DEBUG:
free() stringlist_delete() exit_loggrabber() submit_screen()
where in this case, the write_fw1_cursorfile in submit_screen() is returning the -1.
I added additional logic to write_fw1_cursorfile just to see what errno was being returned by fprintf, and it is EBADF (Bad file descriptor). I am not sure if this indicates an early close somehow or some type of overwrite of static memory. If I compile a version without #37, I never experience the crash, but it is not clear to me whether that change is to blame or it is affected by some type of latent bug.
The only error messages seen are: ERROR: Error when updating cursor. ERROR: -1 characters written instead of 33.
A normal run through valgrind showed one explicit memory error that the string being passed to atoi in write_fw1_cursorfile is only NULL terminated due to undefined behavior (the position char string seems to rely on the underlying memory to be 0's which is not a guarantee even though it is likely). However, initializing this array fixed the memory error but did not seem to solve the problem unfortunately.