Page 1 of 1

[Wish] longer continuation sections/lines still

Posted: 17 Nov 2020, 21:41
by swagfag
in a114 the 16k continuation section/line char limit was removed.
The following limits have been removed by utilizing dynamic allocations:
  • Maximum line or continuation section length of 16,383 characters.
the new limit now is ~32k chars
test code(add/erase "a"s one at a time)

SimpleHeap is used to process the script's text during loading. eventually, it caps out at

Code: Select all

#define BLOCK_SIZE (32 * 1024 * sizeof(TCHAR)) // Relied upon by Malloc() to be a multiple of 4.
// 65536 bytes, 32768 wchars incl. null terminator

...
void* SimpleHeap::Malloc(size_t aSize) // aSize in bytes
// This could be made more memory efficient by searching old blocks for sufficient
// free space to handle <size> prior to creating a new block.  But the whole point
// of this class is that it's only called to allocate relatively small objects,
// such as the lines of text in a script file.  The length of such lines is typically
// around 80, and only rarely would exceed 1000.  Trying to find memory in old blocks
// seems like a bad trade-off compared to the performance impact of traversing a
// potentially large linked list or maintaining and traversing an array of
// "under-utilized" blocks.
{
	if (aSize < 1 || aSize > BLOCK_SIZE) // <<<<<<
		return NULL;

Re: [Wish] longer continuation sections/lines still

Posted: 18 Nov 2020, 13:46
by kczx3
When would you have a need for this long of a continuation section?

Re: [Wish] longer continuation sections/lines still

Posted: 18 Nov 2020, 20:13
by swagfag
shortly before writing this thread i had a need for such a continuation section

Re: [Wish] longer continuation sections/lines still

Posted: 18 Nov 2020, 21:40
by kczx3
You seriously took my question of “when” literally? I’m just trying to understand a use case of having that much text in a continuation section.

Re: [Wish] longer continuation sections/lines still

Posted: 19 Nov 2020, 03:09
by swagfag
i dont know about a general use case, mine was:
  • i run my vim buffers as ahk scripts
  • i wanna do some throwaway text processing
  • i dont wanna pipe my data into a file ill probably forget to delete when im done
  • the old v1 limit was removed and there isnt a documented new one, i know - lets paste the data into a string
  • wonder why the damn script wont launch
  • spend time figuring out if its my vim setup's, the data's or ahk's fault
  • spend time singlestepping through ahk's source

Re: [Wish] longer continuation sections/lines still

Posted: 20 Nov 2020, 04:38
by nnnik
i dont wanna pipe my data into a file ill probably forget to delete when im done
Sounds like a you problem.

That being said the new limits should be documented rather than hidden away.

Re: [Wish] longer continuation sections/lines still

Posted: 21 Nov 2020, 14:28
by tank
nnnik wrote:
20 Nov 2020, 04:38
Sounds like a you problem
so is every other reason someone comes here. ....
is there some reason to not use an include with tge text?

im reminded of the paradigm in programing of separating content, code, and display

Re: [Wish] longer continuation sections/lines still

Posted: 21 Nov 2020, 15:17
by kczx3
I guess the way I see it is if you’ve got that much text then you should probably just read it in from a file.

Re: [Wish] longer continuation sections/lines still

Posted: 21 Nov 2020, 17:12
by swagfag
im not sure whether lexikos realized there was a new limit(now imposed by another part of the codebase) when he made the change. he might have, and he might have in fact purposefully left it undocumented(in case he intends to change it later down the road) but this seems like an unlikely scenario. either way, had it been documented, obviously this thread wouldnt have existed

Re: [Wish] longer continuation sections/lines still

Posted: 29 Nov 2020, 09:30
by Helgef
SimpleHeap::Malloc is used for a lot of things other than continuation sections. so this limit will also apply to other things too. For example, the number of tokens in an expression. It should probably be fixed at some point.

Cheers.

Re: [Wish] longer continuation sections/lines still

Posted: 30 Jan 2021, 02:44
by lexikos
It should probably redirect to malloc in the case of large allocations, which I think should be some amount significantly below BLOCK_SIZE - or maybe just when aSize > sLast->mSpaceAvailable. Any allocation (below the limit) that won't fit into the remainder of the current block causes a new block to be allocated, leaving the remainder of the current block permanently unused.

Re: [Wish] longer continuation sections/lines still  Topic is solved

Posted: 07 May 2021, 03:18
by lexikos
This was fixed by v2.0-a123 (commit 0ae12156d).

Re: [Wish] longer continuation sections/lines still

Posted: 08 May 2021, 10:29
by swagfag
lexikos wrote:
30 Jan 2021, 02:44
It should probably redirect to malloc in the case of large allocations
i think calls to alloca should be reviewed(unless theres a specific reason for using them)
i can now trigger a stack overflow (for example here https://github.com/Lexikos/AutoHotkey_L/blame/d87b942f0f84a9593e633bfcd21eb91677d25cf5/source/script.cpp#L4816 and maybe in other places) if a long enough continuation section is used