Unhandled Win32 exception AkelPad.exe 13132 - long filenames

English main discussion
Post Reply
  • Author
  • Message
Offline
Posts: 32
Joined: Thu Oct 15, 2015 2:20 am

Unhandled Win32 exception AkelPad.exe 13132 - long filenames

Post by CBruce »

I have some files with LONG filenames that look like they might be causing AkelPad to throw an exception error.

Individual filenames up to 218 characters long.
Path + filename up to 244 characters long.

If I move a file to the root folder and try to open/save it, AkelPad still crashes.

Both the filename length and the path+filename length are well within the Windows limits - and I don't have problems with any other applications that are dealing with them - (file explorer, internet browsers, etc.).

I can't find the filename buffer in the AkelPad source code - so I'm wondering if anyone knows what AkelPad has for a maximum filename length?

Thanks,
CBruce

DV
Offline
Posts: 1250
Joined: Thu Nov 16, 2006 11:53 am
Location: Kyiv, Ukraine

Re: Unhandled Win32 exception AkelPad.exe 13132 - long filen

Post by DV »

I think I know what is happening.
All the file name buffers in AkelPad's source code are declared as

Code: Select all

wchar_t wszOpenFile[MAX_PATH];

Code: Select all

wchar_t wszFile[MAX_PATH];
and so on.
Correspondingly, if the full path name to be opened is exactly MAX_PATH characters long, there is no space for the last trailing '\0' character in the wszOpenFile/wszFile/etc buffer and it leads either to overflow that can be survived or to overflow that can not. (The exact behavior seems to rely on the current memory state of the application.)
Most likely automatic replacements of all

Code: Select all

[MAX_PATH]
to

Code: Select all

[MAX_PATH+1]
should fix the problem (don't omit the square brackets!).

DV
Offline
Posts: 1250
Joined: Thu Nov 16, 2006 11:53 am
Location: Kyiv, Ukraine

Re: Unhandled Win32 exception AkelPad.exe 13132 - long filen

Post by DV »

Or maybe I'm wrong.
As far as I can see, the file path becomes corrupted after calling the system's function GetFullPathNameW from the function GetFullPathNameWide.
Interestingly, GetFullPathNameW can return 261 (MAX_PATH+1) even when the buffer length passed to it was 260 (MAX_PATH) - and in this case GetFullPathNameW does not fill its second string parameter completely, leaving garbage in it.

Offline
Posts: 32
Joined: Thu Oct 15, 2015 2:20 am

Post by CBruce »

My immediate thought was that the path+filename was too long for MAX_PATH - but remember, I said that my max path in use is only 244 characters.

So I had time to play a bit this morning and found out that AkelPad abends when the path+filename >= 197.

Perhaps AkelPad is internally quoting the filename (+2 characters) and allowing for a null byte (+1 character) and only has a buffer length of 200 characters?... Because 197 seems a bit odd.

Anyway, that 197/200 length is 60 characters shorter than Windows MAX_PATH.

I'm on Windows 10 Pro 64-bit English.

DV
Offline
Posts: 1250
Joined: Thu Nov 16, 2006 11:53 am
Location: Kyiv, Ukraine

Post by DV »

Please provide an example of path + file name < 200 characters that leads to a problem. Or better two examples. I could not reproduce it with full path length less than 260, though it's under Windows 7 64-bit.
Oh, and AkelPad itself is 32-bit or 64-bit?

Offline
Posts: 32
Joined: Thu Oct 15, 2015 2:20 am

Post by CBruce »

The abend occurs when I edit and then hit Ctrl-S to save the file.

It can be the only file being edited - or one of many files.

Mistake above: >= 198 not 197... which leads me back to a 200 byte/character buffer which would allow for a quoted path string.

EDIT: hmm... testing some more... sometimes it's a length of 198, sometimes 199, sometimes 200 that causes the abend.

AkelPad 4.9.8 x64

(97 KB file) - (path length = 210)
--------------------------------------
D:\BEH_Projects\Project 001\BEH(12) - Bit Twiddling Hacks - Sean Anderson - (indistinguishability obfuscation, public key, PKE, subleq, brainfuck, bits, bit operations, metamorph, polymorphic, encryption,).html

(2 KB file) - (path length = 198)
(this was my test path name to figure out where the break was)
------------------------------------
D:\BEH_Projects\Project 001\BEH(12) - Some Bit Twiddling functions explained - Project Nayuki - (indistinguishability obfuscation, source code, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1234567.txt

DV
Offline
Posts: 1250
Joined: Thu Nov 16, 2006 11:53 am
Location: Kyiv, Ukraine

Post by DV »

I could not reproduce it under Windows 7 64-bit.
It might be something related to particular environment (Windows 10? disk encryption? antivirus? etc?). What about other editors: the standard Notepad, SciTE, Notepad++, etc. - are you sure they don't have the same problem?

Offline
Posts: 874
Joined: Sat Jan 16, 2010 2:03 pm

Post by opk44 »

1. I could not reproduce it too (under Windows XP 32-bit).
2. Maybe SaveFile plugin is "ON" (with SaveMethod = "Save a copy in directory")?

Offline
Posts: 32
Joined: Thu Oct 15, 2015 2:20 am

SOLVED !!!

Post by CBruce »

Great catch, opk44 !!!

It was:
2. Maybe SaveFile plugin is "ON" (with SaveMethod = "Save a copy in directory")?

No problems at all with the [Save Copy] option turned off.

I use PortableApps version and save the copies to a directory at the head of the PortableApps directory... with that long path, and the AkelPad TMP suffix, the full path+filename of the TMP file becomes this:

D:\PortableApps\PortableApps\AkelPadPortable\App\AkelPadx64\..\..\..\..\AkelPad_temp_files\BEH1234 - Some Bit Twiddling functions explained - Project Nayuki - pindistinguishability obfuscation, source code, aaaaaaaaaaaaaaaaaaaaaaaaaaa123456789.txt.124357008.tmp

Which means that my filename itself can only be approximately 196 characters long.

Also, I think something got re-addressed in memory today... instead of [Save Copy] crashing AkelPad, I am only getting [Cannot create file "".] errors when the attempted save happens.

I'll create a MUCH shorter TMP file path to get the functionality I want.

THANKS for helping!
CBruce

Offline
Site Admin
Posts: 6311
Joined: Thu Jul 06, 2006 7:20 am

Post by Instructor »


Offline
Posts: 84
Joined: Wed Jan 27, 2016 6:53 pm
Location: Europe

Post by SaFeTyPe »

I am aware this is an old thread with a topic that is only related.

Quick question: Is it normal that when I try to open a file with path+filename=more than around 256 (+/-), Akelpad will bring a dialogue that asks "create file "(path to the file to be opened, but without filename)"? And when one clicks "yes" it will say "cannot create "(path to file)".

The path to the file was considerably less than 200 characters, but the filename was around 100 characters.

I just wonder why it does not say "cannot open file because path+filename too long"....

Windows Editor has no problem opening the file.

I am using Windows 11 Pro ARM (release channel), AkelPad x64, and I have enabled in the Windows registry (several months ago, with no problems) that path lengths longer than 256 (+/-) should be allowed.

DV
Offline
Posts: 1250
Joined: Thu Nov 16, 2006 11:53 am
Location: Kyiv, Ukraine

Post by DV »

SaFeTyPe wrote:I am using Windows 11 Pro ARM (release channel), AkelPad x64, and I have enabled in the Windows registry (several months ago, with no problems) that path lengths longer than 256 (+/-) should be allowed.
Actually, it took only 20 years for Microsoft to do this change :) I mean, the problem was well-known even before Windows 2000, and only Windows 10 introduced a solution for it.
The similar change must be done in the source files of AkelPad and of all of its plugins. There are a lot of places where static arrays of MAX_PATH symbols are used. In each and every place, this needs to be changed either to a dynamically allocated array or to a static array of greater size. Plus rewriting the code to use the "\\." prefix which is required to support full paths longer than MAX_PATH. (And yes, the full path includes the directory path plus the file name).
Post Reply