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 calling ws2811_fini #284

Open
natcl opened this issue Mar 30, 2018 · 4 comments
Open

Segmentation fault when calling ws2811_fini #284

natcl opened this issue Mar 30, 2018 · 4 comments

Comments

@natcl
Copy link

natcl commented Mar 30, 2018

There seems to be a segmentation fault when calling ws2811_fini in the nodejs bindings.
Any tips on how to fix that ?

Thanks !

void finalize(const Nan::FunctionCallbackInfo<v8::Value> &info)
{
  ws2811_return_t ret;

  ret = ws2811_wait(&ws281x);
  if (ret != WS2811_SUCCESS)
  {
    Nan::ThrowError(ws2811_get_return_t_str(ret));
    return;
  }

  ws2811_fini(&ws281x);
}
@danielytics
Copy link

I’ve noticed the same thing a few days ago, while using C++ (but not while using the included test program, which is odd because my code was based off it).

@Gadgetoid
Copy link
Collaborator

I think this is related, ws2811_fini was removed from the Python bindings, but it turns out there may be a memory leak remaining: d4c7e35

Looks like the segfault has been swept under the rug somewhat, and we should probably track it down and correct it. I suspect it's due to ws2811_fini attempting to clean up things which haven't been allocated.

rpi_ws281x/ws2811.c

Lines 1061 to 1079 in d50cc44

void ws2811_fini(ws2811_t *ws2811)
{
volatile pcm_t *pcm = ws2811->device->pcm;
ws2811_wait(ws2811);
switch (ws2811->device->driver_mode) {
case PWM:
stop_pwm(ws2811);
break;
case PCM:
while (!(pcm->cs & RPI_PCM_CS_TXE)) ; // Wait till TX FIFO is empty
stop_pcm(ws2811);
break;
}
unmap_registers(ws2811);
ws2811_cleanup(ws2811);
}

@etanx
Copy link

etanx commented Aug 1, 2018

This may be slightly different, but when I run any of the python example scripts I get:

File "build/bdist.linux-armv6l/egg/neopixel.py", line 102, in begin RuntimeError: ws2811_init failed with code -1 Segmentation fault

I could get an older x16 RGB LED ring to work, but now with a x24 RGBW (I used a branch sk6812) it's not initializing.

@davthomaspilot
Copy link

Check out the issue I just posted. Try intializing .chan[0].gamma and chan[1].gamma to zero.

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

5 participants