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

Fix hangs and segfaults when egregiously long symbol is used #8241

Merged
merged 2 commits into from Sep 7, 2014
Merged

Fix hangs and segfaults when egregiously long symbol is used #8241

merged 2 commits into from Sep 7, 2014

Conversation

danluu
Copy link
Contributor

@danluu danluu commented Sep 5, 2014

Julia hangs when I have a program with a symbol of length 2**19. It then segfaults when I ^C. Longer symbols segfault immediately. Oddly, a symbol of length 2**19 causes julia to segfault immediately when I run it under gdb.

This causes an julia to error out instead hanging or segfaulting.

@@ -462,6 +462,10 @@ static jl_sym_t *mk_symbol(const char *str)
size_t len = strlen(str);
size_t nb = (sizeof(jl_sym_t)+len+1+7)&-8;

if (len >= SYM_POOL_SIZE) {
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to use nb > SYM_POOL_SIZE.

@jiahao
Copy link
Member

jiahao commented Sep 5, 2014

Dare I ask why you have symbols of length >=524,288?

@StefanKarpinski
Copy link
Sponsor Member

Jeez, that's a big symbol.

@danluu
Copy link
Contributor Author

danluu commented Sep 5, 2014

Ok. Used nb instead of length.

@jiahao , would you believe any of the following?

  1. They say a picture is worth a thousand words, so I wrote an emacs mode that lets me use PNGs as variable names. Turns out, pictures are often longer than a thousand words.
  2. I translated a java program to julia without renaming any of the variables.
  3. I have a philosophical objection to the style guide's inistence on squishcase + short variable names, so I name my variables by including all words except the ones I mean.
  4. You gotta name your variables something, y'know?

@quinnj
Copy link
Member

quinnj commented Sep 5, 2014

💯

@kmsquire
Copy link
Member

kmsquire commented Sep 5, 2014

That's a very worthy @jiahao response! :-)

@ivarne
Copy link
Sponsor Member

ivarne commented Sep 7, 2014

This looks like a 0.3 backport candidate. Will cherry-pick as soon as it is merged 🍒

JeffBezanson added a commit that referenced this pull request Sep 7, 2014
Fix hangs and segfaults when egregiously long symbol is used
@JeffBezanson JeffBezanson merged commit 85f7587 into JuliaLang:master Sep 7, 2014
@JeffBezanson
Copy link
Sponsor Member

> would work instead of >=, but after that many characters who's really keeping track :)

ivarne pushed a commit that referenced this pull request Sep 8, 2014
@ivarne
Copy link
Sponsor Member

ivarne commented Sep 8, 2014

Backported to release-0.3 in 8c1b105

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

Successfully merging this pull request may close these issues.

None yet

7 participants