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

newException terminates msg early from NULL byte, other IO does not #13115

Closed
D-Nice opened this issue Jan 11, 2020 · 4 comments
Closed

newException terminates msg early from NULL byte, other IO does not #13115

D-Nice opened this issue Jan 11, 2020 · 4 comments

Comments

@D-Nice
Copy link
Contributor

D-Nice commented Jan 11, 2020

Error output produced by raise newException is inconsistent with other IO such as echo or stdout.write.

Example

const b_null: char = 0.char
var msg = "This char is `" & $b_null & "` and works fine!"

echo msg

raise newException(Exception, msg)

Current Output

echo msg
# This char is `` and works fine!

raise newException(Exception, msg)
# Error: unhandled exception: This char is `

Expected Output

echo msg
# This char is `` and works fine!

raise newException(Exception, msg)
# Error: unhandled exception: This char is `` and works fine! [Exception]

Additional Information

  • This issue was found via fuzzing some CLI utility, which takes piped input. The error messsage was being cutoff, because the input contained a NULL byte.
    EDIT:
  • Consistency is the main thing I'd ask for, however, if both could output ^@ for NULL char, that may be better assuming it doesn't introduce needless complexity.
$ nim -v
Nim Compiler Version 1.0.4 [Linux: amd64]
Compiled at 2019-11-27
Copyright (c) 2006-2019 by Andreas Rumpf

git hash: c8998c498f5e2a0874846eb31309e1d1630faca6
active boot switches: -d:release

D-Nice added a commit to D-Nice/nbaser that referenced this issue Jan 11, 2020
the fuzzer found that null bytes were cutting off the error msg prematurely. Issue filed regarding this, but in general using the actual representation will help debug any issues rather than unprintable characters. Issue filed regarding the early termination here: nim-lang/Nim#13115
@Araq Araq added the Severe label Jan 12, 2020
ringabout added a commit to ringabout/Nim that referenced this issue Nov 6, 2020
ringabout added a commit to ringabout/Nim that referenced this issue Nov 12, 2020
@Araq Araq closed this as completed in c555525 Nov 27, 2020
@timotheecour timotheecour reopened this Nov 28, 2020
@timotheecour
Copy link
Member

timotheecour commented Nov 28, 2020

reopening since it doesnt' work for cpp
refs #15930

works in js, vm

@ringabout
Copy link
Member

Workaround for cpp backend:

nim cpp -r -d:noCppExceptions app.nim

timotheecour added a commit to timotheecour/Nim that referenced this issue Nov 28, 2020
timotheecour added a commit to timotheecour/Nim that referenced this issue Nov 28, 2020
timotheecour added a commit to timotheecour/Nim that referenced this issue Nov 28, 2020
@timotheecour
Copy link
Member

timotheecour commented Nov 28, 2020

no need for workaround => #16167

timotheecour added a commit to timotheecour/Nim that referenced this issue Dec 1, 2020
timotheecour added a commit to timotheecour/Nim that referenced this issue Dec 2, 2020
timotheecour added a commit to timotheecour/Nim that referenced this issue Dec 3, 2020
timotheecour added a commit to timotheecour/Nim that referenced this issue Dec 3, 2020
timotheecour added a commit to timotheecour/Nim that referenced this issue Dec 3, 2020
timotheecour added a commit to timotheecour/Nim that referenced this issue Dec 4, 2020
timotheecour added a commit to timotheecour/Nim that referenced this issue Dec 4, 2020
Araq pushed a commit that referenced this issue Dec 11, 2020
…enbsd) (#16167)

* fix partially #13115 properly (works for c,js,cpp,vm; still fails for js on openbsd)
* address comment: also test with -d:danger, -d:debug
mildred pushed a commit to mildred/Nim that referenced this issue Jan 11, 2021
mildred pushed a commit to mildred/Nim that referenced this issue Jan 11, 2021
…js on openbsd) (nim-lang#16167)

* fix partially nim-lang#13115 properly (works for c,js,cpp,vm; still fails for js on openbsd)
* address comment: also test with -d:danger, -d:debug
@timotheecour
Copy link
Member

now that #16167 was merged, the only thing remaining is js backend on openbsd; it's due to an upstream nodejs bug that has been patched in more recent nodejs version, ie outside of nim's control; closing for now, feel free to re-open if you disagree

ardek66 pushed a commit to ardek66/Nim that referenced this issue Mar 26, 2021
ardek66 pushed a commit to ardek66/Nim that referenced this issue Mar 26, 2021
…js on openbsd) (nim-lang#16167)

* fix partially nim-lang#13115 properly (works for c,js,cpp,vm; still fails for js on openbsd)
* address comment: also test with -d:danger, -d:debug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants