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

Segmentation fault when using high coordinate values #9

Closed
Shtong opened this issue Sep 1, 2015 · 3 comments
Closed

Segmentation fault when using high coordinate values #9

Shtong opened this issue Sep 1, 2015 · 3 comments

Comments

@Shtong
Copy link

Shtong commented Sep 1, 2015

Hello,

There are seg faults in a lot of cases when specifying high coordinates. For example:

Python 2.7.3 (default, Mar 13 2014, 11:03:55)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import noise
>>> noise.__version__
'1.2.1'
>>> noise.pnoise1(2382.79792381, octaves=5, base=8898)
zsh: segmentation fault  python
@caseman
Copy link
Owner

caseman commented Sep 1, 2015

Interesting. This doesn't crash on macos, but does on Linux. I'll take a look

@caseman
Copy link
Owner

caseman commented Sep 1, 2015

It looks like the (my) code naively presumes that the base is in the range of 0..255, although other values can accidentally work they may read from outside the lookup table. Actually it's worse than that and even values in that range can result in reading garbage. Reading garbage will result in seemingly ok results on some platforms (it is a pseudo-random function after all), but on others with stricter memory access it crashes as you noted.

Anyway it's fixable but the internal api will need an adjustment. For some reason base is currently an integer, which only makes sense if you subscribe to the rather insane presumptions of the present code. It would be better for it to be a float and have it interact with the coordinates before they are mapped to the lookup table.

I'll work on a fix, but for now you can workaround by adding the base value to the input coordinates yourself, and leaving base at zero, which should not crash. The base value concept is a bit dubious anyway, and the implementation doubly so. Some self flagellation is possibly in order as well.

@Shtong
Copy link
Author

Shtong commented Sep 2, 2015

Yeah, actually I started working assuming the base was a float, which is actually what the method signature in the help pages hints at: "base=0.0". Thankfully the error message was relatively explicit :)

I'll manually add the base as you suggest.

@caseman caseman closed this as completed Nov 9, 2018
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