Kevin Day [Wed, 29 Mar 2023 23:24:15 +0000 (18:24 -0500)]
Regression: Build test.sh script is not properly running.
Three mistakes are introduced by the commit 362c7b9f6cd57421a18c0148fb6eb9bda165bcd2.
1) The error handling return status checks are against empty string and not "0".
2) The test.sh script is backported from the 0.7.x development branch and accidentally included projects not existing in this 0.6.x branch.
3) Accidental copy and paste mistake where print variable is being used as if it were a function.
Remove the failure=0 assignment.
The default of failure="" is what is needed.
The fl_path project is actually fll_path.
The variable print_line_first is supposed to be test_print_first.
The unit tests might also be back ported at a later time.
Writing unit tests exposed this problem.
The last1 and last2 positions could be the exclusive stop points.
The comparison checks fail to handle this situation and expect the last1 and last2 variables to not be positioned at an exclusive stop point.
This results in an invalid read.
Kevin Day [Mon, 27 Mar 2023 12:33:28 +0000 (07:33 -0500)]
Bugfix: The fl_string parsing functions do not check buffer.used.
The range length is being performed but not the buffer used length.
Add the appropriate return codes to represent end of string (buffer used length is reached).
This is applicable for the dynamic strings but is not applicable for the regular strings.
Kevin Day [Tue, 21 Mar 2023 03:52:41 +0000 (22:52 -0500)]
Bugfix: Out of date repository build scripts.
The repository build scripts are very much out of date.
A recent bugfix, commit 9a021eb4044cf8cb63bcef6f8851566b4bc574c7, attempted to partially address this.
It turns out that there is a lot more that needs to be done.
All of the repository build scripts are now updated.
Make sure the copyright parameter is available.
Make sure the "+Q/++quiet" and "+E/++error" parameters are correct and working.
This is a copy of the changes from commit 736d99ce416da505e859c9ee3890b3adf119260f from the 0.7.0 development branch.
The 0.7.0 parameters "+F/++line_first_no" and "+L/++line_last_no" are removed as they are not available in 0.6.0 stable branch versions.
The relevant code remains, it is just unused.
Improve return status handling.
The goal here is to avoid calling "exit".
The use of "exit" is not safe as under certain conditions it can close terminals that the script is running in.
Kevin Day [Mon, 20 Mar 2023 03:14:02 +0000 (22:14 -0500)]
Bugfix: Out of date install.sh and Featureless Make helper scripts.
It seems that I never looked at these in a while and they are rather out of date.
Fix the parameters.
There are other scripts that need to be looked at as well and are not solved by this commit.
I fixed this in 0.7.0.
I decided to cheat with install.sh and copy over the file with the newer features.
Just disable those features by deleting a few lines to maintain synthetic API compatibility.
This is a script and so API is not really a thing.
Kevin Day [Thu, 16 Mar 2023 23:17:26 +0000 (18:17 -0500)]
Update: Add unit tests for fll_path.
I noticed that the '~' path is not expanded.
I checked to see if this is intentional or not.
It is intentionally not supported yet.
I need another function.
This check encouraged me to write some unit tests for the current behavior.
It seems that I had forgotten just how few unit tests I have.
Now there are at least more.
Kevin Day [Sat, 11 Mar 2023 02:42:53 +0000 (20:42 -0600)]
Update: Add example contrroller script for running under systemd using cgroups.
This provides an example cgroups setup.
I found that on systems with cgroups2, this is harder to figure out.
This turned out to be because of the existing setup used by many systemd systems.
This provides an example that I managed to get to work under some systems in some circumstances.
The biggest problems is that the subtree needs to be passed along and that tends to not be done by default.
The current user, if not root, usually lacks the privileges to do so.
The best case would be to use the cgroups generation when running as root to setup the appropriate user.
Then, use the program startup examples as the normal user.
This should show the cgroup situation.
I would not be surprised if the cgroup setup scripts has to be altered (not just the user and group name).
Kevin Day [Thu, 9 Mar 2023 05:00:33 +0000 (23:00 -0600)]
Feature: Add support for 'helper' mode to compliment the 'program' mode.
This is a bug fix disguised as a new feature.
When controller runs in program mode and is cancelled, all background (asynchronous) processes are cancelled.
My original thoughts were that background processes should stay open in program mode.
This is the bug being fixed.
I believe that there are use cases to operate in "program" mode and to always terminate the background processes in this manner.
Rather than fixing one case and breaking the other, this is a new feature that helps solve both cases.
The "program" mode operates in the same manner unchanged.
The new "helper" mode operates by detaching background (asynchronous) processes on exit.
The foreground process still runs and blocks normally.
A terminate signal might still terminate background processes.
More work is likely needed in this regard.
This stretches the original design to its limits.
The 0.7.x versions and later will need re-design to better handle these cases.
The original design I used was a learn as I go for thread design.
This resulted in rather messy code.
Now that I made it to this point, the controller program (0.6.x and earlier) can be used as a stepping stone for a better design.
Some of the problems are worked-around.
The program starts and exits too fast in controller mode.
The child processes end up getting terminated before a complete process is started and then backgrounded.
The work-around is to add a short sleep.
This is not reliable but for most cases it should be fine.
Additional work-arounds may be needed by the user such as executig their own sleep foreground process.
Kevin Day [Thu, 9 Mar 2023 02:47:47 +0000 (20:47 -0600)]
Cleanup: Remove dead code in controller program.
The process variable is not used.
I decided to not remove the now unused process parameter from the relevant functions.
This prevents breaking API and ABI.
Kevin Day [Thu, 9 Mar 2023 02:27:46 +0000 (20:27 -0600)]
Bugfix: Multiple cancellations may occur, use mutex lock to prevent.
There is an existing check that prevents the cancellation from being called more than once.
What is not being considered is that if the main thread calls cancellation while another cancellation is active then the controller_thread_process_exit() gets called.
The controller_thread_process_exit() function will begin more forcibly shutting things down.
Avoid this by providing a mutex lock to lock the cancellation.
Only once the first cancellation is complete will the second (or more) then return without doing anything.
This clarification paved the way for a solution to the bug where lines with unterminated quotes are not getting anything at all.
By "favoring the typo", the rest of the line is preserved and is able to be printed.
Kevin Day [Mon, 6 Mar 2023 03:45:13 +0000 (21:45 -0600)]
Update: Further clarify quoting in FSS specifications.
I looked at the code and realized I should instead favor the "typo" behavior.
Process until the end of the line rather than break up the Object due to the quotes.
This means if the quote is unterminated then the rest of the line is considerd the Object.
Also document where Content utilizes the same rules.
Example Object and Content pair following FSS-0001:
Object "Content".
The Content would be "Content".
This behavior effectively preserves the period and also retains the quotes.
Another example (FSS-0001):
"Object 1" "Content 1" Content2 and_3
"Object 2": Content.
This second row shows the "typo" is favored concept.
The second row has no Content and instead has the following as the "Object: Object 2": Content.
Note how the quotes are kept when this situation happens.
I also updated the word "newline", replacing it with the words "new" and "line".
I noticed and fixed a mistake in the logic due to this refactor and a similar previous refactor.
Kevin Day [Mon, 6 Mar 2023 01:37:30 +0000 (19:37 -0600)]
Update: Clarify FSS specifications in regards to quote behavior.
I noticed a problem where something that is quoted with an immediate character after it does not get processed.
Example Object and Content pair following FSS-0001:
Object "Content".
In the above example, notice how there is a period after the quotes.
Also notice how the content has no spaces.
The current behavior would treat the "Content". as invalid.
I reviewed the specifications and found them lacking in regards to this dilemma.
I updated the specification to clarify the behavior.
With this change the FSS read functions will need to be updated.
Another example (FSS-0001):
"Object 1" "Content 1" Content2 and_3
"Object 2": Content.
In the above example for an FSS-001, the first row is straight-forward.
The second row is a problem.
Because there is non-white space after the quote, this cannot be treated as a quoted Object.
The behavior would then be to treat this as not quoted.
This means for row two, the object name is: "Object
The first Content is 2":
The second Content is Content.
Kevin Day [Mon, 6 Mar 2023 01:16:21 +0000 (19:16 -0600)]
Feature: Implement wrap support for IKI standard to be compliant with recent changes.
The wrap support for IKI (using open and close brackets '[' (U+005B) ']' (U+005D)) has been recently added to the specification.
This updates the project to be in compliance.
Kevin Day [Sun, 5 Mar 2023 20:51:19 +0000 (14:51 -0600)]
Bugfix: Dead code in return status handling.
The fake_make_operate_process_return() has dead code where it checks for the inverse of the return_code in two spots.
The first of which always returns.
The second case can never be reached.
Redesign the function.
This success/failure behavior should be preserved with this change.
Add a simple example fakefile for testing the return code value.
Kevin Day [Thu, 2 Mar 2023 04:03:23 +0000 (22:03 -0600)]
Feature: The IKI standard now supports bracket wrapping.
I wanted to avoid this and keep IKI as simple as possible.
My recent uses have shown that I must have some sort of word-separator support.
This is the simplest implementation that I can think of at this time.
The brackets do not get escaped, instead the IKI gets escaped.
If there is no closing brracket in the correct spot, then the first bracket is not part of the variable.
The brackets other than the opening at the front and the closing bracket at the end are allowed.
The vocabulary name never includes the open and close bracket.
The following shows the heart of the problem this feature solves:
Consider:
- helloworld:"earth".
What if "world" is the variable name and hello is not supposed to be space separated?
With this featre, now the following is possible:
- hello[world]:"earth"
Note that the following are not valid (that is to say these are not IKI variables):
- hello[world:"earth"
- heloworld]:"earth"
- hello[[world]]:"earth"
Kevin Day [Wed, 1 Mar 2023 06:05:31 +0000 (00:05 -0600)]
Bugfix: Miscellaneous problems in file functons and Featureless Make related code.
Fix documentation inaccuracies such as "Set to 0 to not use." when 0 is not a "not use" value and is instead a valid value with discrete meaning.
Remove documentation about non-existent parameter "file".
Clarify the wording in some of the documentation.
Add missing return on error check after several memory allocation function calls.
Add missing range parameter checks.
Error checking is being performed on wrong status variable and wrong status variable is being returned.
Perform some general code clean up as encountered.
Kevin Day [Fri, 24 Feb 2023 02:23:47 +0000 (20:23 -0600)]
Cleanup: Make the error messages with fallback warning messages.
Follow up the previous commit (4d7d66565a555baf9d7df72255c1063bc8858072) with an even better improvement.
Use warning rather than error and then only display on verbose or greater.
Kevin Day [Fri, 24 Feb 2023 02:14:39 +0000 (20:14 -0600)]
Cleanup: Consistently apply verbosity to error message with fallback.
The fallback error message is an automatically recovered error.
Only print the error message in verbose mode or greater.
This behavior is followed elsewhere and so this change makes the design more consistent.
Kevin Day [Wed, 22 Feb 2023 23:57:58 +0000 (17:57 -0600)]
Bugfix: Control group function is partially outdated and uses incorrect integer.
The F_control_group_path_system_default_s_length should not be used here when progressing the path string.
Use control_group.groups.array[i].used instead.
Kevin Day [Wed, 22 Feb 2023 04:45:09 +0000 (22:45 -0600)]
Bugfix: Incorrect and messy file error messages.
The code is unlikely to get to the error cases that print these messages due to other safety checks.
This makes testing this more difficult.
I do not currently have the testing environment for this.
I found the error messages is messed up and incorrect.
Clean up the messages.
This has not been tested due to the above mentioned problems.
Kevin Day [Wed, 15 Feb 2023 05:05:12 +0000 (23:05 -0600)]
Security: Invalid read or write while expanding operations.
The logic here is non-standard.
The normal logic operates on a pre-allocated basis.
That is, right before accessing the data perform the pre-allocation.
This code operates on the expectation that new variables are only added when conditionally required.
This results in a post-allocation basis where once a variable is known to expand then increment the used variable for the next pass.
The allocation checks need to happen after the increment on used.
There are some cases where this post-allocation is not happening.
This is probably a regression in the very recent bug fixes regarding expanding operations.
Be sure to ensure a clean state after the post-allocation process.
Kevin Day [Wed, 15 Feb 2023 04:15:23 +0000 (22:15 -0600)]
Bugfix: Multiple single-valued Objects should used last instead of first Object.
Early on I was uncertain on what the proper behavior should be.
Over time I established that the last Object specified should be used.
This makes sense with most things.
Consider normal math:
x = 1
x = 2
Is x equal to 1 or 2?
I strongly believe the most common interpretation would be "2" because the assignment to "2" comes after the assignment to "1" when reading top-down.
Following this logic, the single-valued settings Objects must use the last occurrence rather than the first.
Kevin Day [Sun, 12 Feb 2023 16:22:20 +0000 (10:22 -0600)]
Feature: Add Turtle Kevux path support.
This does not break API or ABI because it requires macros to be defined that would break it.
These macros, when in use, should not break API (but does extend it) but may break ABI.
The return value may have additional results and might be considered an API but not ABI breaking change.
There is already Kevux-specific code in FLL.
Temporarily continue that process as a short term solution.
In the long term, separate functions or files may be used (or an entirely separate project).
Kevin Day [Mon, 6 Feb 2023 02:51:04 +0000 (20:51 -0600)]
Bugfix: Invalid defines, incorrect comments, missing flags, and missing dependencies.
There is an inconsistency where _di_f_color_string_s_ and _di_f_color_strings_s_ are used.
Settle on _di_f_color_string_s_ because it is defined in the header file.
Incorrect defines, such as _di_f_utf_is_contro_codel_ are removed.
The *.config.h comment example doesn't work.
Consistently add fanalyzer mode and make sure it is available in both settings and fakefile files.
Some of the define macros are missing in regards to private functions.
The controller program is missing f_limit and fl_directory dependencies.
Kevin Day [Tue, 31 Jan 2023 03:09:32 +0000 (21:09 -0600)]
Update: Controller and Control man page documentation.
Move the specification details into man (5) pages.
This further allows for more explicit declaration of the license of the specifications.
The following are the commands used to help generated these man pages:
fss_basic_list_read entry.txt +Q -cn "Entry Specification" | iki_read +Q -w -W code '\fB' '\fR'
Kevin Day [Tue, 31 Jan 2023 02:31:32 +0000 (20:31 -0600)]
Update: Featureless Make man page documentation.
Move the specification details into man (5) pages.
This further allows for more explicit declaration of the license of the specifications.
The following are the commands used to help generated these man pages.
fss_basic_list_read dependencies.txt +Q -cn "Dependencies Specification" | iki_read +Q -w -WWW code '\fB' '\fR' bold '\fB' '\fR' FLL '\fB' '\fR'
Kevin Day [Sun, 29 Jan 2023 23:27:21 +0000 (17:27 -0600)]
Bugfix: The build settings 'path_sources' is incorrectly added.
The commit 79858cf386916fd25ccd3578797de53b16f5c446 fixed a problem with the sources path passed to the program.
This revealed a bug where the build setting 'path_sources' is being added twice.
This is probably why the previous bug was not noticed for so long.
Make sure to apply the passed path sources parameter when the build settings does not have 'path_sources'.
Kevin Day [Sun, 29 Jan 2023 21:44:53 +0000 (15:44 -0600)]
Bugfix: The -S/--sources parameter is not being correctly used.
The parameter is not being properly validated.
The parameter is then not being appended to the appropriate strings.
The default value is being appended to the appropriate strings.
Kevin Day [Thu, 26 Jan 2023 04:27:01 +0000 (22:27 -0600)]
Regression: Serial example rule is not working.
Investigation revealed that the commit 002bf17595459e65173be16f983977ead99593b6 introduced a regression where the cached data is being reset incorrectly.
The data is properly processed but when there is more than a single rule the previous rules are being cleared.
Kevin Day [Thu, 26 Jan 2023 01:23:53 +0000 (19:23 -0600)]
Update: Add additional sanity checks.
The GCC -fanalyzer is reporting a problem that as far as I can tell is a false positive.
This program is older code practices and will eventually be rewritten anyway.
Kevin Day [Thu, 26 Jan 2023 00:56:36 +0000 (18:56 -0600)]
Security: NULL pointer dereference in writer due to pipe function result handling.
The GCC -fanalyzer parameter helped me discover this one.
The status_pipe is being read and processed.
There is a case where the status_pipe is being set but it is not being reset after handling.
In a later loop the pipe does not get read but the previously set state is used bringing the code into a bad state.
Then the loop doesn't do the block buffer used check and this results in the eventual NULL dereference.
Kevin Day [Thu, 26 Jan 2023 00:55:02 +0000 (18:55 -0600)]
Update: Add fanalyzer build mode.
I keep forgetting to run the GCC fanalyzer sanity checks to help catch problems before making a release.
Add a formal mode in all of the build settings to make this processor easier and therefore easier to remember.
Add missing -Wall to some of the files for the test mode.
Kevin Day [Tue, 24 Jan 2023 05:32:01 +0000 (23:32 -0600)]
Bugfix: Fakefile processing with color context is producing extra spaces when unquoted.
Do not generate a new argument when calling fake_make_operate_expand_context().
The color context should combine with existing arguments.
This does not handle the last context argument and more work is likely needed to handle that one.
Remove the not quoted check that always generates a new argument.
The FSS Extended should support one or more Content per Object.
All others support the same number of Objects as Content (not referring to nested Content).
The error and error message when this is and is not correctly being handled.
The correct detection needs to count based on sub locations rather than locations.