Skip to content

Conversation

@Konamiman
Copy link
Owner

@Konamiman Konamiman commented Jan 25, 2025

This pull request fixes a bug that was introduced when FAT16 support was introduced in the CORRECT_BUF routine. When a buffer had to be invalidated after a write, the pointer to the buffer in the buffer chain had been corrupted, and the process eventually caused a crash.

This is difficult to test but some people has reported it being reproduced while using the AKID text editor. See also #142.

Closes #142

@Konamiman Konamiman self-assigned this Jan 25, 2025
@Konamiman Konamiman added this to the v2.1.3 milestone Jan 25, 2025
@Konamiman Konamiman changed the base branch from v2.1 to v2.1.3 January 25, 2025 18:46
@Konamiman Konamiman merged commit aaecca6 into v2.1.3 Jun 2, 2025
1 check failed
@grauw
Copy link
Contributor

grauw commented Jun 3, 2025

I literally JUST got a bug report on my ASCII-X flash tool which after 2 evenings of debugging boiled down to this issue in Nextor, so your new release couldn’t have been more well timed :).

I can confirm my crash that was present in 2.1.2 is fixed in release 2.1.3.

Any suggestions for a workaround I could employ to avoid this bug?

The issue started occurring after I added a file size pre-allocation step on a file newly created with _FNEW, which speeds up file writing because it creates the FAT chain in one go. The code uses _SEEK to move the file pointer to desired size - 1, writes 1 byte, and then seeks back to 0. I also used that method in gunzip, and I know Louthrax does in SofaUnzip, however I didn’t run into this issue before.

@grauw
Copy link
Contributor

grauw commented Jun 3, 2025

To answer my own question, the issue seems to be avoided if I flush and invalidate all buffers after moving the file pointer back to 0, before continuing to write from there.

	ld b,0FFH
	ld d,0FFH
	ld c,_FLUSH
	call BDOS

Oh, but _FLUSH also had a bug prior to 2.1.3… Hmm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nextor crashes when rewriting a file with longer length and crossing a 512-byte boundary in akid (at least)

3 participants