-
Notifications
You must be signed in to change notification settings - Fork 31
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
Compile error with fresh MiKTeX installation #458
Comments
Hello and thank you for the report. I don't have any fix for you at the moment but I will look into reproducing your issue. |
I installed Windows 11 in a VM. In it, I installed MikTeX by running file Then, I updated MikTeX from the MikTeX console: Next, I created a file Note The After running the command, I was prompted to download the following packages:
After downloading the packages, the compilation failed with the error from your original post: Here is the part of the code of the Markdown package on lines 2336–2338 from file Lines 26294 to 26296 in a9804bd
Apparently, we fail to locate the file This appears to be an issue with the KPathSea library in MikTeX. To demonstrate, I created the following LuaTeX script local kpse = require("kpse")
kpse.set_program_name("luatex")
local pathname = kpse.lookup("UnicodeData.txt")
if pathname == nil then
print("Found no files.")
else
print("Found file `" .. pathname .. "`.")
end Then, I ran the command
Finally, I ran the same command on the MikTeX installation. This produced the following output:
This issue extends beyond just the Lua API. I also ran the command
By contrast, the same command produced no output on the MikTeX installation. |
@Yggdrasil128 After my review from #458 (comment), this issue seems unrelated to the Markdown package. In MiKTeX/miktex#1515, I escalated the bug report upstream to see what the MikTeX developers have to say about it. |
Very interesting, thank you for the detailed analysis and for opening the upstream bug report! I'll be watching that issue as well. |
Even without an upstream fix, we should still produce better error messages when KPathSea has failed to locate a file. |
@Yggdrasil128 In the meantime, I downloaded the file |
Of course, I'll give it a try and get back to you tomorrow. |
I have tested it again on a fresh Windows 11 VM, with the same steps as in my initial comment, but with the additional I have attached the log file: document.log I then tested it again on anther VM with twice the assigned memory (16 GB total), but with the same result. Please let me know if I can test additional things for you, I'm happy to help you investigate this problem. |
Thanks! Here are some steps of preliminary analysis that I would take:
If you could try these steps and let me know what the results are, that would be helpful. |
Thanks! The next step would be to make a copy of file In summary, here are the next questions that would be helpful to answer:
|
I copied the Looks like it doesn't crash in the |
How interesting! We initialize most data structures in functions |
This may be quite difficult to debug, since LPEG processes the whole input at once. Unless the issue is with other steps taken by the conversion function, removing different parts of the Markdown grammar from the table |
Thanks for the pointers! However, with your approach, I determined that I only need to disable the |
Interesting. The After we have pinpointed and fixed the issue, I would like to better document the installation and the usage of the Markdown package in MikTeX and add MikTeX (and perhaps Windows) to the continuous integration pipeline, so that we can ensure that such issues don't go unnoticed in the future. This may need some ingenuity, since we don't have many self-hosted runners and the full regression tests are slow on nodes with few CPU cores. Similarly, I would like to better document and test the Markdown package with ConTeXt standalone, as discussed with @andreiborisov in #402. |
I dug a bit deeper into this. I disabled various parsers (by setting them to The crash occurs in the As you can see in the console output, line 4982 got hit, but neither did 4987 nor 4990. Earlier in the code, the |
I confirmed that the issue is with MikTeX under Windows: $ docker run -it -e MIKTEX_UID=`id -u` miktex/miktex:basic miktex@9da1b10ba72b:/miktex/work$ curl https://mirrors.ctan.org/macros/generic/unicode-data/UnicodeData.txt <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>307 Temporary Redirect</title>
</head><body>
<h1>Temporary Redirect</h1>
<p>The document has moved <a href="https://mirrors.nic.cz/tex-archive/macros/generic/unicode-data/UnicodeData.txt">here</a>.</p>
</body></html> miktex@9da1b10ba72b:/miktex/work$ curl https://mirrors.nic.cz/tex-archive/macros/generic/unicode-data/UnicodeData.txt > UnicodeData.txt miktex@9da1b10ba72b:/miktex/work$ cat > example.md <<EOF
_Hello,_ **Markdown**!
EOF miktex@9da1b10ba72b:/miktex/work$ texlua `kpsewhich markdown-cli.lua` example.md \markdownRendererDocumentBegin
\markdownRendererEmphasis{Hello,} \markdownRendererStrongEmphasis{Markdown}!\markdownRendererDocumentEnd I will now look into whether the issue is also present with TeX Live under Windows. |
I failed to reproduce the issue with TeX Live 2024 on the same Windows VM: This indicates that the issue is specific to just MikTeX under Windows and therefore lower-priority than if the issue affected Windows in general. However, the issue is intriguing and we are close to discovering the exact cause thanks to @Yggdrasil128's detailed analysis in #458 (comment). |
More specifically, the issue seems to be with the parsers To see if there is a difference in the table Then, I produced the files by running the command MikTeX on Windowsparsers.punctuation.1.txt TeX Live 2024 on Linuxparsers.punctuation.1.txt After replacing the Windows end-of-line characters
3390a3391,3394
> U+2FFC = parsers.succeed * S(E2) * S(BF) * S(BC)
> U+2FFD = parsers.succeed * S(E2) * S(BF) * S(BD)
> U+2FFE = parsers.succeed * S(E2) * S(BF) * S(BE)
> U+2FFF = parsers.succeed * S(E2) * S(BF) * S(BF)
3477a3482
> U+31EF = parsers.succeed * S(E3) * S(87) * S(AF)
At this point, it seems to me that LuaTeX in MikTeX just has trouble with Now, |
The issue seems to be somewhat more specific, though, since I can't seem to come up with an MWE that would crash LuaTeX: It could also just be the size of the parser. Whereas |
However, it took a second or two time to concatenate 16,000 |
@Yggdrasil128: If you have the time and inclination, I will appreciate help with trying to construct a minimal working example that reproduces the issue. I tried in #458 (comment) and #458 (comment) but so far, I failed to reproduce the issue. |
Sorry for the long radio silence, I'm currently a bit busy, but I will look into it again in the next days. |
I've created a smaller reproducing file that just loads the punctuation parsers from the local lpeg = require("lpeg")
local unicode = require("unicode")
print(debug.getinfo(1).short_src .. ":" .. debug.getinfo(1).currentline)
parsers = {}
parsers.punctuation = {}
parsers.punctuation_size = {}
(function()
local file = assert(io.open("UnicodeData.txt", "r"),
[[Could not open file "UnicodeData.txt"]])
local lineNumber = 0
for line in file:lines() do
lineNumber = lineNumber + 1
--if lineNumber % 2 == 0 then goto continue end
local codepoint, major_category = line:match("^(%x+);[^;]*;(%a)")
if major_category == "P" or major_category == "S" then
local code = unicode.utf8.char(tonumber(codepoint, 16))
if parsers.punctuation[#code] == nil then
parsers.punctuation[#code] = lpeg.P(false)
end
--[-[
local code_parser = lpeg.P(true)
for i = 1, #code do
local byte = code:sub(i, i)
local byte_parser = lpeg.S(byte)
code_parser = code_parser
* byte_parser
end
--]]
-- Does this replacement work?
--local code_parser = lpeg.P(code)
parsers.punctuation[#code] = parsers.punctuation[#code] + code_parser
parsers.punctuation_size[#code] = (parsers.punctuation_size[#code] or 0) + 1
end
::continue::
end
assert(file:close())
end)()
print(debug.getinfo(1).short_src .. ":" .. debug.getinfo(1).currentline)
print("Parser sizes, " .. "1: " .. parsers.punctuation_size[1] .. ", 2: " .. parsers.punctuation_size[2] .. ", 3: " .. parsers.punctuation_size[3] .. ", 4: " .. parsers.punctuation_size[4])
local s = "_Hello,_ **Markdown**!"
local result = lpeg.match(parsers.punctuation[4], s, 1)
print(debug.getinfo(1).short_src .. ":" .. debug.getinfo(1).currentline)
print("result:")
print(result) And it crashes at
But if I uncomment line 16, which causes all even-numbered lines from the
And if I change the 0 to a 1, so that odd-numbered lines are skipped instead, it also works:
This leads me to believe that the issue is not with any particular one of these parsers, but with the sheer number of parsers that are concatenated together. Side note local code_parser = lpeg.P(true)
for i = 1, #code do
local byte = code:sub(i, i)
local byte_parser = lpeg.S(byte)
code_parser = code_parser
* byte_parser
end with just Anyways, I then looked at your PR #482 and noticed that you build the parsers a bit differently there, so this doesn't apply anymore. I copied your changes into the script and ran it again: Finally, I plugged your changes into my copy of So thank you very much, I think this highly intriguing issue is solved with your PR. :) Well, apart from MiKTeX/miktex#1515 that is. |
Thanks for your analysis. I hoped that #482 would also help here besides improving the speed.
Please note that #482 is not yet finished, see the failing CI. For some reason, the parser does not match some punctuation symbols such as "€", likely due to some obscure typo in my depth-first search algorithm.
As also discussed in #482, I would like to remove the dependency on |
Furthermore, this would also make the package easier to use with other distros that may not contain |
I expect to close this ticket in the next month's release after closing ticket #486. |
Important In version 3.7.1 of the Markdown package, to be released by the end of September, there is a new file |
Hello, I've recently ran into a problem that causes markdown to fail with the following error message:
Here are my steps to reproduce:
Create a fresh Windows 11 VM
Install the most recent version of MiKTeX
Create file
document.tex
Run
lualatex --interaction=nonstopmode --shell-escape --synctex=1 document.tex
The above error occurs.
In the resulting PDF, only the "Hello World" part is there, the "Hello Markdown" part is missing.
I have attached the full log file: document.log
Since everything is a fresh install, all packages are up-to-date.
Interestingly, on a different system where I haven't updated my MiKTeX packages in a while,
I still have markdown version
2.23.0-0-g0b22f91
installed, and everything works fine there.Please let me know if I can help you with any additional information.
The text was updated successfully, but these errors were encountered: