-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Random Storage_Error in Libadalang.Implementation.Inc_Ref during Libadalang.Rewriting #953
Comments
Hello, When successful, the The correct thing to do is to perform all the calls to We’ll enhance the documentation for |
Thanks for your feedback. Yes, as in the libadalang repository file An update to this misleading file would be great. |
Good point, thank you for pointing this out! Yes, we will definitely fix it. |
Kind of an egg and chicken issue here, we can not perform the calls to
|
I don’t understand your first point: calling
Can you clarify if you have tried this, and if you did and had problems, what these problems were? Regarding your second point, renaming/deleting source files is not in the scope of the rewriting API, and anyway changing unit/source file mappings invalidates unit providers. Our recommendation would be to keep data on the side of your rewriting process to describe the file creation/renaming/deletion required, and apply these operations once the rewriting is done. After that, you will need to create a new unit provider/analysis context for the new set of analysis units. |
Rework not to use any rewriting handle past the call to Libadalang.Rewriting.Apply, since that function destroys all rewriting handles on success. For #953
Great thanks, As a summary;
A fix for -- Write results
declare
Unit_Handles : constant LAL_RW.Unit_Rewriting_Handle_Array
:= LAL_RW.Unit_Handles (Handle);
-- Shall not be used after the call to Libadalang.Rewriting.Apply
Analysis_Units : Libadalang.Analysis.Analysis_Unit_Array
(Unit_Handles'Range);
begin
for Index in Unit_Handles'Range loop
-- Remember which analysis units are to be rewritten
Analysis_Units (Index)
:= Libadalang.Rewriting.Unit (Unit_Handles (Index));
end loop;
declare
Result : constant LAL_RW.Apply_Result := LAL_RW.Apply (Handle);
begin
if not Result.Success then
TIO.Put_Line ("Error during rewriting...");
end if;
for Unit of Analysis_Units loop
-- Go through all rewritten units and generate a ".new" source
-- file to contain the rewritten sources.
declare
Filename : constant String
:= LAL.Get_Filename (Unit) & ".new";
Charset : constant String := LAL.Get_Charset (Unit);
Content_Text : constant Langkit_Support.Text.Text_Type :=
LAL.Text (Unit);
-- Retreive rewritten text,
Content_Bytes : constant String :=
Langkit_Support.Text.Encode (Content_Text, Charset);
-- and encode it using the same encoding
-- as in the original file.
Output_File : TIO.File_Type;
begin
TIO.Create (Output_File, TIO.Out_File, Filename);
TIO.Put (Output_File, Content_Bytes);
TIO.Close (Output_File);
end;
end loop;
end;
end; |
Exactly! Actually we had an update for |
Share implementation of constrain prefix amongst all subps Closes #953 See merge request eng/libadalang/libadalang!1276
Environment
Debian GNU/Linux 10/11 x86_64
GNAT 12.1.2 (66b989b5)
Libadalang 22.0.0 (5f365aa4)
Bug description
After
Libadalang.Rewriting.Apply
is done successfully, calls toLibadalang.Rewriting.Unit
are made to generate new source files.However
Storage_Error
is raised inLibadalang.Implementation.Inc_Ref
as it is called byLibadalang.Analysis.Wrap_Context
.Changing
Analysis_Context_Type.Ref_Count
type fromNatural
toaliased GNATCOLL.Atomic.Atomic_Counter
, and updatingInc_Ref
andDec_Ref
accordingly fixes the issue.Note: This issue occurs randomly.
184001354-ref_count.patch.gz
The text was updated successfully, but these errors were encountered: