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

Prevent eagerCache=false from causing undefined behavior #129

Closed
Witiko opened this issue May 27, 2022 · 2 comments · Fixed by #226
Closed

Prevent eagerCache=false from causing undefined behavior #129

Witiko opened this issue May 27, 2022 · 2 comments · Fixed by #226
Assignees
Labels
bug plaintex Related to the plain TeX interface and implementation
Milestone

Comments

@Witiko
Copy link
Owner

Witiko commented May 27, 2022

In a486b88, we documented that disabling the eagerCache Lua option can lead to undefined behavior when markdown fragments are nested. However, this is not always true: disabling the eagerCache Lua option only causes undefined behavior when \markdownMode is set to the legacy values 0 (shell escape via \write18) and 1 (shell escape via os.execute()), not 2 (direct Lua access). Furthermore, we can detect nested markdown fragments and avoid undefined behavior: If we are in a nested context and \markdownMode is 2, then we disable eagerCache and redirect output from \markdownOptionOutputTempFileName to a new type of a temporary output file.

@Witiko Witiko added bug plaintex Related to the plain TeX interface and implementation labels May 27, 2022
@Witiko Witiko added this to the 2.15.2 milestone May 27, 2022
@Witiko Witiko self-assigned this May 27, 2022
@Witiko Witiko modified the milestones: 2.15.2, 2.17.0 May 31, 2022
@Witiko
Copy link
Owner Author

Witiko commented Jun 17, 2022

Perhaps a simpler solution that leverages the semantics of files on unix: Currently, we open outputTempFileName for writing, which truncates the file, affecting all file descriptors open for reading. However, if we first unlinked the file from outputTempFileName and then opened outputTempFileName for writing, a new file would be created and the original should be garbage-collected after the end of the process, making any conflict between the two different files impossible.

@Witiko Witiko modified the milestones: 2.17.0, 2.16.0 Jun 17, 2022
@Witiko Witiko modified the milestones: 2.16.0, 3.0.0 Jun 28, 2022
@Witiko
Copy link
Owner Author

Witiko commented Jun 28, 2022

This issue will be solved when Witiko/lt3luabridge#8 has been closed and after we have removed \markdownMode in #309. Then, we can remove the undefined behavior notice and make eagerCache=false the default behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug plaintex Related to the plain TeX interface and implementation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant