Comments (2)
If run the following on iex
, such a segmentation fault doesn't occur:
iex> LogisticMap.logistic_map_10_pelemay(1..16)
from pelemay.
Hey there! I was looking into this a bit and believe there is not enough space being allocated for the internal vector holding the list.
Valgrind revealed the following:
==30428== 1 errors in context 1 of 35:
==30428== Thread 6 2_scheduler:
==30428== Invalid read of size 8
==30428== at 0x4B3245F0: map_elem1_plus_1_mult_1_mult_elem1_mod_6700413_kernel_i64 (map_elem1_plus_1_mult_1_mult_elem1_mod_6700413_kernel.c:25)
==30428== by 0x4B323DAF: map_elem1_plus_1_mult_1_mult_elem1_mod_6700413_yielding_nif (libnifelixirlogisticmap.c:597)
==30428== by 0x3909A0: execute_nif (erl_nif.c:3117)
==30428== by 0x188CA8: process_main (beam_cold.h:184)
==30428== by 0x1A53EE: sched_thread_func (erl_process.c:8486)
==30428== by 0x4B532C: thr_wrapper (ethread.c:122)
==30428== by 0x49E6608: start_thread (pthread_create.c:477)
==30428== by 0x4B22292: clone (clone.S:95)
==30428== Address 0x49044118 is 8 bytes after a block of size 64 alloc'd
==30428== at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==30428== by 0x3C887D: erts_sys_alloc (sys.c:871)
==30428== by 0x388BB4: erts_alloc_fnf (erl_alloc.h:294)
==30428== by 0x38AD65: enif_alloc (erl_nif.c:529)
==30428== by 0x4B325649: enif_get_int64_vec_from_list (basic.c:80)
==30428== by 0x4B32396E: map_elem1_plus_1_mult_1_mult_elem1_mod_6700413_nif (libnifelixirlogisticmap.c:536)
==30428== by 0x188CA8: process_main (beam_cold.h:184)
==30428== by 0x1A53EE: sched_thread_func (erl_process.c:8486)
==30428== by 0x4B532C: thr_wrapper (ethread.c:122)
==30428== by 0x49E6608: start_thread (pthread_create.c:477)
==30428== by 0x4B22292: clone (clone.S:95)
In basic.c:80
the line is
size_t nn = CACHE_LINE_SIZE;
ErlNifSInt64 *t = (ErlNifSInt64 *)enif_alloc(nn);
Since t
is being used as an array below (&t[i++]
) is the sizeof()
function missing during the allocation?
I was playing around with something like this that seemed to clear the mem leaks.
Where length
is derived from enif_get_list_lengh
since *vec_l
might be NULL.
size_t nn = CACHE_LINE_SIZE;
ErlNifSInt64 *t = (ErlNifSInt64 *)enif_alloc(sizeof(ErlNifSInt64) * length);
I'd like to get your thoughts before moving forward with a PR :)
from pelemay.
Related Issues (20)
- macOS earlier than Mojave (10.14) doesn't support timespec_get() in time.h
- Automatic configuration mechanism for compilation of machine-dependent code
- Separate lib/pelemay/generator/native/builder.ex with automatic configuration into an independent library
- Add well-tested platforms
- Add a description of the process for release
- Evaluate the potential of application of Exile to Pelemay
- Configure tzdata to prevent occurring errors due to Logger on Nerves
- change the name of the master branch into "main"
- Q&A from ElixirConf EU Virtual HOT 1
- Tested Platforms 0.0.13 HOT 10
- Warning occurs when 1.11 HOT 1
- Error when including a decimal
- Error when M1 Mac with Rosetta 2 mode HOT 1
- Error when mix hex.publish HOT 3
- Generate stub Elixir code by macros instead of a module file HOT 1
- Fallback with warning when the NIF cannot be loaded HOT 4
- Deal with enif_consume_timeslice HOT 1
- protocol String.Chars not implemented HOT 1
- Pelemay Logger terminated in case of Elixir 1.13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pelemay.