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

Wake core dumps on the string "%" #1419

Open
bmitc opened this issue Sep 18, 2023 · 2 comments
Open

Wake core dumps on the string "%" #1419

bmitc opened this issue Sep 18, 2023 · 2 comments

Comments

@bmitc
Copy link
Contributor

bmitc commented Sep 18, 2023

This was happened upon while trying to get "%" as a verbatim string in Wake. (Note, the best way I found was integerToUnicode 37.) While experimenting with various methods, I happened to try:

$ wake -x '"%"'
<command-line>:1:[9-11]: syntax error; found illegal token '"%"', but handling it like '"%'
<command-line>:1:12: syntax error; found illegal token '', but handling it like '%"'
wake: src/util/rank.cpp:266: uint32_t RankSelect1Map::select1(uint32_t) const: Assertion `rank1 < num1s' failed.
Aborted (core dumped)

and got the core dump.

This is not a critical issue since it's easily worked around by using integerToUnicode, but I wanted to file this just to capture the find.


As a secondary issue, should "%" properly resolve to a string? I think right now, it's getting interpreted as a half-complete multi-line string "%...%". Maybe when that multi-line string syntax is removed in favor of """...""" we can test to make sure "%" can be input as or inside a normal string?

@V-FEXrt
Copy link
Contributor

V-FEXrt commented Oct 4, 2023

Okay, I see what's going on here.

This is a problem that will just go away once we remove legacy multiline strings. The first part "% is being processed as the start to a multiline string and the remaining " without a %" is confusing the parser. The crash only happens when calling -x directly because that handles expressions differently. If you do it inside of a file you get a proper parse error without a crash.

For now I'll leave this open but going to wait for legacy string removal to actually do anything here.

For completeness, here is another way to get the string literal "%"

$ cat do.wake 
package foo

export def x _ = """
    %
    """
$ wake --in foo x
"%"

@bmitc
Copy link
Contributor Author

bmitc commented Oct 4, 2023

For now I'll leave this open but going to wait for legacy string removal to actually do anything here.

That sounds good to me. This is for sure an edge of edge case, especially after your investigation. Thanks for taking a look at this one!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants