Skip to content
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

Obfuscated model from save total can't be opened #10513

Closed
matteodepascali opened this issue Apr 7, 2023 · 4 comments · Fixed by #10522
Closed

Obfuscated model from save total can't be opened #10513

matteodepascali opened this issue Apr 7, 2023 · 4 comments · Fixed by #10522
Assignees
Milestone

Comments

@matteodepascali
Copy link

Description

After exporting a model through the save total feature selecting the "obfuscate output" option, the resulting file can't be loaded. The following error message appears:

"[~/Desktop/testObfuscated/TestObfuscatedTotal.mo:1:6-1:6:writable] Error: Lexer failed to recognize '$n0
Real'
"

Steps to reproduce

In the attached folder you may find the original model, the total obfuscated model and a launch script "test.mos". Running test.mos produces the reported behavior.

Expected behavior

omc should be able to load the model

Additional files

Providing a zip folder with the files.
testObfuscated.zip

Version and OS

  • OpenModelica Version v1.22.0-dev-17-g88d7b964fd (64-bit)
  • Modelica 4.0.0
  • OS: Windows 11 64bit
@casella casella added this to the 1.21.0 milestone Apr 7, 2023
@casella
Copy link
Contributor

casella commented Apr 7, 2023

@perost this looks like a regression. We should check if it also happens in 1.21.0 and fix it there as well.

perost added a commit to perost/OpenModelica that referenced this issue Apr 11, 2023
@perost
Copy link
Member

perost commented Apr 11, 2023

Fixed in #10522, and I will port it to the 1.21.0 maintenance branch as well.

The issue was that we added some features to the obfuscation a while ago so that some parts of the model can be left as is, which means that there's a possibility of getting conflicting names if the model already contains names with the pattern n123.

So to avoid that I changed it to prefix the names with $, which is how we usually deal with compiler-generated names that don't need to be valid Modelica identifiers. Except that in this case they obviously need to be valid if you want to save the model and not just simulate it immediately (in order to obfuscate the generated C-code).

For now I just changed it back to not prefix the names with $, since it's unlikely to actually cause issues with normal models. To solve the issue properly we'd have to go through the whole model and make sure we don't generate identifiers that already exist in the model, but that will require a bit of work.

perost added a commit to perost/OpenModelica that referenced this issue Apr 11, 2023
perost added a commit to perost/OpenModelica that referenced this issue Apr 11, 2023
perost added a commit to perost/OpenModelica that referenced this issue Apr 11, 2023
perost added a commit to perost/OpenModelica that referenced this issue Apr 11, 2023
perost added a commit that referenced this issue Apr 11, 2023
perost added a commit to perost/OpenModelica that referenced this issue Apr 11, 2023
@mahge
Copy link
Contributor

mahge commented Apr 11, 2023

@perost would quoting them cause issues ,i.e., '$n0'?

@perost
Copy link
Member

perost commented Apr 11, 2023

@perost would quoting them cause issues ,i.e., '$n0'?

Probably not, but it also wouldn't really help. We need them to be valid identifiers, and any valid identifiers have the same issue of potentially existing in the model.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants