[zeromq-dev] malloc() memory corruption at zsock_new_req

Bachmair Florian - flexSolution GmbH florian.bachmair at flexsolution.eu
Thu Nov 17 07:53:24 CET 2016


Hi. I'm using czmq via a jni wrapper, and when I execute this method(See 
methode at the bottom of this message), the application crashes at the 
RED Codeline with

Any Ideas why this happens?

*** Error in `java': malloc(): memory corruption: 0x64e01218 ***
======= Backtrace: =========
/usr/lib/libc.so.6(+0x65180)[0x76e36180]
/usr/lib/libc.so.6(+0x6bc3c)[0x76e3cc3c]
/usr/lib/libc.so.6(+0x6df90)[0x76e3ef90]
/usr/lib/libc.so.6(__libc_calloc+0xd4)[0x76e41cd8]
======= Memory map: ========
00008000-00009000 r-xp 00000000 fd:00 58702 /opt/jdk1.8.0_111/bin/java
00010000-00011000 rw-p 00000000 fd:00 58702 /opt/jdk1.8.0_111/bin/java
01735000-01756000 rw-p 00000000 00:00 0          [heap]
61a43000-61a46000 ---p 00000000 00:00 0
61a46000-61a93000 rw-p 00000000 00:00 0
61a93000-61a96000 ---p 00000000 00:00 0
61a96000-61ae3000 rw-p 00000000 00:00 0
61ae3000-61ae4000 ---p 00000000 00:00 0
61ae4000-622e3000 rw-p 00000000 00:00 0
622e3000-622e4000 ---p 00000000 00:00 0
622e4000-62ae3000 rw-p 00000000 00:00 0
62ae3000-62ae4000 ---p 00000000 00:00 0
62ae4000-632e3000 rw-p 00000000 00:00 0
632e3000-632e4000 ---p 00000000 00:00 0
632e4000-63ae3000 rw-p 00000000 00:00 0
63ae3000-63c14000 r-xp 00000000 fd:00 11181 /usr/lib/libstdc++.so.6.0.22
63c14000-63c23000 ---p 00131000 fd:00 11181 /usr/lib/libstdc++.so.6.0.22
63c23000-63c28000 r--p 00130000 fd:00 11181 /usr/lib/libstdc++.so.6.0.22
63c28000-63c2a000 rw-p 00135000 fd:00 11181 /usr/lib/libstdc++.so.6.0.22
63c2a000-63c2c000 rw-p 00000000 00:00 0
63c2c000-63c75000 r-xp 00000000 fd:00 11117 /usr/lib/libpgm-5.2.so.0.0.122
63c75000-63c84000 ---p 00049000 fd:00 11117 /usr/lib/libpgm-5.2.so.0.0.122
63c84000-63c85000 r--p 00048000 fd:00 11117 /usr/lib/libpgm-5.2.so.0.0.122
63c85000-63c86000 rw-p 00049000 fd:00 11117 /usr/lib/libpgm-5.2.so.0.0.122
63c86000-63c8a000 rw-p 00000000 00:00 0
63c8a000-63d20000 r-xp 00000000 fd:00 26440 /usr/local/lib/libczmq.so.3.0.0
63d20000-63d30000 ---p 00096000 fd:00 26440 /usr/local/lib/libczmq.so.3.0.0
63d30000-63d32000 rw-p 00096000 fd:00 26440 /usr/local/lib/libczmq.so.3.0.0
63d32000-63d8c000 r-xp 00000000 fd:00 11166 /usr/lib/libsodium.so.18.1.1
63d8c000-63d9b000 ---p 0005a000 fd:00 11166 /usr/lib/libsodium.so.18.1.1
63d9b000-63d9c000 r--p 00059000 fd:00 11166 /usr/lib/libsodium.so.18.1.1
63d9c000-63d9d000 rw-p 0005a000 fd:00 11166 /usr/lib/libsodium.so.18.1.1
63d9d000-63ded000 r-xp 00000000 fd:00 11283 /usr/lib/libzmq.so.5.0.1
63ded000-63dfd000 ---p 00050000 fd:00 11283 /usr/lib/libzmq.so.5.0.1
63dfd000-63dff000 r--p 00050000 fd:00 11283 /usr/lib/libzmq.so.5.0.1
63dff000-63e00000 rw-p 00052000 fd:00 11283 /usr/lib/libzmq.so.5.0.1
63e00000-63ea0000 rw-p 00000000 00:00 0
63ea0000-63f00000 ---p 00000000 00:00 0
63f00000-63f3f000 rw-p 00000000 00:00 0
63f3f000-64000000 ---p 00000000 00:00 0
64000000-64100000 rw-p 00000000 00:00 0
64100000-64200000 rw-p 00000000 00:00 0
64200000-642de000 rw-p 00000000 00:00 0
642de000-64300000 ---p 00000000 00:00 0
6433c000-643cc000 r-xp 00000000 00:20 14253 
/tmp/sqlite-3.7.151-arm-libsqlitejdbc.so
643cc000-643ce000 rw-p 00090000 00:20 14253 
/tmp/sqlite-3.7.151-arm-libsqlitejdbc.so
643ce000-643cf000 rw-p 00000000 00:00 0
643cf000-643dd000 r-xp 00000000 fd:00 58921 
/opt/jdk1.8.0_111/jre/lib/arm/libnio.so
643dd000-643e4000 ---p 0000e000 fd:00 58921 
/opt/jdk1.8.0_111/jre/lib/arm/libnio.so
643e4000-643e5000 rw-p 0000d000 fd:00 58921 
/opt/jdk1.8.0_111/jre/lib/arm/libnio.so
643e5000-64400000 r--s 001d2000 fd:00 58856 
/opt/jdk1.8.0_111/jre/lib/ext/nashorn.jar
64400000-64500000 rw-p 00000000 00:00 0
64500000-645fe000 rw-p 00000000 00:00 0
645fe000-64600000 ---p 00000000 00:00 0
64600000-6462c000 rw-p 00000000 00:00 0
6462c000-64700000 ---p 00000000 00:00 0
6470a000-6470d000 r-xp 00000000 fd:00 10836 /usr/lib/libcap.so.2.25
6470d000-6471c000 ---p 00003000 fd:00 10836 /usr/lib/libcap.so.2.25
6471c000-6471d000 rw-p 00002000 fd:00 10836 /usr/lib/libcap.so.2.25
6471d000-6472d000 r-xp 00000000 fd:00 11074 /usr/lib/libnss_myhostname.so.2
6472d000-6473c000 ---p 00010000 fd:00 11074 /usr/lib/libnss_myhostname.so.2
6473c000-6473d000 r--p 0000f000 fd:00 11074 /usr/lib/libnss_myhostname.so.2
6473d000-6473e000 rw-p 00010000 fd:00 11074 /usr/lib/libnss_myhostname.so.2
6473e000-64751000 r-xp 00000000 fd:00 11140 /usr/lib/libresolv-2.24.so
64751000-64760000 ---p 00013000 fd:00 11140 /usr/lib/libresolv-2.24.so
64760000-64761000 r--p 00012000 fd:00 11140 /usr/lib/libresolv-2.24.so
64761000-64762000 rw-p 00013000 fd:00 11140 /usr/lib/libresolv-2.24.so
64762000-64764000 rw-p 00000000 00:00 0
64764000-64777000 r-xp 00000000 fd:00 58928 
/opt/jdk1.8.0_111/jre/lib/arm/libnet.so
64777000-6477f000 ---p 00013000 fd:00 58928 
/opt/jdk1.8.0_111/jre/lib/arm/libnet.so
6477f000-64780000 rw-p 00013000 fd:00 58928 
/opt/jdk1.8.0_111/jre/lib/arm/libnet.so
64780000-64781000 ---p 00000000 00:00 0
64781000-64800000 rw-p 00000000 00:00 0
64800000-648ff000 rw-p 00000000 00:00 0
648ff000-64900000 ---p 00000000 00:00 0
6490a000-64930000 r--s 00570000 fd:01 130954     /home/f/test.jar
64930000-64933000 ---p 00000000 00:00 0
64933000-64980000 rw-p 00000000 00:00 0
64980000-64983000 ---p 00000000 00:00 0
64983000-64a00000 rw-p 00000000 00:00 0
64a00000-64a21000 rw-p 00000000 00:00 0
64a21000-64b00000 ---p 00000000 00:00 0
64b01000-64b07000 r-xp 00000000 fd:00 11065 /usr/lib/libnss_dns-2.24.so
64b07000-64b16000 ---p 00006000 fd:00 11065 /usr/lib/libnss_dns-2.24.so
64b16000-64b17000 r--p 00005000 fd:00 11065 /usr/lib/libnss_dns-2.24.so
64b17000-64b18000 rw-p 00006000 fd:00 11065 /usr/lib/libnss_dns-2.24.so
64b18000-64b1b000 ---p 00000000 00:00 0
64b1b000-64b68000 rw-p 00000000 00:00 0
64b68000-64d00000 r--p 00000000 fd:00 14441 /usr/lib/locale/locale-archive
64d00000-64d21000 rw-p 00000000 00:00 0
64d21000-64e00000 ---p 00000000 00:00 0
64e00000-64e21000 rw-p 00000000 00:00 0
64e21000-64f00000 ---p 00000000 00:00 0
64f00000-64f21000 rw-p 00000000 00:00 0
64f21000-65000000 ---p 00000000 00:00 0
65012000-65015000 ---p 00000000 00:00 0
65015000-65062000 rw-p 00000000 00:00 0
65062000-65065000 ---p 00000000 00:00 0
65065000-650b2000 rw-p 00000000 00:00 0
650b2000-650b3000 ---p 00000000 00:00 0
650b3000-65181000 rw-p 00000000 00:00 0
65181000-65359000 r--s 03d2a000 fd:00 58838 /opt/jdk1.8.0_111/jre/lib/rt.jar
65359000-657fa000 rw-p 00000000 00:00 0
657fa000-65800000 ---p 00000000 00:00 0
65800000-65d40000 rw-p 00000000 00:00 0
65d40000-6a540000 ---p 00000000 00:00 0
6a540000-6b000000 rw-p 00000000 00:00 0
6b000000-74000000 ---p 00000000 00:00 0
7400b000-7400e000 rw-p 00000000 00:00 0
7400e000-74031000 ---p 00000000 00:00 0
74031000-74037000 rw-p 00000000 00:00 0
74037000-7407f000 ---p 00000000 00:00 0
7407f000-74084000 rw-p 00000000 00:00 0
74084000-74100000 ---p 00000000 00:00 0
74100000-74200000 rwxp 00000000 00:00 0
74200000-76100000 ---p 00000000 00:00 0
76100000-76200000 rw-p 00000000 00:00 0
76200000-76203000 r-xp 00000000 fd:01 130951 /home/f/lib/libflexlib-zmq.so
76203000-7620a000 ---p 00003000 fd:01 130951 /home/f/lib/libflexlib-zmq.so
7620a000-7620b000 rw-p 00002000 fd:01 130951 /home/f/lib/libflexlib-zmq.so
7620b000-7620f000 r--s 00097000 fd:00 58847 
/opt/jdk1.8.0_111/jre/lib/jsse.jar
7620f000-76215000 rw-p 00000000 00:00 0
76215000-7625d000 ---p 00000000 00:00 0
7625d000-76274000 r-xp 00000000 fd:00 58897 
/opt/jdk1.8.0_111/jre/lib/arm/libzip.so
76274000-7627b000 ---p 00017000 fd:00 58897 
/opt/jdk1.8.0_111/jre/lib/arm/libzip.so
7627b000-7627c000 rw-p 00016000 fd:00 58897 
/opt/jdk1.8.0_111/jre/lib/arm/libzip.so
7627c000-76286000 r-xp 00000000 fd:00 11066 /usr/lib/libnss_files-2.24.so
76286000-76295000 ---p 0000a000 fd:00 11066 /usr/lib/libnss_files-2.24.so
76295000-76296000 r--p 00009000 fd:00 11066 /usr/lib/libnss_files-2.24.so
76296000-76297000 rw-p 0000a000 fd:00 11066 /usr/lib/libnss_files-2.24.so
76297000-7629d000 rw-p 00000000 00:00 0
7629d000-762c0000 r-xp 00000000 fd:00 58923 
/opt/jdk1.8.0_111/jre/lib/arm/libjava.so
762c0000-762c8000 ---p 00023000 fd:00 58923 
/opt/jdk1.8.0_111/jre/lib/arm/libjava.so
762c8000-762c9000 rw-p 00023000 fd:00 58923 
/opt/jdk1.8.0_111/jre/lib/arm/libjava.so
762c9000-762d2000 r-xp 00000000 fd:00 58899 
/opt/jdk1.8.0_111/jre/lib/arm/libverify.so
762d2000-762da000 ---p 00009000 fd:00 58899 
/opt/jdk1.8.0_111/jre/lib/arm/libverify.so
762da000-762db000 rw-p 00009000 fd:00 58899 
/opt/jdk1.8.0_111/jre/lib/arm/libverify.so
762db000-762e1000 r-xp 00000000 fd:00 11145 /usr/lib/librt-2.24.so
762e1000-762f0000 ---p 00006000 fd:00 11145 /usr/lib/librt-2.24.so
762f0000-762f1000 r--p 00005000 fd:00 11145 /usr/lib/librt-2.24.so
762f1000-762f2000 rw-p 00006000 fd:00 11145 /usr/lib/librt-2.24.so
762f2000-762f5000 ---p 00000000 00:00 0
762f5000-76342000 rw-p 00000000 00:00 0
76342000-763b1000 r-xp 00000000 fd:00 11024 /usr/lib/libm-2.24.so
763b1000-763c0000 ---p 0006f000 fd:00 11024 /usr/lib/libm-2.24.so
763c0000-763c1000 r--p 0006e000 fd:00 11024 /usr/lib/libm-2.24.so
763c1000-763c2000 rw-p 0006f000 fd:00 11024 /usr/lib/libm-2.24.so
763c2000-7694b000 r-xp 00000000 fd:00 58914 
/opt/jdk1.8.0_111/jre/lib/arm/client/libjvm.so
7694b000-76952000 ---p 00589000 fd:00 58914 
/opt/jdk1.8.0_111/jre/lib/arm/client/libjvm.so
76952000-7697e000 rw-p 00588000 fd:00 58914 
/opt/jdk1.8.0_111/jre/lib/arm/client/libjvm.so
7697e000-76da5000 rw-p 00000000 00:00 0
76da5000-76dc1000 r-xp 00000000 fd:00 10919 /usr/lib/libgcc_s.so.1
76dc1000-76dd0000 ---p 0001c000 fd:00 10919 /usr/lib/libgcc_s.so.1
76dd0000-76dd1000 rw-p 0001b000 fd:00 10919 /usr/lib/libgcc_s.so.1
76dd1000-76efa000 r-xp 00000000 fd:00 10828 /usr/lib/libc-2.24.so
76efa000-76f0a000 ---p 00129000 fd:00 10828 /usr/lib/libc-2.24.so
76f0a000-76f0c000 r--p 00129000 fd:00 10828 /usr/lib/libc-2.24.so
76f0c000-76f0d000 rw-p 0012b000 fd:00 10828 /usr/lib/libc-2.24.so
76f0d000-76f10000 rw-p 00000000 00:00 0
76f10000-76f14000 r-xp 00000000 fd:00 10867 /usr/lib/libdl-2.24.so
76f14000-76f23000 ---p 00004000 fd:00 10867 /usr/lib/libdl-2.24.so
76f23000-76f24000 r--p 00003000 fd:00 10867 /usr/lib/libdl-2.24.so
76f24000-76f25000 rw-p 00004000 fd:00 10867 /usr/lib/libdl-2.24.so
76f25000-76f39000 r-xp 00000000 fd:00 58964 
/opt/jdk1.8.0_111/lib/arm/jli/libjli.so
76f39000-76f41000 ---p 00014000 fd:00 58964 
/opt/jdk1.8.0_111/lib/arm/jli/libjli.so
76f41000-76f42000 rw-p 00014000 fd:00 58964 
/opt/jdk1.8.0_111/lib/arm/jli/libjli.so
76f42000-76f58000 r-xp 00000000 fd:00 11127 /usr/lib/libpthread-2.24.so
76f58000-76f67000 ---p 00016000 fd:00 11127 /usr/lib/libpthread-2.24.so
76f67000-76f68000 r--p 00015000 fd:00 11127 /usr/lib/libpthread-2.24.so
76f68000-76f69000 rw-p 00016000 fd:00 11127 /usr/lib/libpthread-2.24.so
76f69000-76f6b000 rw-p 00000000 00:00 0
76f6c000-76f74000 r-xp 00000000 fd:00 58907 
/opt/jdk1.8.0_111/jre/lib/arm/libmanagement.so
76f74000-76f7b000 ---p 00008000 fd:00 58907 
/opt/jdk1.8.0_111/jre/lib/arm/libmanagement.so
76f7b000-76f7c000 rw-p 00007000 fd:00 58907 
/opt/jdk1.8.0_111/jre/lib/arm/libmanagement.so
76f7c000-76f9c000 r-xp 00000000 fd:00 10745 /usr/lib/ld-2.24.so
76f9c000-76f9d000 rw-p 00000000 00:00 0
76f9d000-76f9e000 r--p 00197000 fd:00 14441 /usr/lib/locale/locale-archive
76f9e000-76fa6000 rw-s 00000000 00:20 293240 /tmp/hsperfdata_flex/28551
76fa6000-76fa7000 r--p 00000000 00:00 0
76fa7000-76fab000 rw-p 00000000 00:00 0
76fab000-76fac000 r--p 0001f000 fd:00 10745 /usr/lib/ld-2.24.so
76fac000-76fad000 rw-p 00020000 fd:00 10745 /usr/lib/ld-2.24.so
7ea11000-7ea32000 rw-p 00000000 00:00 0          [stack]
7eeec000-7eeed000 r-xp 00000000 00:00 0          [sigpage]
7eeed000-7eeee000 r--p 00000000 00:00 0          [vvar]
7eeee000-7eeef000 r-xp 00000000 00:00 0          [vdso]
ffff0000-ffff1000 r-xp 00000000 00:00 0          [vectors]






JNIEXPORT jstring JNICALL Java_ZeroMQ_native_1request(JNIEnv * env, 
jobject object, jstring address, jint port, jstring timestamp,
         jstring sender, jstring command, jstring message) {
// ===============================================
// Convert Java Objects to C
// ===============================================
     puts("A");
     fflush(stdout);
     const char *c_address = (*env)->GetStringUTFChars(env, address, 0);
     const char *c_timestamp = (*env)->GetStringUTFChars(env, timestamp, 0);
     const char *c_sender = (*env)->GetStringUTFChars(env, sender, 0);
     const char *c_command = (*env)->GetStringUTFChars(env, command, 0);
     const char *c_message = (*env)->GetStringUTFChars(env, message, 0);
     char *endpoint = (char*) malloc(sizeof(30));
     sprintf(endpoint, "tcp://%s:%d", c_address, port);

// ===============================================
// Connect to Endpoint, Send Request and wait for Response
// ===============================================
     puts("B");
     fflush(stdout);
*    req = zsock_new_req(endpoint);*
     zsock_send(req, "ssss", c_timestamp, c_sender, c_command, c_message);
     char* result;
     zsock_recv(req, "s", &result);

// ===============================================
// Free Resources
// ===============================================
     (*env)->ReleaseStringUTFChars(env, address, c_address);
      (*env)->ReleaseStringUTFChars(env, timestamp, c_timestamp);
      (*env)->ReleaseStringUTFChars(env, sender, c_sender);
      (*env)->ReleaseStringUTFChars(env, command, c_command);
      (*env)->ReleaseStringUTFChars(env, message, c_message);

// ===============================================
// Destroy zsock
// ===============================================
     puts("C");
     fflush(stdout);
     zsock_destroy(&req);

// ===============================================
// Return result
// ===============================================
     puts("D");
     fflush(stdout);
     jstring ret = (*env)->NewStringUTF(env, result);
     return ret;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20161117/ba66e326/attachment.htm>


More information about the zeromq-dev mailing list