Giter Site home page Giter Site logo

clusterlabs / libqb Goto Github PK

View Code? Open in Web Editor NEW
165.0 165.0 98.0 7.46 MB

libqb is a library providing high performance logging, tracing, ipc, and poll.

Home Page: http://clusterlabs.github.io/libqb/

License: GNU Lesser General Public License v2.1

Shell 2.91% Makefile 2.65% C 86.65% M4 7.23% Python 0.27% Roff 0.30%

libqb's People

Contributors

ab-oe avatar asalkeld avatar beekhof avatar chrissie-c avatar davidvossel avatar dpejesh avatar fabbione avatar gao-yan avatar gnu-srs avatar grooverdan avatar growdu avatar grueni avatar inouekazu avatar ip1981 avatar jfriesse avatar jnpkrn avatar jonesmz avatar jsgf avatar kgaillot avatar meyering avatar miz-take avatar orbea avatar r1mikey avatar rubenk avatar t-matsuo avatar vladmalov avatar wferi avatar wladmis avatar wmdlr avatar yunkai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libqb's Issues

TESTS: '}' is missing at the end of write_logs.c

GCC output looks like:

gcc -DHAVE_CONFIG_H -I. -I../include -I../include/qb -I../include -I../include -ansi -D_GNU_SOURCE -DANSI_ONLY -g -O2 -Wall -Wshadow -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wdeclaration-after-statement -Wpointer-arith -Wwrite-strings -Wcast-align -Wbad-function-cast -Wmissing-format-attribute -Wformat=2 -Wformat-security -Wformat-nonliteral -Wno-long-long -Wno-strict-aliasing -MT bench_log-write_logs.o -MD -MP -MF .deps/bench_log-write_logs.Tpo -c -o bench_log-write_logs.o test -f 'write_logs.c' || echo './'write_logs.c
write_logs.c: In function ‘log_dict_words’:
write_logs.c:32860:1: error: expected declaration or statement at end of input

qb_ipcs_unref and qb_loop_run

After fixing #62 in app using libqb there is still problem and this time it doesn't looks fixable this way.

==30888== Invalid read of size 4
==30888==    at 0x526D006: qb_ipcs_dispatch_connection_request (ipcs.c:730)
==30888==    by 0x5269D1E: _poll_dispatch_and_take_back_ (loop_poll.c:98)
==30888==    by 0x5269956: qb_loop_run (loop.c:43)
==30888==    by 0x129218: main (main.c:1309)
==30888==  Address 0xa0519d8 is 1,256 bytes inside a block of size 1,360 free'd
==30888==    at 0x4C297E6: free (vg_replace_malloc.c:446)
==30888==    by 0x526C6F3: qb_ipcs_unref (ipcs.c:217)
==30888==    by 0x12B06C: cs_ipcs_service_destroy (ipc_glue.c:183)
==30888==    by 0x12D535: corosync_service_unlink_and_exit_priority (service.c:236)
==30888==    by 0x12DA30: service_exit_schedwrk_handler (service.c:377)
==30888==    by 0x526AC8A: job_dispatch (loop_job.c:39)
==30888==    by 0x5269956: qb_loop_run (loop.c:43)
==30888==    by 0x129218: main (main.c:1309)

Right before this error, service was unreferenced.

GC for trie

Trie doesn't free nodes automatically, so if many keys with different names are created and then destroyed, memory of nodes is not freed.

It should be nice to provide ether automatic GC of nodes with no reference or manual one.

RB: Call to sem_destroy_fn() without checking ref_count

Call to sem_destroy_fn() inside qb_rb_close() should be permitted iff previous call to qb_atomic_int_dec_and_test() returns 1. Otherwise sem_destroy_fn() destroys the semaphore even if the ringbuffer was opened without QB_RB_FLAG_CREATE flag.
However it seems to be more conceptually correct to test QB_RB_FLAG_CREATE in rb->flags.
Thus qb_rb_close() will look like

void qb_rb_close(qb_ringbuffer_t * rb)
{
    if (rb == NULL) {
        return;
    }
    qb_util_log(LOG_DEBUG,
                 "Destroying ringbuffer: %s",
                 rb->shared_hdr->hdr_path);

    (void)qb_atomic_int_dec_and_test(&rb->shared_hdr->ref_count);
    /*
     * proposed changes
    */
    if (rb->flags & QB_RB_FLAG_CREATE)
        (void)rb->sem_destroy_fn(rb);
    /*
     * end of changes
    */
    unlink(rb->shared_hdr->data_path);
    unlink(rb->shared_hdr->hdr_path);
    munmap(rb->shared_data, (rb->shared_hdr->size * sizeof(uint32_t)) << 1);
    munmap(rb->shared_hdr, sizeof(struct qb_ringbuffer_shared_s));
    free(rb);
}

Compilation fault on OS without sem_timedwait function

Typical example is NetBSD, but I believe same problem appears in OpenBSD and Darwin. Compilation of libqb timerlist_helper file will fail, because this doesn't implement sem_timedwait function.

In corosync 1.x (flatiron) I've solved this issue by not using sem_timedwait on OS without it's support. Even this is not perfect solution, it made corosync somehow works in most situations.

Another option to explore may be to use threads.

'struct qb_poll_source' has no member named 'epollfd'

I may be trying to do the impossible and building from source on centos 5.8

I've got all the autoconf, automake, check, libtool, m4, pkgconfig dependencies current. I can do the following without error and no special options:
./autogen.sh
./configure

Make fails though:
loop_poll_epoll.c: In function '_fini':
loop_poll_epoll.c:73: error: 'struct qb_poll_source' has no member named 'epollfd'
loop_poll_epoll.c:74: error: 'struct qb_poll_source' has no member named 'epollfd'
loop_poll_epoll.c:75: error: 'struct qb_poll_source' has no member named 'epollfd'
loop_poll_epoll.c: In function '_add':
loop_poll_epoll.c:87: error: 'struct qb_poll_source' has no member named 'epollfd'
loop_poll_epoll.c: In function '_mod':
loop_poll_epoll.c:103: error: 'struct qb_poll_source' has no member named 'epollfd'
loop_poll_epoll.c: In function '_del':
loop_poll_epoll.c:115: error: 'struct qb_poll_source' has no member named 'epollfd'
loop_poll_epoll.c: In function 'poll_and_add_to_jobs':
loop_poll_epoll.c:157: error: 'struct qb_poll_source' has no member named 'epollfd'
loop_poll_epoll.c: In function 'qb_epoll_init':
loop_poll_epoll.c:198: error: 'struct qb_poll_source' has no member named 'epollfd'
loop_poll_epoll.c:198: error: 'EPOLL_CLOEXEC' undeclared (first use in this function)
loop_poll_epoll.c:198: error: (Each undeclared identifier is reported only once
loop_poll_epoll.c:198: error: for each function it appears in.)
loop_poll_epoll.c:199: error: 'struct qb_poll_source' has no member named 'epollfd'
make[2]: *** [loop_poll_epoll.lo] Error 1
make[2]: Leaving directory `/root/cluster/libqb-0.13.0/lib'

This is out of my league. Any help would be great.

OS X 10.8.2 compilation issues

Tried building on OS X 10.8.2 (Mountain Lion) with gcc 4.2.1 (from Xcode 4.6, with autoconf and automake installed via MacPorts), but needed to fix a few things in lib/ipc_socket.c to make it build successfully: (freshly cloned from git half-an-hour ago)

line 50: address->sun_len = QB_SUN_LEN(&address);
change to (remove &): address_sun_len = QB_SUN_LEN(address);

global replace (in ipc_socket.c) MSG_NOSIGNAL with SO_NOSIGPIPE

I am no expert with autoconf/automake, so I'm not sure how to patch it so it'd be cross-platform friendly.

LIST: Additional macros for iteration over the list

We propose to include in qblist.h the following macros:

/**

  • Iterate over list of given type safe against removal of list entry
  • @param pos: the type * to use as a loop cursor.
  • @param n: another type * to use as temporary storage
  • @param head: the head for your list.
  • @param member: the name of the list_struct within the struct.
    _/
    #define qb_list_for_each_entry_safe(pos, n, head, member)
    for (pos = qb_list_entry((head)->next, typeof(_pos), member),
    n = qb_list_entry(pos->member.next, typeof(_pos), member);
    &pos->member != (head);
    pos = n, n = qb_list_entry(n->member.next, typeof(_n), member))

/**

  • Iterate backwards over list safe against removal
  • @param pos: the type * to use as a loop cursor.
  • @param n: another type * to use as temporary storage
  • @param head: the head for your list.
  • @param member: the name of the list_struct within the struct.
    _/
    #define qb_list_for_each_entry_safe_reverse(pos, n, head, member)
    for (pos = qb_list_entry((head)->prev, typeof(_pos), member),
    n = qb_list_entry(pos->member.prev, typeof(_pos), member);
    &pos->member != (head);
    pos = n, n = qb_list_entry(n->member.prev, typeof(_n), member))

ipcserver example crashes when trying to run in OSX 10.8.3

Steps to reproduce:

Compiled from git and installed
Run ipcserver example using sudo

syslog shows this error:

Apr 24 10:29:47 node2.myplace.com ipcserver[38514]: [38514] detected buffer overflow
Apr 24 10:29:48 node2.myplace.com ReportCrash[38529]: DebugSymbols was unable to start a spotlight query: spotlight is not responding or disabled.
Apr 24 10:29:50 node2.myplace.com ReportCrash[38529]: failed looking up LS service ( scCreateSystemService returned MACH_PORT_NULL, called from SetupCoreApplicationServicesCommunicationPort, so using client-side NULL calls.
Apr 24 10:29:50 node2.myplace.com ReportCrash[38529]: LaunchServices/5123589: Unable to lookup coreservices session port for session 0x186a0 uid=0 euid=0

crash dump is:

Process: ipcserver [38514]
Path: /usr/local/src/libqb/examples/.libs/ipcserver
Identifier: ipcserver
Version: 0
Code Type: X86-64 (Native)
Parent Process: sudo [38513]
User ID: 0

Date/Time: 2013-04-24 10:29:48.005 -0700
OS Version: Mac OS X 10.8.3 (12D78)
Report Version: 10

Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000

Application Specific Information:
__abort() called

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff8fc4cd46 __kill + 10
1 libsystem_c.dylib 0x00007fff8f1d7ec0 __abort + 193
2 libsystem_c.dylib 0x00007fff8f19977d __chk_fail + 35
3 libsystem_c.dylib 0x00007fff8f199886 __snprintf_chk + 150
4 libqb.0.dylib 0x000000010c580d30 qb_ipcs_us_publish + 576 (ipc_setup.c:386)
5 libqb.0.dylib 0x000000010c57fdb8 qb_ipcs_run + 104 (ipcs.c:122)
6 ipcserver 0x000000010c573bc8 main + 760 (ipcserver.c:379)
7 libdyld.dylib 0x00007fff8d28a7e1 start + 1

Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000000 rbx: 0x00007fff5368c5e0 rcx: 0x00007fff5368c5c8 rdx: 0x0000000000000000
rdi: 0x0000000000009672 rsi: 0x0000000000000006 rbp: 0x00007fff5368c5f0 rsp: 0x00007fff5368c5c8
r8: 0x0000000000000002 r9: 0x00000000d79856d9 r10: 0x00007fff8fc4e342 r11: 0x0000000000000206
r12: 0x0000000000000000 r13: 0x000000010c574bc7 r14: 0x00007fff5368c792 r15: 0x00007ffc39c0f814
rip: 0x00007fff8fc4cd46 rfl: 0x0000000000000206 cr2: 0x00007fff79a70ff0
Logical CPU: 0

Binary Images:
0x10c573000 - 0x10c574ff7 +ipcserver (0) <6FF47981-2906-3D6A-A999-4DEDE2249923> /usr/local/src/libqb/examples/.libs/ipcserver
0x10c578000 - 0x10c591fff +libqb.0.dylib (0) /usr/local/src/libqb/lib/.libs/libqb.0.dylib
0x10c5b8000 - 0x10c6c2fe7 +libglib-2.0.0.dylib (0) <77023DE8-F2A8-32B0-A7E0-028BCA775347> /opt/local/lib/libglib-2.0.0.dylib
0x10c6f2000 - 0x10c6fafff +libintl.8.dylib (0) /opt/local/lib/libintl.8.dylib
0x10c6ff000 - 0x10c7f7ff7 +libiconv.2.dylib (0) <1914316E-52FA-3DC3-9CE7-6D2D71CFD4DB> /opt/local/lib/libiconv.2.dylib
0x7fff6c173000 - 0x7fff6c1a793f dyld (210.2.3) /usr/lib/dyld
0x7fff88bf9000 - 0x7fff88c45ff7 libauto.dylib (185.1) <73CDC482-16E3-3FC7-9BB4-FBA2DA44DBC2> /usr/lib/libauto.dylib
0x7fff88cd8000 - 0x7fff88d27ff7 libFontRegistry.dylib (100) /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/Resources/libFontRegistry.dylib
0x7fff88d76000 - 0x7fff88dcbff7 libTIFF.dylib (849) /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libTIFF.dylib
0x7fff88e23000 - 0x7fff88e7dfff com.apple.print.framework.PrintCore (8.3 - 387.2) <5BA0CBED-4D80-386A-9646-F835C9805B71> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore.framework/Versions/A/PrintCore
0x7fff88ea8000 - 0x7fff88ea8fff libkeymgr.dylib (25) /usr/lib/system/libkeymgr.dylib
0x7fff88fc3000 - 0x7fff88fe3fff libPng.dylib (849) /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libPng.dylib
0x7fff892ef000 - 0x7fff892f8ff7 com.apple.CommerceCore (1.0 - 26.1) <40A129A8-4E5D-3C7A-B299-8CB203C4C65D> /System/Library/PrivateFrameworks/CommerceKit.framework/Versions/A/Frameworks/CommerceCore.framework/Versions/A/CommerceCore
0x7fff8954a000 - 0x7fff8954afff com.apple.vecLib (3.8 - vecLib 3.8) <794317C7-4E38-338A-A874-5E18001C8503> /System/Library/Frameworks/vecLib.framework/Versions/A/vecLib
0x7fff895b3000 - 0x7fff8960aff7 com.apple.ScalableUserInterface (1.0 - 1) <93C14595-6172-37E9-88F2-CBC80A1C54D0> /System/Library/Frameworks/QuartzCore.framework/Versions/A/Frameworks/ScalableUserInterface.framework/Versions/A/ScalableUserInterface
0x7fff8960b000 - 0x7fff8980bfff libicucore.A.dylib (491.11.2) /usr/lib/libicucore.A.dylib
0x7fff8980c000 - 0x7fff8980efff com.apple.securityhi (4.0 - 55002) <8B2008A2-B6A2-3E69-9FA2-77B38C869DD6> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SecurityHI.framework/Versions/A/SecurityHI
0x7fff8980f000 - 0x7fff89831ff7 com.apple.Kerberos (2.0 - 1) <416543F5-E7AF-3269-843F-C8CDA8DD0FFA> /System/Library/Frameworks/Kerberos.framework/Versions/A/Kerberos
0x7fff89832000 - 0x7fff89835fff com.apple.help (1.3.2 - 42) <418A9A41-BCB4-32A2-97ED-3A388F69CA9D> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Help.framework/Versions/A/Help
0x7fff898aa000 - 0x7fff898e7fef libGLImage.dylib (8.7.25) <139A9892-A6F2-3F49-87FB-E7AC3F56E003> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLImage.dylib
0x7fff89958000 - 0x7fff89959fff libsystem_blocks.dylib (59) /usr/lib/system/libsystem_blocks.dylib
0x7fff8995a000 - 0x7fff89960fff com.apple.DiskArbitration (2.5.2 - 2.5.2) /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration
0x7fff8a59a000 - 0x7fff8a5ebff7 com.apple.SystemConfiguration (1.12.2 - 1.12.2) /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration
0x7fff8a5ec000 - 0x7fff8a6a9ff7 com.apple.ColorSync (4.8.0 - 4.8.0) <73BE495D-8985-3B88-A7D0-23DF0CB50304> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ColorSync.framework/Versions/A/ColorSync
0x7fff8a6aa000 - 0x7fff8a7c292f libobjc.A.dylib (532.2) <90D31928-F48D-3E37-874F-220A51FD9E37> /usr/lib/libobjc.A.dylib
0x7fff8a7c3000 - 0x7fff8a7f4ff7 com.apple.DictionaryServices (1.2 - 184.4) <2EC80C71-263E-3D63-B461-6351C876C50D> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/DictionaryServices.framework/Versions/A/DictionaryServices
0x7fff8a7f5000 - 0x7fff8a804fff com.apple.opengl (1.8.7 - 1.8.7) <26F7FF79-6BB2-3968-B70D-71D4E07C9551> /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL
0x7fff8a805000 - 0x7fff8a81cfff libGL.dylib (8.7.25) <15F5CB64-847B-3D3D-9663-E0523F15F513> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib
0x7fff8ab42000 - 0x7fff8ab46fff libCoreVMClient.dylib (32.3) /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libCoreVMClient.dylib
0x7fff8ab4c000 - 0x7fff8ab4dfff liblangid.dylib (116) <864C409D-D56B-383E-9B44-A435A47F2346> /usr/lib/liblangid.dylib
0x7fff8ac40000 - 0x7fff8ad05ff7 com.apple.coreui (2.0 - 181.1) <7C4196D5-79E8-3557-963B-71F494DC9B04> /System/Library/PrivateFrameworks/CoreUI.framework/Versions/A/CoreUI
0x7fff8ad2e000 - 0x7fff8ad42fff com.apple.speech.synthesis.framework (4.1.12 - 4.1.12) <94EDF2AB-809C-3D15-BED5-7AD45B2A7C16> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/SpeechSynthesis.framework/Versions/A/SpeechSynthesis
0x7fff8afd0000 - 0x7fff8b01aff7 libGLU.dylib (8.7.25) /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib
0x7fff8b052000 - 0x7fff8b05fff7 com.apple.NetAuth (4.0 - 4.0) /System/Library/PrivateFrameworks/NetAuth.framework/Versions/A/NetAuth
0x7fff8b068000 - 0x7fff8b09eff7 libsystem_info.dylib (406.17) /usr/lib/system/libsystem_info.dylib
0x7fff8b0f8000 - 0x7fff8b147ff7 libcorecrypto.dylib (106.2) /usr/lib/system/libcorecrypto.dylib
0x7fff8b15f000 - 0x7fff8b261fff libJP2.dylib (849) <4EEA33EB-AF9F-365D-A572-F7D11AD1C76F> /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libJP2.dylib
0x7fff8b262000 - 0x7fff8b263ff7 libdnsinfo.dylib (453.19) <14202FFB-C3CA-3FCC-94B0-14611BF8692D> /usr/lib/system/libdnsinfo.dylib
0x7fff8b2b7000 - 0x7fff8b351fff libvMisc.dylib (380.6) <714336EA-1C0E-3735-B31C-19DFDAAF6221> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvMisc.dylib
0x7fff8b36c000 - 0x7fff8b3d4ff7 libc++.1.dylib (65.1) /usr/lib/libc++.1.dylib
0x7fff8b3d5000 - 0x7fff8b3fcfff com.apple.framework.familycontrols (4.1 - 410) <50F5A52C-8FB6-300A-977D-5CFDE4D5796B> /System/Library/PrivateFrameworks/FamilyControls.framework/Versions/A/FamilyControls
0x7fff8b43e000 - 0x7fff8b44dff7 libxar.1.dylib (105) /usr/lib/libxar.1.dylib
0x7fff8b4c3000 - 0x7fff8b4c9ff7 libunwind.dylib (35.1) <21703D36-2DAB-3D8B-8442-EAAB23C060D3> /usr/lib/system/libunwind.dylib
0x7fff8b4ce000 - 0x7fff8b537fff libstdc++.6.dylib (56) <08A26E98-26A7-3A23-A594-01EF923BA123> /usr/lib/libstdc++.6.dylib
0x7fff8b538000 - 0x7fff8b6adfff com.apple.CFNetwork (596.3.3 - 596.3.3) <3739DC8D-8610-3740-80EC-43E130779CB8> /System/Library/Frameworks/CFNetwork.framework/Versions/A/CFNetwork
0x7fff8b6b3000 - 0x7fff8b721fff com.apple.framework.IOKit (2.0.1 - 755.22.5) <1547DA6F-9793-30A2-8E92-7368DE84D46C> /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
0x7fff8b722000 - 0x7fff8b778fff com.apple.HIServices (1.20 - 417) /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/HIServices
0x7fff8b78e000 - 0x7fff8b79bfff libbz2.1.0.dylib (29) /usr/lib/libbz2.1.0.dylib
0x7fff8b7e3000 - 0x7fff8b83dff7 com.apple.opencl (2.2.18 - 2.2.18) <4A78E53C-17B0-3B2D-A9EA-EF8720FE4134> /System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL
0x7fff8b83e000 - 0x7fff8b843fff libcompiler_rt.dylib (30) <08F8731D-5961-39F1-AD00-4590321D24A9> /usr/lib/system/libcompiler_rt.dylib
0x7fff8b844000 - 0x7fff8b8a1ff7 com.apple.audio.CoreAudio (4.1.1 - 4.1.1) /System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio
0x7fff8b8a2000 - 0x7fff8b8acfff com.apple.speech.recognition.framework (4.1.5 - 4.1.5) <5A4B532E-3428-3F0A-8032-B0AFFF72CA3D> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SpeechRecognition.framework/Versions/A/SpeechRecognition
0x7fff8b8ad000 - 0x7fff8b8b2fff com.apple.OpenDirectory (10.8 - 151.10) <1F47EC96-7403-3690-8D8D-C31D3B6FDA0A> /System/Library/Frameworks/OpenDirectory.framework/Versions/A/OpenDirectory
0x7fff8bbb3000 - 0x7fff8bbb4ff7 libsystem_sandbox.dylib (220.2) <6838A6FD-8626-3356-BB4F-BB4787216207> /usr/lib/system/libsystem_sandbox.dylib
0x7fff8c9e3000 - 0x7fff8cb34fff com.apple.audio.toolbox.AudioToolbox (1.8 - 1.8) /System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox
0x7fff8cb62000 - 0x7fff8cb74ff7 libz.1.dylib (43) <2A1551E8-A272-3DE5-B692-955974FE1416> /usr/lib/libz.1.dylib
0x7fff8cb75000 - 0x7fff8cc02ff7 com.apple.SearchKit (1.4.0 - 1.4.0) <54A8069C-E497-3B07-BEA7-D3BC9DB5B649> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SearchKit.framework/Versions/A/SearchKit
0x7fff8cf0f000 - 0x7fff8d26cff7 com.apple.Foundation (6.8 - 945.16) <89BD68FD-72C8-35C1-94C6-3A07F097C50D> /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
0x7fff8d288000 - 0x7fff8d28bff7 libdyld.dylib (210.2.3) /usr/lib/system/libdyld.dylib
0x7fff8d28c000 - 0x7fff8d412fff libBLAS.dylib (1073.4) /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
0x7fff8d413000 - 0x7fff8d413fff com.apple.Accelerate (1.8 - Accelerate 1.8) <6AD48543-0864-3D40-80CE-01F184F24B45> /System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate
0x7fff8d414000 - 0x7fff8d4c5fff com.apple.LaunchServices (539.7 - 539.7) /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/LaunchServices
0x7fff8d4c6000 - 0x7fff8d4d2fff com.apple.CrashReporterSupport (10.8.3 - 417) <48EDDDF3-5720-39D6-B51F-D9AFB93327B3> /System/Library/PrivateFrameworks/CrashReporterSupport.framework/Versions/A/CrashReporterSupport
0x7fff8d592000 - 0x7fff8d5b3fff com.apple.Ubiquity (1.2 - 243.15) /System/Library/PrivateFrameworks/Ubiquity.framework/Versions/A/Ubiquity
0x7fff8d695000 - 0x7fff8d73bff7 com.apple.CoreServices.OSServices (557.6 - 557.6) <1BDB5456-0CE9-301C-99C1-8EFD0D2BFCCD> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/OSServices
0x7fff8d741000 - 0x7fff8d76cfff libxslt.1.dylib (11.3) <441776B8-9130-3893-956F-39C85FFA644F> /usr/lib/libxslt.1.dylib
0x7fff8d7b7000 - 0x7fff8d8d7fff com.apple.desktopservices (1.7.3 - 1.7.3) <707F77D2-EC0E-3431-840F-B984BD7ABDD6> /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv
0x7fff8d8d8000 - 0x7fff8d8ddfff libcache.dylib (57) <65187C6E-3FBF-3EB8-A1AA-389445E2984D> /usr/lib/system/libcache.dylib
0x7fff8d8de000 - 0x7fff8d8f5fff com.apple.CFOpenDirectory (10.8 - 151.10) /System/Library/Frameworks/OpenDirectory.framework/Versions/A/Frameworks/CFOpenDirectory.framework/Versions/A/CFOpenDirectory
0x7fff8d8f6000 - 0x7fff8d924ff7 libsystem_m.dylib (3022.6) <11B6081D-6212-3EAB-9975-BED6234BD6A5> /usr/lib/system/libsystem_m.dylib
0x7fff8d9f9000 - 0x7fff8da10fff com.apple.GenerationalStorage (1.1 - 132.3) /System/Library/PrivateFrameworks/GenerationalStorage.framework/Versions/A/GenerationalStorage
0x7fff8e23a000 - 0x7fff8e245fff libsystem_notify.dylib (98.5) /usr/lib/system/libsystem_notify.dylib
0x7fff8e28e000 - 0x7fff8e30eff7 com.apple.ApplicationServices.ATS (332 - 341.1) /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/ATS
0x7fff8e30f000 - 0x7fff8e4aafef com.apple.vImage (6.0 - 6.0) /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vImage.framework/Versions/A/vImage
0x7fff8e4ab000 - 0x7fff8e4b2fff libcopyfile.dylib (89) <876573D0-E907-3566-A108-577EAD1B6182> /usr/lib/system/libcopyfile.dylib
0x7fff8e4b3000 - 0x7fff8e4c8ff7 libdispatch.dylib (228.23) /usr/lib/system/libdispatch.dylib
0x7fff8e4c9000 - 0x7fff8e4d1ff7 libsystem_dnssd.dylib (379.37) <616FC901-151E-38BF-B2C4-24A351C5FAAD> /usr/lib/system/libsystem_dnssd.dylib
0x7fff8e9fd000 - 0x7fff8ea12fff com.apple.ImageCapture (8.0 - 8.0) <71B24609-DEE9-3927-9C82-62E72270299C> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/ImageCapture.framework/Versions/A/ImageCapture
0x7fff8ea13000 - 0x7fff8ea17fff libpam.2.dylib (20) /usr/lib/libpam.2.dylib
0x7fff8ea18000 - 0x7fff8ea99fff com.apple.Metadata (10.7.0 - 707.5) <4140B1F6-7D73-33C7-B3F2-4DB349C31AE9> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadata.framework/Versions/A/Metadata
0x7fff8ea9a000 - 0x7fff8eb6cff7 com.apple.CoreText (260.0 - 275.16) <990F3C7D-EEF1-33C4-99D6-8E81C96ED3E3> /System/Library/Frameworks/CoreText.framework/Versions/A/CoreText
0x7fff8ec15000 - 0x7fff8ec1cfff libGFXShared.dylib (8.7.25) <869580B2-39CB-30C3-B76E-73BB4894B6B7> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGFXShared.dylib
0x7fff8ec1d000 - 0x7fff8ec1eff7 libremovefile.dylib (23.2) <6763BC8E-18B8-3AD9-8FFA-B43713A7264F> /usr/lib/system/libremovefile.dylib
0x7fff8ec7d000 - 0x7fff8ec9aff7 com.apple.openscripting (1.3.6 - 148.3) /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/OpenScripting.framework/Versions/A/OpenScripting
0x7fff8ec9b000 - 0x7fff8ecc5ff7 com.apple.CoreVideo (1.8 - 99.4) /System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo
0x7fff8ed16000 - 0x7fff8ed7efff libvDSP.dylib (380.6) /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvDSP.dylib
0x7fff8f007000 - 0x7fff8f066fff com.apple.AE (645.6 - 645.6) <44F403C1-660A-3543-AB9C-3902E02F936F> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/AE
0x7fff8f0a9000 - 0x7fff8f0aafff libDiagnosticMessagesClient.dylib (8) <8548E0DC-0D2F-30B6-B045-FE8A038E76D8> /usr/lib/libDiagnosticMessagesClient.dylib
0x7fff8f0b8000 - 0x7fff8f125ff7 com.apple.datadetectorscore (4.1 - 269.2) <4FD4A7CE-BB00-3AAB-B7AA-AE395D5400EC> /System/Library/PrivateFrameworks/DataDetectorsCore.framework/Versions/A/DataDetectorsCore
0x7fff8f17e000 - 0x7fff8f24aff7 libsystem_c.dylib (825.26) <4C9EB006-FE1F-3F8F-8074-DFD94CF2CE7B> /usr/lib/system/libsystem_c.dylib
0x7fff8f25a000 - 0x7fff8f571ff7 com.apple.CoreServices.CarbonCore (1037.5 - 1037.5) <731D8F92-1C52-3613-BA01-EFEA54DADF41> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/CarbonCore
0x7fff8f612000 - 0x7fff8f616fff com.apple.IOSurface (86.0.4 - 86.0.4) <26F01CD4-B76B-37A3-989D-66E8140542B3> /System/Library/Frameworks/IOSurface.framework/Versions/A/IOSurface
0x7fff8f6d9000 - 0x7fff8f6dbfff com.apple.TrustEvaluationAgent (2.0 - 23) /System/Library/PrivateFrameworks/TrustEvaluationAgent.framework/Versions/A/TrustEvaluationAgent
0x7fff8f6dc000 - 0x7fff8f6e2fff libmacho.dylib (829) /usr/lib/system/libmacho.dylib
0x7fff8f6e8000 - 0x7fff8f7ddfff libiconv.2.dylib (34) /usr/lib/libiconv.2.dylib
0x7fff8f7de000 - 0x7fff8f806fff libJPEG.dylib (849) <5C9052F6-D0B3-39CC-8302-468B43D694D5> /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libJPEG.dylib
0x7fff8f807000 - 0x7fff8f81dfff com.apple.MultitouchSupport.framework (235.29 - 235.29) <617EC8F1-BCE7-3553-86DD-F857866E1257> /System/Library/PrivateFrameworks/MultitouchSupport.framework/Versions/A/MultitouchSupport
0x7fff8f81e000 - 0x7fff8f81efff com.apple.Carbon (154 - 155) <372716D2-6FA1-3611-8501-3DD1D4A6E8C8> /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon
0x7fff8f81f000 - 0x7fff8f92afff libFontParser.dylib (84.6) <96C42E49-79A6-3475-B5E4-6A782599A6DA> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/Resources/libFontParser.dylib
0x7fff8fa64000 - 0x7fff8fa72fff libcommonCrypto.dylib (60027) /usr/lib/system/libcommonCrypto.dylib
0x7fff8fa73000 - 0x7fff8fb8cfff com.apple.ImageIO.framework (3.2.0 - 849) /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
0x7fff8fc3b000 - 0x7fff8fc56ff7 libsystem_kernel.dylib (2050.22.13) <5A961E2A-CFB8-362B-BC43-122704AEB047> /usr/lib/system/libsystem_kernel.dylib
0x7fff8fc57000 - 0x7fff8fc62fff com.apple.CommonAuth (3.0 - 2.0) <7A953C1F-8B18-3E46-9BEA-26D9B5B7745D> /System/Library/PrivateFrameworks/CommonAuth.framework/Versions/A/CommonAuth
0x7fff8fc63000 - 0x7fff8fca6ff7 com.apple.bom (12.0 - 192) <0EFE0F2D-B6DE-3D1E-93C2-EED6D96F70A2> /System/Library/PrivateFrameworks/Bom.framework/Versions/A/Bom
0x7fff8fca9000 - 0x7fff8fcb1fff liblaunch.dylib (442.26.2) <2F71CAF8-6524-329E-AC56-C506658B4C0C> /usr/lib/system/liblaunch.dylib
0x7fff8fcb2000 - 0x7fff900a9fff libLAPACK.dylib (1073.4) /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib
0x7fff900aa000 - 0x7fff900aeff7 com.apple.CommonPanels (1.2.5 - 94) <5F81D593-4B87-3DCC-B934-625D436B4CB1> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/CommonPanels.framework/Versions/A/CommonPanels
0x7fff900af000 - 0x7fff900affff com.apple.Accelerate.vecLib (3.8 - vecLib 3.8) /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/vecLib
0x7fff905e9000 - 0x7fff9088dff7 com.apple.CoreImage (8.2.4 - 1.0.1) <4A6B017F-B9F7-36DA-943D-A95611F147EA> /System/Library/Frameworks/QuartzCore.framework/Versions/A/Frameworks/CoreImage.framework/Versions/A/CoreImage
0x7fff9088e000 - 0x7fff90cabfff FaceCoreLight (2.4.1) /System/Library/PrivateFrameworks/FaceCoreLight.framework/Versions/A/FaceCoreLight
0x7fff90cac000 - 0x7fff90e5afff com.apple.QuartzCore (1.8 - 304.2) <234EABE1-067C-3DAE-BEAC-674526E232C2> /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore
0x7fff90ed6000 - 0x7fff90eddfff com.apple.NetFS (5.0 - 4.0) <195D8EC9-72BB-3E04-A64D-E1A89B4850C1> /System/Library/Frameworks/NetFS.framework/Versions/A/NetFS
0x7fff90ede000 - 0x7fff90fdbfff libsqlite3.dylib (138.1) /usr/lib/libsqlite3.dylib
0x7fff90fdc000 - 0x7fff9105aff7 com.apple.securityfoundation (6.0 - 55115.4) <137E156C-B29C-3B84-95B3-669BC7C1BA7A> /System/Library/Frameworks/SecurityFoundation.framework/Versions/A/SecurityFoundation
0x7fff9105b000 - 0x7fff9105dff7 com.apple.print.framework.Print (8.0 - 258) <8F243E49-021F-3892-B555-3010A7F450A2> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Print.framework/Versions/A/Print
0x7fff912fb000 - 0x7fff91c8b6ff com.apple.CoreGraphics (1.600.0 - 331.0.4) <4953961C-96DC-39D7-ADF5-B767F2A7E4E1> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics
0x7fff91cd4000 - 0x7fff91cf3ff7 com.apple.ChunkingLibrary (2.0 - 133.3) <8BEC9AFB-DCAA-37E8-A5AB-24422B234ECF> /System/Library/PrivateFrameworks/ChunkingLibrary.framework/Versions/A/ChunkingLibrary
0x7fff91ef2000 - 0x7fff91ef3ff7 libSystem.B.dylib (169.3) /usr/lib/libSystem.B.dylib
0x7fff91ef4000 - 0x7fff91ef4fff com.apple.ApplicationServices (45 - 45) <5302CC85-D534-3FE5-9E56-CA16762177F6> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices
0x7fff91ef5000 - 0x7fff91f14ff7 libresolv.9.dylib (51) <0882DC2D-A892-31FF-AD8C-0BB518C48B23> /usr/lib/libresolv.9.dylib
0x7fff91f15000 - 0x7fff91f28ff7 com.apple.LangAnalysis (1.7.0 - 1.7.0) <023D909C-3AFA-3438-88EB-05D0BDA5AFFE> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/LangAnalysis.framework/Versions/A/LangAnalysis
0x7fff924a0000 - 0x7fff924c5ff7 libc++abi.dylib (26) /usr/lib/libc++abi.dylib
0x7fff9258d000 - 0x7fff9259afff com.apple.AppleFSCompression (49 - 1.0) /System/Library/PrivateFrameworks/AppleFSCompression.framework/Versions/A/AppleFSCompression
0x7fff925d6000 - 0x7fff927c0ff7 com.apple.CoreFoundation (6.8 - 744.18) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
0x7fff927c1000 - 0x7fff927c3fff libquarantine.dylib (52) <4BE2E642-A14F-340A-B482-5BD2AEFD9C24> /usr/lib/system/libquarantine.dylib
0x7fff92852000 - 0x7fff928f0ff7 com.apple.ink.framework (10.8.2 - 150) <3D8D16A2-7E01-3EA1-B637-83A36D353308> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Ink.framework/Versions/A/Ink
0x7fff928f1000 - 0x7fff92c21fff com.apple.HIToolbox (2.0 - 626.1) <656D08C2-9068-3532-ABDD-32EC5057CCB2> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox
0x7fff92c22000 - 0x7fff92c61ff7 com.apple.QD (3.42 - 285) <8DF36FCA-C06B-30F4-A631-7BE2FF7E56D1> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/QD.framework/Versions/A/QD
0x7fff92c62000 - 0x7fff92d5fff7 libxml2.2.dylib (22.3) <7FD09F53-83DA-3ECD-8DD9-870E1A2F0427> /usr/lib/libxml2.2.dylib
0x7fff92d72000 - 0x7fff93043ff7 com.apple.security (7.0 - 55179.11) <73958084-5BBC-3597-A751-7370B0C247E5> /System/Library/Frameworks/Security.framework/Versions/A/Security
0x7fff93044000 - 0x7fff93048fff libGIF.dylib (849) <6A664B4D-0A88-33F7-9064-0CD159AB9CE9> /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libGIF.dylib
0x7fff93217000 - 0x7fff93217fff libOpenScriptingUtil.dylib (148.3) /usr/lib/libOpenScriptingUtil.dylib
0x7fff93261000 - 0x7fff93283ff7 libxpc.dylib (140.42) /usr/lib/system/libxpc.dylib
0x7fff93284000 - 0x7fff93306ff7 com.apple.Heimdal (3.0 - 2.0) /System/Library/PrivateFrameworks/Heimdal.framework/Versions/A/Heimdal
0x7fff93307000 - 0x7fff93312ff7 com.apple.bsd.ServiceManagement (2.0 - 2.0) /System/Library/Frameworks/ServiceManagement.framework/Versions/A/ServiceManagement
0x7fff93313000 - 0x7fff93315ff7 libunc.dylib (25) <2FDC94A7-3039-3680-85F3-2164E63B464D> /usr/lib/system/libunc.dylib
0x7fff935c9000 - 0x7fff935cdff7 com.apple.TCC (1.0 - 1) <76A86876-2280-3849-8478-450E1A8C0E01> /System/Library/PrivateFrameworks/TCC.framework/Versions/A/TCC
0x7fff93acc000 - 0x7fff93acefff libCVMSPluginSupport.dylib (8.7.25) /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libCVMSPluginSupport.dylib
0x7fff93acf000 - 0x7fff93addff7 libsystem_network.dylib (77.10) <2AAA67A1-525E-38F0-8028-1D2B64716611> /usr/lib/system/libsystem_network.dylib
0x7fff93ade000 - 0x7fff93affff7 libCRFSuite.dylib (33) /usr/lib/libCRFSuite.dylib
0x7fff93f5d000 - 0x7fff93f70ff7 libbsm.0.dylib (32) /usr/lib/libbsm.0.dylib
0x7fff93f71000 - 0x7fff93fabff7 com.apple.GSS (3.0 - 2.0) <970CAE00-1437-3F4E-B677-0FDB3714C08C> /System/Library/Frameworks/GSS.framework/Versions/A/GSS
0x7fff93fac000 - 0x7fff941e1ff7 com.apple.CoreData (106.1 - 407.7) <24E0A6B4-9ECA-3D12-B26A-72B9DCF09768> /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData
0x7fff9421b000 - 0x7fff94229ff7 libkxld.dylib (2050.22.13) <4AAF0573-8632-3D06-BE32-C5675F77638D> /usr/lib/system/libkxld.dylib
0x7fff94bce000 - 0x7fff94bcefff com.apple.CoreServices (57 - 57) <45F1466A-8264-3BB7-B0EC-E5E5BFBED143> /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices
0x7fff94bda000 - 0x7fff94c1efff libcups.2.dylib (327.3) <71E771A1-0489-3417-8A4A-56A2C930F80C> /usr/lib/libcups.2.dylib
0x7fff94c1f000 - 0x7fff94c22fff libRadiance.dylib (849) /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libRadiance.dylib

External Modification Summary:
Calls made by other processes targeting this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by all processes on this machine:
task_for_pid: 5479262
thread_create: 0
thread_set_state: 0

VM Region Summary:
ReadOnly portion of Libraries: Total=129.9M resident=52.7M(41%) swapped_out_or_unallocated=77.2M(59%)
Writable regions: Total=19.8M written=432K(2%) resident=536K(3%) swapped_out=0K(0%) unallocated=19.3M(97%)

REGION TYPE VIRTUAL
=========== =======
MALLOC 11.5M
MALLOC guard page 48K
STACK GUARD 56.0M
Stack 8192K
VM_ALLOCATE 4K
__DATA 7992K
__LINKEDIT 52.3M
__TEXT 77.6M
__UNICODE 544K
shared memory 12K
=========== =======
TOTAL 213.8M

IPC_SHM: sem_timedwait returns ETIMEDOUT in test test_ipc_server_fail

I compiled this fork of libqb with Oracle Solaris 11U7, gcc 4.5.2 and some packages of csw.
The ipc tests fail when shm is used.

In check_ipc.s in test "ipc_server_fail_shm" the function test_ipc_server_fail is called.
test_ipc_server_fail calls qb_ipcc_sendv_recv from lib/ipcc.c with a value of -1 for ms_timeout.
In the loop below qb_ipcc_recv is called which returns -ETIMEDOUT.
-ETIMEDOUT is the original return code of sem_timedwait.
The logic of the code is (as I understand it):

  • if ms_timeout lower than 0 then change -ETIMEDOUT to -EAGAIN
  • connectionstate ist not called, client keeps connected
  • if -EAGAIN and still connected then try again
    and this is an endless loop.
    I debugged all steps through the program up to the call of sem_timedwait and there are no changes to the errorcode or the connectionstate.

Maybe this is an problem when compiling with gcc 4.5.2 and Oracle Solaris 11.
Other systems may return another value as ETIMEDOUT.

The initialization of the values of timeout_now and timeout_rem in the loop should be before the loop.
It does not change anything in the actual implementation but it looks more logically (IHMO).

In lib/ipcc.c line 284:

    do {
        if (timeout_rem > QB_IPC_MAX_WAIT_MS || ms_timeout == -1) {
            timeout_now = QB_IPC_MAX_WAIT_MS;
        } else {
            timeout_now = timeout_rem;
        }

        res = qb_ipcc_recv(c, res_msg, res_len, timeout_now);
        if (res == -ETIMEDOUT) {
            if (ms_timeout < 0) {
                res = -EAGAIN;
            } else {
                timeout_rem -= timeout_now;
                if (timeout_rem > 0) {
                    res = -EAGAIN;
                }
            }
        } else  if (res < 0 && res != -EAGAIN) {
            errno = -res;
            qb_util_perror(LOG_DEBUG,
            "qb_ipcc_recv %d timeout:(%d/%d)",
            res, timeout_now, timeout_rem);
        }
    } while (res == -EAGAIN && c->is_connected);

My changes are here with debugging an without debugging code

        qb_util_log(LOG_DEBUG, "qb_ipcc_sendv_recv before do QB_IPC_MAX_WAIT_MS=%d timeout_rem=%d timeout_now=%d ms_timeout=%d",
           QB_IPC_MAX_WAIT_MS,timeout_rem,timeout_now,ms_timeout);
        if (timeout_rem > QB_IPC_MAX_WAIT_MS || ms_timeout == -1) {
           timeout_now = QB_IPC_MAX_WAIT_MS;
           timeout_rem = QB_IPC_MAX_WAIT_MS;
        } else {
           timeout_now = timeout_rem;
        }

        do {
            qb_util_log(LOG_DEBUG, "qb_ipcc_sendv_recv in do QB_IPC_MAX_WAIT_MS=%d timeout_rem=%d timeout_now=%d ms_timeout=%d",
               QB_IPC_MAX_WAIT_MS,timeout_rem,timeout_now,ms_timeout);

            res = qb_ipcc_recv(c, res_msg, res_len, timeout_now);
            qb_util_log(LOG_DEBUG, "qb_ipcc_sendv_recv in do res=%d ms_timeout=%d", res,ms_timeout);
            if (res == -ETIMEDOUT) {
            qb_util_log(LOG_DEBUG, "qb_ipcc_sendv_recv in do res=%d timeout_rem=%d timeout_now=%d diff=%d",
               res,timeout_rem,timeout_now,timeout_rem - timeout_now);
                timeout_rem -= timeout_now;
                if (timeout_rem > 0) {
                        res = -EAGAIN;
                } else {
                    _check_connection_state(c, -EIO);
                    res = -ENOTCONN;
                    errno = res;
                }
            } else  if (res < 0 && res != -EAGAIN) {
                errno = -res;
                qb_util_perror(LOG_DEBUG,
                               "qb_ipcc_recv %d timeout:(%d/%d)",
                               res, timeout_now, timeout_rem);
            }
        } while (res == -EAGAIN && c->is_connected);
        if (timeout_rem > QB_IPC_MAX_WAIT_MS || ms_timeout == -1) {
           timeout_now = QB_IPC_MAX_WAIT_MS;
           timeout_rem = QB_IPC_MAX_WAIT_MS;
        } else {
           timeout_now = timeout_rem;
        }

        do {
            res = qb_ipcc_recv(c, res_msg, res_len, timeout_now);
            if (res == -ETIMEDOUT) {
                timeout_rem -= timeout_now;
                if (timeout_rem > 0) {
                        res = -EAGAIN;
                } else {
                    _check_connection_state(c, -EIO);
                    res = -ENOTCONN;
                    errno = res;
                }
            } else  if (res < 0 && res != -EAGAIN) {
                errno = -res;
                qb_util_perror(LOG_DEBUG,
                               "qb_ipcc_recv %d timeout:(%d/%d)",
                               res, timeout_now, timeout_rem);
            }
        } while (res == -EAGAIN && c->is_connected);

qb leaks files in /dev/shm

  1. Exec https://github.com/jfriesse/csts/blob/master/tests/start-cfgstop-one-by-one-with-load.sh (it just starts corosync on 3+ nodes in random order and starts cpg-load)
  2. Wait for test to finish

[root@cts-node1 ~]# ls -1 /dev/shm
qb-cpg-event-10049-10063-18-data
qb-cpg-event-10049-10063-18-header
qb-cpg-event-10105-10126-19-data
qb-cpg-event-10105-10126-19-header
qb-cpg-event-10158-10172-18-data
...

[root@cts-node2 ~]# ls -1 /dev/shm
qb-cpg-event-14584-14598-18-data
qb-cpg-event-14584-14598-18-header
qb-cpg-event-14707-14723-18-data
qb-cpg-event-14707-14723-18-header
qb-cpg-event-14769-14783-18-data
qb-cpg-event-14769-14783-18-header
...

100% reproducible

crash in ptrie notify when running corosync's testsam

==5718== Invalid read of size 4
==5718== at 0x4E706A4: trie_notify (trie.c:565)
==5718== by 0x4E7010C: trie_node_destroy (trie.c:381)
==5718== by 0x4E7029E: trie_node_deref (trie.c:431)
==5718== by 0x4E70BC6: trie_iter_next (trie.c:722)
==5718== by 0x4E6D69A: qb_map_iter_next (map.c:82)
==5718== by 0x419C83: icmap_iter_next (icmap.c:765)
==5718== by 0x40EE2E: message_handler_req_lib_cmap_iter_next (cmap.c:415)
==5718== by 0x41A733: cs_ipcs_msg_process (ipc_glue.c:661)
==5718== by 0x4E6625B: process_request (ipcs.c:596)
==5718== by 0x4E66520: qb_ipcs_dispatch_connection_request (ipcs.c:682)
==5718== by 0x4E625EF: poll_dispatch_and_take_back (loop_poll.c:208)
==5718== by 0x4E61E3C: qb_loop_run_level (loop.c:43)
==5718== Address 0x6edca28 is 24 bytes inside a block of size 40 free'd
==5718== at 0x4A0662E: free (vg_replace_malloc.c:366)
==5718== by 0x4E709B0: trie_notify_del (trie.c:665)
==5718== by 0x4E6D7D3: qb_map_notify_del_2 (map.c:121)
==5718== by 0x419E2F: icmap_track_delete (icmap.c:870)
==5718== by 0x415ED1: wd_key_changed (wd.c:365)
==5718== by 0x418E64: icmap_notify_fn (icmap.c:817)
==5718== by 0x4E7068B: trie_notify (trie.c:560)
==5718== by 0x4E7010C: trie_node_destroy (trie.c:381)
==5718== by 0x4E7029E: trie_node_deref (trie.c:431)
==5718== by 0x4E70BC6: trie_iter_next (trie.c:722)
==5718== by 0x4E6D69A: qb_map_iter_next (map.c:82)
==5718== by 0x419C83: icmap_iter_next (icmap.c:765)
==5718==

We need to refcount the notifier struct..

Occasional crash in corosync client (dlm)

libqb 50f07abcfe7010360f697d1f26b56fec863d892f
corosync e925f421658960d568f168c3623b23414dddcc1c

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff7fea700 (LWP 7026)]
0x00007ffff7bcd7a0 in sem_trywait () from /lib64/libpthread.so.0
Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.25.el6.x86_64
(gdb) bt
#0  0x00007ffff7bcd7a0 in sem_trywait () from /lib64/libpthread.so.0
#1  0x00007ffff6bc3805 in my_posix_sem_timedwait (rb=0x555555a7e060, ms_timeout=0)
    at ringbuffer_helper.c:39
#2  0x00007ffff6bc2ee2 in qb_rb_chunk_read (rb=0x555555a7e060, data_out=0x7fffffefce50,
    len=1048576, timeout=<value optimized out>) at ringbuffer.c:548
#3  0x00007ffff6bc612a in qb_ipcc_event_recv (c=0x555555c9b480, msg_pt=0x7fffffefce50,
    msg_len=1048576, ms_timeout=0) at ipcc.c:321
#4  0x00007ffff77b5966 in cpg_dispatch (handle=1003584061500817409,
    dispatch_types=<value optimized out>) at cpg.c:356
#5  0x000055555555da94 in process_cpg_lockspace (ci=6) at cpg.c:1574
#6  0x0000555555565cf4 in loop () at main.c:978
#7  0x0000555555566b36 in main (argc=1, argv=0x7fffffffe5a8) at main.c:1356

ipc(sc) can deadlock if ipc_type is socket

Simple reproducer:
corosync.conf:
qb {
ipc_type: socket
}

start corosync
start test/cpgverify

corosync + cpgverify will deadlock in qb_ipc_us_sendv function because:

if (errno == EAGAIN &&
(processed > 0 || iov_p > 0)) {
goto retry_send;

but processed is >0. So it just retry forever (or until cpgverify is stopped).

IPC: client can get stuck when server has exited

#0 0x00007fd0309e0740 in sem_wait () from /lib64/libpthread.so.0
#1 0x00007fd02f7f3e90 in my_posix_sem_timedwait (rb=0x7fd0334d87c0, ms_timeout=-1)

at ringbuffer_helper.c:41

#2 0x00007fd02f7f35d7 in qb_rb_chunk_read (rb=0x7fd0334d87c0,

data_out=0x7fffe12d4f40, len=24, timeout=<value optimized out>) at ringbuffer.c:523

#3 0x00007fd02f7f5e72 in qb_ipcc_recv (c=0x7fd0334dbc40,

msg_ptr=<value optimized out>, msg_len=<value optimized out>,
ms_timeout=<value optimized out>) at ipcc.c:199

#4 0x00007fd0305ca499 in coroipcc_msg_send_reply_receive (handle=8408462744751177728)

at cpg.c:100

#5 cpg_finalize (handle=8408462744751177728) at cpg.c:243
#6 0x00007fd031607f77 in close_cpg_daemon () at cpg.c:2662
#7 0x00007fd03160abe1 in loop () at main.c:1004
#8 0x00007fd03160b717 in main (argc=3, argv=0x7fffe12d51d8) at main.c:1300

./configure fails on AIX 7.1

The following block of tests passes on AIX 7.1 when they should fail:

Test print first, because it will be a builtin if present.

if test "X( print -r -- -n ) 2>/dev/null" = X-n &&
test "Xprint -r -- $ECHO 2>/dev/null" = "X$ECHO"; then
ECHO='print -r --'

As AIX does not implement the "--" stdin redirect, "print -r --" is set as the default printing function and subsequent calls to "print --" fail when the parameter is passed via pipe.

LOG: add an easier way to get all enabled targets

From Andrew:

If i want to bump the log level (ie. a new priority for the "*" filter), you need to know which logging types are currently enabled

let t="everything currently enabled" for qb_log_filter_ctl()

or we could have a foreach_enabled_target() iterator.

trie_destroy can cause segfault

I'm not able to write pure libqb reproducer, but corosync (on exit) from time time time can end with:
thread apply all bt

Thread 2 (Thread 0x7f674f9d7700 (LWP 6159)):
#0  0x00007f67525eb620 in sem_wait () from /lib64/libpthread.so.0
#1  0x00007f6752c1fae3 in qb_logt_worker_thread (data=<optimized out>) at log_thread.c:71
#2  0x00007f67525e5d14 in start_thread () from /lib64/libpthread.so.0
#3  0x00007f675231868d in clone () from /lib64/libc.so.6

Thread 1 (Thread 0x7f67509d8740 (LWP 6158)):
#0  0x00007f67522a2acb in _int_free () from /lib64/libc.so.6
#1  0x00007f6752c23410 in trie_node_release (t=t@entry=0x7f6754edacc0, node=node@entry=0x7f6754f4fe30) at trie.c:374
#2  0x00007f6752c23c5a in trie_node_destroy (t=t@entry=0x7f6754edacc0, n=n@entry=0x7f6754f4fe30) at trie.c:394
#3  0x00007f6752c2405e in trie_destroy (map=0x7f6754edacc0) at trie.c:452
#4  0x00007f67534dec85 in icmap_fini () at icmap.c:235
#5  0x00007f6752c191fb in job_dispatch (item=0x7f6754f44620, p=<optimized out>) at loop_job.c:39
#6  0x00007f6752c17ec7 in qb_loop_run_level (level=0x7f6754ede130) at loop.c:43
#7  qb_loop_run (lp=<optimized out>) at loop.c:204
#8  0x00007f67534c9f45 in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at main.c:1259

Reproducer is
https://github.com/jfriesse/csts/blob/master/tests/start-stop-with-load.sh

Usually reproducible with 50% chance.

ringbuffer.c doesn't pay close enough attention to write ordering

qb_rb_chunk_write performs the following writes to shared memory:

  • allocate some ringbuffer and set the magic to CHUNK_MAGIC_ALLOC
  • copy data into the ringbuffer
  • commit the chunk:
    • write the data size
    • update the magic to CHUNK_MAGiC
    • post

However, there's no explicit ordering of these writes, so on systems with loose write ordering rules the reader may see them in any order. In particular, they may see the magic updated to CHUNK_MAGIC and the size set before all the copied data is visible, and end up reading a corrupted message.

Conversely, qb_rb_chunk_read/peek assumes that if CHUNK_MAGIC is correct, then the size is also correct, but write reordering makes this invalid.

I think the write sequence needs to be:

  • alloc chunk
  • copy data
  • commit
    • write barrier
    • update size
    • write barrier
    • update magic
    • write barrier
    • post

I'm not convinced the current code is correct on x86 systems, but it looks very suspect for CPUs with weaker memory ordering rules such as Mips.

I'm seeing problems with corosync going into infinite spins while reading from clients, while clients are failing to write to corosync but the ringbuffer is full. I haven't confirmed that this issue is a root cause of that bug, but its suggestive.

man8 directory is not contained in 'make dist-gzip' target.

I am trying to build package for ubuntu 12.10 from the latest git version.

I can build the source code/documentation from the git repository, but if I try to build from a generated tar.gz (make dist-gzip) the package building fails as the docs/man8 directory is missing.

copying the docs/man8 manually allows the package to build.

qb_ipcs_destroy frees qb_ipcs_service_t but connections can depend on it

Patch for examples/ipcserver.c:

diff --git a/examples/ipcserver.c b/examples/ipcserver.c
index 2fbdae5..be2e676 100644
--- a/examples/ipcserver.c
+++ b/examples/ipcserver.c
@@ -53,20 +53,47 @@ s1_connection_accept_fn(qb_ipcs_connection_t * c, uid_t uid, gid_t gid)
 #endif
 }

+static void outq_flush (void *data) {
+    struct cs_ipcs_conn_context *cnx;
+    cnx = qb_ipcs_context_get(data);
+    static int i = 0;
+
+    fprintf(stderr,"iter %u\n", i);
+    i++;
+    if (i  == 20) {
+       qb_ipcs_destroy(s1);
+    }
+    if (i == 21) {
+           qb_ipcs_event_send(data, "test", 4);
+    }
+    assert(memcmp(cnx, "test", 4) == 0);
+    qb_loop_job_add(bms_loop, QB_LOOP_HIGH, data, outq_flush);
+}
+
 static void
 s1_connection_created_fn(qb_ipcs_connection_t * c)
 {
        struct qb_ipcs_stats srv_stats;
+       struct cs_ipcs_conn_context *context;

+       qb_ipcs_connection_ref(c);
+       qb_loop_job_add(bms_loop, QB_LOOP_HIGH, c, outq_flush);
        qb_ipcs_stats_get(s1, &srv_stats, QB_FALSE);
        qb_log(LOG_INFO, "Connection created (active:%d, closed:%d)",
               srv_stats.active_connections, srv_stats.closed_connections);
+       context = calloc(1, 20);
+       memcpy(context, "test", 4);
+       qb_ipcs_context_set(c, context);
 }

 static void
 s1_connection_destroyed_fn(qb_ipcs_connection_t * c)
 {
        qb_log(LOG_INFO, "Connection about to be freed");
+
+    struct cs_ipcs_conn_context *cnx;
+    cnx = qb_ipcs_context_get(c);
+    free(cnx);
 }

 static int32_t
@@ -89,6 +116,7 @@ s1_connection_closed_fn(qb_ipcs_connection_t * c)
        qb_log(LOG_DEBUG, " Recv retries %"PRIu64"", stats.recv_retries);
        qb_log(LOG_DEBUG, " FC state     %d", stats.flow_control_state);
        qb_log(LOG_DEBUG, " FC count     %"PRIu64"", stats.flow_control_count);
+
        return 0;
 }

@@ -274,6 +302,7 @@ my_dispatch_del(int32_t fd)
        return qb_loop_poll_del(bms_loop, fd);
 }

+
 int32_t
 main(int32_t argc, char *argv[])
 {

valgrind result:

==29639== Invalid read of size 8
==29639==    at 0x4E3E2E4: qb_ipcs_event_send (ipcs.c:374)
==29639==    by 0x40131D: outq_flush (ipcserver.c:67)
==29639==    by 0x4E3B9B3: job_dispatch (loop_job.c:39)
==29639==    by 0x4E39BB9: qb_loop_run_level (loop.c:43)
==29639==    by 0x4E3A193: qb_loop_run (loop.c:204)
==29639==    by 0x401BA7: main (ipcserver.c:378)
==29639==  Address 0x5a541d8 is 392 bytes inside a block of size 472 free'd
==29639==    at 0x4C2695D: free (vg_replace_malloc.c:366)
==29639==    by 0x4E3DDD5: qb_ipcs_unref (ipcs.c:220)
==29639==    by 0x4E3DDEF: qb_ipcs_destroy (ipcs.c:227)
==29639==    by 0x4012FC: outq_flush (ipcserver.c:64)
==29639==    by 0x4E3B9B3: job_dispatch (loop_job.c:39)
==29639==    by 0x4E39BB9: qb_loop_run_level (loop.c:43)
==29639==    by 0x4E3A193: qb_loop_run (loop.c:204)
==29639==    by 0x401BA7: main (ipcserver.c:378)

It is possible to somehow handle this problem in code using libqb, but from user of libqb everything is more or less correct (connection was not destroyed so why not to send events?).

LOG: Possible data race during read/write of log_format

Angus,
according to helgrind, I believe similar problem exists also in libqb:

==20186== Possible data race during write of size 8 at 0x5487cf0 by
thread #1
==20186==    at 0x5275BF4: qb_log_format_set (log.c:1020)
==20186==    by 0x11A52A: logsys_format_set (logsys.c:623)
==20186==    by 0x12E298: main_logging_notify (logconfig.c:541)
==20186==    by 0x12A282: icmap_notify_fn (icmap.c:864)
==20186==    by 0x527BE10: trie_notify (trie.c:586)
==20186==    by 0x527BC57: trie_put (trie.c:520)
==20186==    by 0x5278BA7: qb_map_put (map.c:29)
==20186==    by 0x12965F: icmap_set (icmap.c:425)
==20186==    by 0x11C890: message_handler_req_lib_cmap_set (cmap.c:436)
==20186==    by 0x12BD03: cs_ipcs_msg_process (ipc_glue.c:639)
==20186==    by 0x527018F: _process_request_ (ipcs.c:647)
==20186==    by 0x52705A9: qb_ipcs_dispatch_connection_request (ipcs.c:755)
==20186==  This conflicts with a previous read of size 8 by thread #2
==20186==    at 0x5277A43: qb_log_target_format (log_format.c:279)
==20186==    by 0x5276E4F: _syslog_logger (log_syslog.c:47)
==20186==    by 0x5274016: qb_log_thread_log_write (log.c:232)
==20186==    by 0x5275E49: qb_logt_worker_thread (log_thread.c:105)
==20186==    by 0x4C2D01D: mythread_wrapper (hg_intercepts.c:221)
==20186==    by 0x54CE850: start_thread (in /lib64/libpthread-2.12.so)
==20186==    by 0x90B56FF: ???

Honza

make check fails with (noepoll and no sem_timedwait)

This is odd. with no epoll or no sem_timedwait (separately) it passes but together the ipc test fails.

./configure ac_cv_func_epoll_create1=no ac_cv_func_epoll_create=no ac_cv_func_sem_timedwait=no
make check

qb-blackbox should check basic validity of input file

When blackbox file is corrupted, qb-blackbox app can segfault. Use https://github.com/jfriesse/csts/blob/master/tests/fplay-segfault.sh as a test. Typical results:

trace   Mar 29 09:11:05 messages_deliver_to_app(3824):12: Delivering 15cf0 to 15cf1
trace   Mar 29 09:11:05 messages_deliver_to_app(3893):12: Delivering MCAST message with seq 15cf1 to pending delivery queue
[error] trying to recv chunk of size 1024 but -1291845547 available
==2724== Jump to the invalid address stated on the next line
==2724==    at 0x0: ???
==2724==    by 0x4E45C4A: qb_log_blackbox_print_from_file (log_blackbox.c:204)
==2724==    by 0x4007C3: main (qb_blackbox.c:31)
==2724==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
race   Mar 29 09:11:53 totemsrp_mcast(2334):12: mcasted message added to pending queue
trace   Mar 29 09:11:53 totemsrp_mcast(2334):12: mcasted message added to pending queue
trace   Mar 29 09:11:53 totemsrp_mcast(2334):12: mcasted message added to pending queue
==2863== Invalid read of size 2
==2863==    at 0x4C2910C: memcpy (mc_replace_strmem.c:628)
==2863==    by 0x4E45D10: qb_log_blackbox_print_from_file (log_blackbox.c:228)
==2863==    by 0x4007C3: main (qb_blackbox.c:31)
==2863==  Address 0x5a63822 is not stack'd, malloc'd or (recently) free'd
==2863==
==2863== Invalid read of size 2
==2863==    at 0x4C2910C: memcpy (mc_replace_strmem.c:628)
==2863==    by 0x4E45D98: qb_log_blackbox_print_from_file (log_blackbox.c:240)
==2863==    by 0x4007C3: main (qb_blackbox.c:31)
==2863==  Address 0x5a63826 is not stack'd, malloc'd or (recently) free'd
==2863==
==2863== Invalid read of size 1
==2863==    at 0x4C287D2: strlen (mc_replace_strmem.c:282)
==2863==    by 0x4E47CA3: qb_vsnprintf_deserialize (log_format.c:662)
==2863==    by 0x4E45DB5: qb_log_blackbox_print_from_file (log_blackbox.c:244)
==2863==    by 0x4007C3: main (qb_blackbox.c:31)
==2863==  Address 0x5a63828 is not stack'd, malloc'd or (recently) free'd
==2863==
==2863== Invalid read of size 1
==2863==    at 0x5749F20: strchrnul (in /lib64/libc-2.12.so)
==2863==    by 0x4E47CF1: qb_vsnprintf_deserialize (log_format.c:672)
==2863==    by 0x4E45DB5: qb_log_blackbox_print_from_file (log_blackbox.c:244)
==2863==    by 0x4007C3: main (qb_blackbox.c:31)
==2863==  Address 0x5a63828 is not stack'd, malloc'd or (recently) free'd
==2863==
==2863== Invalid read of size 1
==2863==    at 0x4E47CFA: qb_vsnprintf_deserialize (log_format.c:673)
==2863==    by 0x4E45DB5: qb_log_blackbox_print_from_file (log_blackbox.c:244)
==2863==    by 0x4007C3: main (qb_blackbox.c:31)
==2863==  Address 0x5a63828 is not stack'd, malloc'd or (recently) free'd
==2863==
==2863== Invalid read of size 1
==2863==    at 0x4C287D2: strlen (mc_replace_strmem.c:282)
==2863==    by 0x4E4CCEB: strlcat (strlcat.c:36)
==2863==    by 0x4E47482: my_strlcat (log_format.c:453)
==2863==    by 0x4E47D1D: qb_vsnprintf_deserialize (log_format.c:674)
==2863==    by 0x4E45DB5: qb_log_blackbox_print_from_file (log_blackbox.c:244)
==2863==    by 0x4007C3: main (qb_blackbox.c:31)
==2863==  Address 0x5a63828 is not stack'd, malloc'd or (recently) free'd
==2863==
==2863== Invalid read of size 1
==2863==    at 0x4C287D2: strlen (mc_replace_strmem.c:282)
==2863==    by 0x4E4CC67: strlcpy (strlcpy.c:33)
==2863==    by 0x4E4CD2A: strlcat (strlcat.c:39)
==2863==    by 0x4E47482: my_strlcat (log_format.c:453)
==2863==    by 0x4E47D1D: qb_vsnprintf_deserialize (log_format.c:674)
==2863==    by 0x4E45DB5: qb_log_blackbox_print_from_file (log_blackbox.c:244)
==2863==    by 0x4007C3: main (qb_blackbox.c:31)
==2863==  Address 0x5a63828 is not stack'd, malloc'd or (recently) free'd
==2863==
==2863== Invalid read of size 1
==2863==    at 0x4E45DE2: qb_log_blackbox_print_from_file (log_blackbox.c:247)
==2863==    by 0x4007C3: main (qb_blackbox.c:31)
==2863==  Address 0x8feffffcf is not stack'd, malloc'd or (recently) free'd
trace   Mar 29 09:12:58 messages_deliver_to_app(3893):12: Delivering MCAST message with seq 1462b to pending delivery queue
trace   Mar 29 09:12:58 messages_free(2463):12: releasing messages up to and including 1462b
trace   Mar 29 09:12:58 message_handler_req_lib_cpg_mcast(1816):7: got mcast request on 0x7f3d0c26e820
==3151== Invalid read of size 2
==3151==    at 0x4C2910C: memcpy (mc_replace_strmem.c:628)
==3151==    by 0x4E45D10: qb_log_blackbox_print_from_file (log_blackbox.c:228)
==3151==    by 0x4007C3: main (qb_blackbox.c:31)
==3151==  Address 0x2fa5b222 is not stack'd, malloc'd or (recently) free'd

segment fault occured when use array API

This bug occurs when you call qb_array_free after qb_array_create.(max_elements is 65536)
calloc function is called 255(MAX_BINS) times. however, free function is called 256(num_bins) times.
I do not fully understand the specifications, so I can not fix this...

Trie + iteration + del doesn't work as expected

Source code doesn't work as expected (last assert fails). If 4 lines are cut (so iter create is removed) it works.

#include <assert.h>
#include <qb/qbdefs.h>
#include <qb/qbmap.h>
#include <string.h>
#include <stdio.h>

int
main(void)
{
        qb_map_t *map;
        qb_map_iter_t *iter;
        const char *res;
        char *item;

        assert((map = qb_trie_create()) != NULL);
        qb_map_put(map, strdup("testobj.testkey"), strdup("one"));
        qb_map_put(map, strdup("testobj.testkey2"), strdup("two"));

/* --- CUT NEXT 4 LINES AND PREBLEM IS GONE --- */
        assert((iter = qb_map_pref_iter_create(map, "testobj.")) != NULL);
        res = qb_map_iter_next(iter, (void **)&item);
        fprintf(stderr, "%s = %s\n", res, item);
        qb_map_iter_free(iter);

        assert((item = qb_map_get(map, "testobj.testkey")) != NULL);

        assert(qb_map_rm(map, "testobj.testkey") == QB_TRUE);
        assert((item = qb_map_get(map, "testobj.testkey")) == NULL);

        return (0);
}

LIST: The incorrect use of 'typeof'

The use of the keyword 'typeof' in qblist.h makes it impossible to include lists in our sources for C99 (when -std=c99 is explicitly specified). GCC recomends to use 'typeof' instead of 'typeof'.
We propose to fix the bug.

Add qb_map_notify_del_by_userdata() or simerlar

From source code it looks like there is no way to delete a
concrete tracker, if there are more than one with same
function + prefix/key_name + events.

So let me give you example:

libqb_events = QB_MAP_NOTIFY_INSERTED;

qb_map_notify_add(icmap_map, key_name, fn, libqb_events, 1);
qb_map_notify_add(icmap_map, key_name, fn, libqb_events, 2);
qb_map_notify_add(icmap_map, key_name, fn, libqb_events, 3);

Now let's say, I want to remove notifier with user_data 2, it's not
possible, because trie_notify_del will delete first/last (depending on
QB_MAP_NOTIFY_RECURSIVE).

Do you think it's possible to implement functionality, which will return
id/pointer (just something) which can be used for deleting of concrete
event trigger? (I can also imagine to use user_data as this id).

resources.test is failed on RHEL6

Hi
I caught an error on RHEL6(x86_64) when making rpm.

# ./make rpm
(snip)
PASS: array.test
PASS: map.test
PASS: rb.test
PASS: log.test
PASS: loop.test
PASS: ipc.test
FAIL: resources.test
===================================================
1 of 7 tests failed
See tests/test-suite.log
Please report to [email protected]
===================================================

test-suite.log

========================================
   libqb 0.14.0: tests/test-suite.log
========================================

1 of 7 tests failed.

.. contents:: :depth: 2


FAIL: resources.test (exit: 1)
==============================

/dev/shm/qb-test_ipc_disconnect_after_created_us-control-8623-8
/dev/shm/qb-test_ipc_disp_us-control-8617-8

Error: shared memory segments not closed/unlinked

qb_log_from_external_source incorrectly caches log level

for(level = LOG_ERR; level < LOG_DEBUG; level++) {
    qb_log_from_external_source( __func__, __FILE__,  "I'm logging this at level %d", level, __LINE__, 0, level);
}

results in:

error: main: I'm logging this at level 3
error: main: I'm logging this at level 4
error: main: I'm logging this at level 5
error: main: I'm logging this at level 6

Looping the other way (level = LOG_TRACE) would result in nothing being printed unless tracing was enabled.

segfault in timerlist_del

Program terminated with signal 11, Segmentation fault.
#0 0x00007f2648ed924d in timerlist_del (timerlist=0x13f4038, _timer_handle=0x0) at loop_timerlist.c:131
131 memset(timer->handle_addr, 0, sizeof(struct timerlist_timer *));

Thread 1 (Thread 0x7f2649774740 (LWP 813)):
#0 0x00007f2648ed924d in timerlist_del (timerlist=0x13f4038, timer_handle=0x0) at loop_timerlist.c:131
timer = 0x0
#1 0x00007f2648ed9ae8 in qb_loop_timer_del (lp=0x13f3f40, th=8313862168751636481) at loop_timerlist.c:446
s = 0x13f4020
t = 0x13f48f0
res = 0
l = 0x13f3f40
func = "qb_loop_timer_del"
#2 0x00007f264934a712 in reset_token_retransmit_timeout (instance=0x7f2645a90010) at totemsrp.c:1402
No locals.
#3 0x00007f264935028e in message_handler_orf_token (instance=0x7f2645a90010, msg=0x144f390, msg_len=70, endian_conversion_needed=0) at totemsrp.c:3699
token_storage = "\000\000"\377\300\250z\356\272\254#\000%:\004\000\272\254#\000\000\000\000\000\300\250zd\002\000\300\250zd", '\000' <repeats 12 times>"\344, ", '\000' <repeats 27 times>"\344, \000\000\000\000\000\000\000\344", '\000' <repeats 19 times>, "\017\016\001\000T\005\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377\000\001\002\003\004\005\006\a\b\t\n\v\f\r\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037 !"#$%&'()*+,-./0123456789:;<=>?@abcdefghijklmnopqrstuvwxyz[]^
`abcdefghijklmnopqrstuvwxyz{|}~\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377\000\001\002\003\004\005\006"...

    token_storage = "\000\000\"\377\300\250z\356\272\254#\000%:\004\000\272\254#\000\000\000\000\000\300\250zd\002\000\300\250zd", '\000' <repeats 12 times>"\344, ", '\000' <repeats 27 times>"\344, \000\000\000\000\000\000\000\344", '\000' <repeats 19 times>, "\017\016\001\000T\005\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377\000\001\002\003\004\005\006\a\b\t\n\v\f\r\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037 !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377\000\001\002\003\004\005\006"...
    token_convert = "\360\067-S\377\177", '\000' <repeats 90 times>, "0\002\032\000l\000\002\000h\000\001", '\000' <repeats 13 times>, "\001\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000\001", '\000' <repeats 71 times>"\300, \001\n\000\b\000\001\000\020\000\000\200\024\000\005\000\377\377\000\000\207\001\000\000\367G\000\000\350\003\000\000x\000\002\000\000\000\000\000@\000\000\000\334\005\000\000\001\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000\003\000\000\000\240\017\000\000\350\003\000\000\000\000\000\000\200:\t\000\200Q\001\000\003\000\000\000X\002\000\000\020\000\000\000\000\000\000\000\001\000\000\000\001\000\000\000\001\000\000\000`\352", '\000' <repeats 26 times>, "\001\000\000\000\000\000\000\000\374\000\003\000\037\000\000\000\000\000\000\000\b", '\000' <repeats 63 times>...
    token = 0x7fff532d37f0
    forward_token = 1
    transmits_allowed = 17
    mcasted_retransmit = 0
    mcasted_regular = 0
    last_aru = 2337978
    __FUNCTION__ = "message_handler_orf_token"

#4 0x00007f26493529c8 in main_deliver_fn (context=0x7f2645a90010, msg=0x144f390, msg_len=70) at totemsrp.c:4452
instance = 0x7f2645a90010
message_header = 0x144f390
FUNCTION = "main_deliver_fn"
#5 0x00007f2649344d75 in none_token_recv (rrp_instance=0x144dfa0, iface_no=0, context=0x7f2645a90010, msg=0x144f390, msg_len=70, token_seq=277028) at totemrrp.c:694
No locals.
#6 0x00007f264934710e in rrp_deliver_fn (context=0x144e4d0, msg=0x144f390, msg_len=70) at totemrrp.c:1781
token_seqid = 277028
token_is = 1
deliver_fn_context = 0x144e4d0
rrp_instance = 0x144dfa0
hdr = 0x144f390
tmp_msg = {type = 0 '\000', encapsulated = 0 '\000', endian_detector = 0, ring_number = 0, nodeid_activator = 0}
activate_msg = {type = 0 '\000', encapsulated = 0 '\000', endian_detector = 0, ring_number = 0, nodeid_activator = 0}
FUNCTION = "rrp_deliver_fn"

#7 0x00007f264933f1ae in net_deliver_fn (fd=10, revents=1, data=0x144ed00) at totemudp.c:1174
instance = 0x144ed00
msg_recv = {msg_name = 0x7fff532d3f50, msg_namelen = 16, msg_iov = 0x14541b0, msg_iovlen = 1, msg_control = 0x0, msg_controllen = 0, msg_flags = 0}
iovec = 0x14541b0
system_from = {ss_family = 2, ss_align = 0, __ss_padding = "D\225\355H&\177\000\000@\241?\001\000\000\000\000\220I?\001\000\000\000\000P[G\001\002\000\000\000\320?-S\377\177\000\000\232q\355H&\177\000\000\260?-S\377\177\000\000\200@-S\377\177\000\000\002\000\000\000Q\334\260t\320\230?\001\000\000\000\000\320?-S\377\177\000\000\000\242?\001\000\000\000\000\t\000\000\000\002\000\000\000Q\334\260t\000\000\000"}
bytes_received = 70
res = 0
msg_offset = 0x144f390 ""
size_delv = 70
message_type = 0x144f390 ""
__FUNCTION
= "net_deliver_fn"
#8 0x00007f2648ed729a in poll_dispatch_and_take_back (item=0x13fa200, p=QB_LOOP_MED) at loop_poll.c:196
pe = 0x13fa200
res = 0
PRETTY_FUNCTION = "poll_dispatch_and_take_back"
func = "poll_dispatch_and_take_back"
#9 0x00007f2648ed6985 in qb_loop_run_level (level=0x13f3f78) at loop.c:45
job = 0x13fa200
iter = 0x13fa200
processed = 0
#10 0x00007f2648ed6f60 in qb_loop_run (lp=0x13f3f40) at loop.c:206
p = 1
p_stop = 1
rc = 0
remaining_todo = 0
job_todo = 0
timer_todo = 1
ms_timeout = 0
l = 0x13f3f40
func = "qb_loop_run"

#11 0x000000000041d7f1 in main (argc=2, argv=0x7fff532d54f8, envp=0x7fff532d5510) at main.c:1270
error_string = 0x6c51c0 "Successfully read main configuration file '/etc/corosync/corosync.conf'."
totem_config = {version = 2, interfaces = 0x1402aa0, interface_count = 1, node_id = 0, clear_node_high_bit = 0, private_key = '\000' <repeats 127 times>, private_key_len = 128, token_timeout = 1000, token_retransmit_timeout = 238, token_hold_timeout = 180, token_retransmits_before_loss_const = 4, join_timeout = 50, send_join_timeout = 0, consensus_timeout = 1200, merge_timeout = 200, downcheck_timeout = 1000, fail_to_recv_const = 2500, seqno_unchanged_const = 30, rrp_token_expired_timeout = 238, rrp_problem_count_timeout = 2000, rrp_problem_count_threshold = 10, rrp_problem_count_mcast_threshold = 100, rrp_autorecovery_check_timeout = 1000, rrp_mode = "none", '\000' <repeats 59 times>, totem_logging_configuration = {log_printf = 0x41cbea <_logsys_log_printf>, log_level_security = 4, log_level_error = 3, log_level_warning = 4, log_level_notice = 5, log_level_debug = 7, log_subsys_id = 16}, secauth = 0, net_mtu = 1374, threads = 0, heartbeat_failures_allowed = 0, max_network_delay = 50, window_size = 50, max_messages = 17, vsf_type = 0x42d6fe "none", broadcast_use = 0, crypto_type = TOTEM_CRYPTO_SOBER, crypto_accept = TOTEM_CRYPTO_ACCEPT_OLD, crypto_crypt_type = 0, crypto_sign_type = 0, transport_number = TOTEM_TRANSPORT_UDP, miss_count_const = 5}
res = 0
ch = -1
background = 0
setprio = 0
stat_out = {st_dev = 64769, st_ino = 10695, st_nlink = 2, st_mode = 16877, st_uid = 0, st_gid = 0, __pad0 = 0, st_rdev = 0, st_size = 4096, st_blksize = 4096, st_blocks = 8, st_atim = {tv_sec = 1331026037, tv_nsec = 0}, st_mtim = {tv_sec = 1331026037, tv_nsec = 0}, st_ctim = {tv_sec = 1331200211, tv_nsec = 154000001}, __unused = {0, 0, 0}}
corosync_lib_dir = "/var/lib/corosync", '\000' <repeats 159 times>, "/dev/shm/qb-corosync-blackbox-data\000r", '\000' <repeats 324 times>"\253, \327VI&\177", '\000' <repeats 67 times>, "p\001\000\000\000\000\000da\001\000\000\000\000\000da\001", '\000' <repeats 13 times>, "\005\000\000\000\000\000\000\000\000!\000\000\000\000\000\000p!\000\000\000\000\000f!\000\000\000\000\000hf!\000\000\000\000\000\000`\001\000\000\000\000\000\003", '\000' <repeats 39 times>"\260, \200wI&\177\000\000/\000\000\000\000\000\000\000\024oWI&\177\000\000\n\000\000\000\000\000\000\000"...
flock_err = COROSYNC_DONE_EXIT
totem_config_warnings = 0
func = "main"

TESTS: '}' is missing at the end of write_logs.c

GCC output looks like:

gcc -DHAVE_CONFIG_H -I. -I../include -I../include/qb -I../include -I../include -ansi -D_GNU_SOURCE -DANSI_ONLY -g -O2 -Wall -Wshadow -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wdeclaration-after-statement -Wpointer-arith -Wwrite-strings -Wcast-align -Wbad-function-cast -Wmissing-format-attribute -Wformat=2 -Wformat-security -Wformat-nonliteral -Wno-long-long -Wno-strict-aliasing -MT bench_log-write_logs.o -MD -MP -MF .deps/bench_log-write_logs.Tpo -c -o bench_log-write_logs.o test -f 'write_logs.c' || echo './'write_logs.c
write_logs.c: In function ‘log_dict_words’:
write_logs.c:32860:1: error: expected declaration or statement at end of input

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.