utf8 library error in Lua 5.3
Posted: 26 Feb 2022 12:28
In the Zooming Media images (20335) thread I have updated the Rename Media to Match Title Field plugin.
I tried using the utf8.gsub(...) function to ensure Media Titles with Unicode UTF-8 characters were fully supported.
However, when looping through the Media records it would crash after a dozen or so loops.
So I have reverted to string.gsub(...) which will probably even handle Unicode UTF-8 characters I hope.
I narrowed the cause of the problem down to the FH pointer 'userdata' structure.
The following minimal script illustrates the problem and can be Run normally or in debug mode:
Usually a short loop such as for i = 0, 5 do does not fail. Only greater repetitions raise the following error:
Several other forms of FH pointer generating API functions have the same effect.
The specific utf8.gsub parameters don't appear to be relevant.
Line 30 in the \utf8\context\runtime.lua file involves a complex setmetatable(...) function.
The problem only affects FH V7 Lua 5.3 and does NOT affect FH V6 Lua 5.1 at all.
Can others repeat the same symptoms?
Should it be reported to CP? Perhaps with suitable debug tools, the problematic interaction can be diagnosed?
I'm not sure reporting it to the utf8 library author will help unless we can find a non-FH method of getting the error.
I tried using the utf8.gsub(...) function to ensure Media Titles with Unicode UTF-8 characters were fully supported.
However, when looping through the Media records it would crash after a dozen or so loops.
So I have reverted to string.gsub(...) which will probably even handle Unicode UTF-8 characters I hope.
I narrowed the cause of the problem down to the FH pointer 'userdata' structure.
The following minimal script illustrates the problem and can be Run normally or in debug mode:
Code: Select all
utf8 = require(".utf8"):init()
for i = 0, 99 do
item = fhNewItemPtr() -- userdata causes \utf8\context\runtime.lua:30 failure
text = utf8.gsub("ABCD","X"," ")
end
Code: Select all
An error has occurred - plugin failed to complete
[string "X"]:37: error in __gc metamethod (...)\Family Historian\Program\Lua\\utf8\context\runtime.lua:30: System error)!
No changes have been made to data records.
The specific utf8.gsub parameters don't appear to be relevant.
Line 30 in the \utf8\context\runtime.lua file involves a complex setmetatable(...) function.
The problem only affects FH V7 Lua 5.3 and does NOT affect FH V6 Lua 5.1 at all.
Can others repeat the same symptoms?
Should it be reported to CP? Perhaps with suitable debug tools, the problematic interaction can be diagnosed?
I'm not sure reporting it to the utf8 library author will help unless we can find a non-FH method of getting the error.