You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2023/06/14 22:18:07 UTC

[couchdb-hqueue] branch fix-enif-alloc-size created (now b806f21)

This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a change to branch fix-enif-alloc-size
in repository https://gitbox.apache.org/repos/asf/couchdb-hqueue.git


      at b806f21  Fix alloc size in hqueue

This branch includes the following new commits:

     new b806f21  Fix alloc size in hqueue

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[couchdb-hqueue] 01/01: Fix alloc size in hqueue

Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a commit to branch fix-enif-alloc-size
in repository https://gitbox.apache.org/repos/asf/couchdb-hqueue.git

commit b806f2145d2f733a724bb18fe7ecd731ab38f8cd
Author: Nick Vatamaniuc <va...@gmail.com>
AuthorDate: Wed Jun 14 18:16:16 2023 -0400

    Fix alloc size in hqueue
    
    We have allocate size($item) then cast the result to a pointer of that item.
    
    This was discovered on macos with otp 25
    
    ```
    Process 71176 stopped
    * thread #16, name = '11_scheduler', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
        frame #0: 0x00007ff81b74c363 libsystem_c.dylib`__chk_fail_overflow + 16
    libsystem_c.dylib`:
    ->  0x7ff81b74c363 <+16>: ud2
    libsystem_c.dylib`:
        0x7ff81b74c365 <+0>:  pushq  %rbp
        0x7ff81b74c366 <+1>:  movq   %rsp, %rbp
        0x7ff81b74c369 <+4>:  leaq   0x7966(%rip), %rdi        ; "detected source and destination buffer overlap"
    Target 0: (beam.smp) stopped.
    (lldb) bt
    * thread #16, name = '11_scheduler', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
      * frame #0: 0x00007ff81b74c363 libsystem_c.dylib`__chk_fail_overflow + 16
        frame #1: 0x00007ff81b6dcf43 libsystem_c.dylib`__memset_chk + 18
        frame #2: 0x0000000147d1969b hqueue.so`hqueue_nif_insert [inlined] hqueue_nif_node_alloc at hqueue_nif.c:117:5 [opt]
        frame #3: 0x0000000147d1967a hqueue.so`hqueue_nif_insert(env=0x0000700008cb7d38, argc=3, argv=0x0000700008cb7e40) at hqueue_nif.c:296:18 [opt]
        frame #4: 0x00000001000351f2 beam.smp`beam_jit_call_nif(c_p=0x0000000142e6cad8, I=<unavailable>, reg=0x0000700008cb7e40, fp=(hqueue.so`hqueue_nif_insert at hqueue_nif.c:269), NifMod=<unavailable>)(enif_environment_t*, int, unsigned long*), erl_module_nif*) at beam_jit_common.cpp:563:26 [opt]
        frame #5: 0x000000014363856e
    (lldb)
    ```
---
 c_src/hqueue_nif.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/c_src/hqueue_nif.c b/c_src/hqueue_nif.c
index 7cbc5e2..5c862e8 100644
--- a/c_src/hqueue_nif.c
+++ b/c_src/hqueue_nif.c
@@ -112,7 +112,7 @@ hqueue_nif_node_free_ext(void* node)
 hqnode_nif_t*
 hqueue_nif_node_alloc()
 {
-    hqnode_nif_t* node = (hqnode_nif_t*) enif_alloc(sizeof(hqnode_nif_t*));
+    hqnode_nif_t* node = (hqnode_nif_t*) enif_alloc(sizeof(hqnode_nif_t));
 
     memset(node, 0, sizeof(hqnode_nif_t));