segment fault cause by optimizer - java

We encountered one problem when trace log with gdb
.System crash when XMLRPC call and gdb backtrace show:
Program terminated with signal 11, Segmentation fault.
#0 finishCurlMulti (envP=0x0, curlMultiP=0xe37b800, timeoutType=timeout_no,
deadline=..., interruptP=0x0) at xmlrpc_curl_transport.c:572
warning: Source file is more recent than executable.
572
(gdb) bt
#0 finishCurlMulti (envP=0x0, curlMultiP=0xe37b800, timeoutType=timeout_no,
deadline=..., interruptP=0x0) at xmlrpc_curl_transport.c:572
#1 0x00002b84f0b4ad24 in performCurlTransaction (envP=0x46a185d0,
clientTransportP=0xe365d50, serverP=<value optimized out>,
callXmlP=<value optimized out>, responseXmlPP=0x46a185e8)
at xmlrpc_curl_transport.c:1036
#2 performRpc (envP=0x46a185d0, clientTransportP=0xe365d50,
serverP=<value optimized out>, callXmlP=<value optimized out>,
responseXmlPP=0x46a185e8) at xmlrpc_curl_transport.c:1141
#3 call (envP=0x46a185d0, clientTransportP=0xe365d50,
serverP=<value optimized out>, callXmlP=<value optimized out>,
responseXmlPP=0x46a185e8) at xmlrpc_curl_transport.c:1362
===> Is there null pointer error? envP=0x0
-------------------------------------trace frame 1--------------------
(gdb) frame 1
#1 0x00002b84f0b4ad24 in performCurlTransaction (envP=0x46a185d0, clientTransportP=0xe365d50, serverP=<value optimized out>, callXmlP=<value optimized out>,
responseXmlPP=0x46a185e8) at xmlrpc_curl_transport.c:1036
1036 synchronous RPC can be in progress is for the 'perform' method
(gdb) print envP
$1 = <value optimized out>
(gdb) info registers
rax 0x0 0
rbx 0xec59270 247829104
rcx 0x0 0
rdx 0x2 2
rsi 0x46a18200 1184989696
rdi 0xe37b800 238532608
rbp 0x46a185d0 0x46a185d0
rsp 0x46a184e0 0x46a184e0
r8 0x46a17f00 1184988928
r9 0x46a17ef0 1184988912
r10 0x46a18100 1184989440
r11 0x206 518
r12 0xe365d50 238443856
r13 0xe37b800 238532608
r14 0xe99dda0 244964768
r15 0x46a185e8 1184990696
rip 0x2b84f0b4ad24 0x2b84f0b4ad24 <call+340>
eflags 0x10206 [ PF IF RF ]
cs 0x33 51
ss 0xe02b 57387
ds 0x0 0
es 0x0 0
fs 0x63 99
gs 0x0 0
fctrl 0x37f 895
fstat 0x0 0
ftag 0xffff 65535
fiseg 0x0 0
fioff 0x0 0
foseg 0x0 0
fooff 0x0 0
fop 0x0 0
mxcsr 0x1fa0 [ PE IM DM ZM OM UM PM ]
========> do envP store in register rbp?
------------------------Back to frame 0-------------------
(gdb) frame 0
#0 finishCurlMulti (envP=0x0, curlMultiP=0xe37b800, timeoutType=timeout_no, deadline=..., interruptP=0x0) at xmlrpc_curl_transport.c:572
572
(gdb) print envP
$2 = (xmlrpc_env * const) 0x0
(gdb) info register
rax 0x0 0
rbx 0x0 0
rcx 0x0 0
rdx 0x2 2
rsi 0x46a18200 1184989696
rdi 0xe37b800 238532608
rbp 0xe37b800 0xe37b800
rsp 0x46a182f0 0x46a182f0
r8 0x46a17f00 1184988928
r9 0x46a17ef0 1184988912
r10 0x46a18100 1184989440
r11 0x206 518
r12 0x0 0
r13 0x0 0
r14 0x0 0
r15 0x0 0
rip 0x2b84f0b49e93 0x2b84f0b49e93 <finishCurlMulti+259>
eflags 0x10206 [ PF IF RF ]
cs 0x33 51
ss 0xe02b 57387
ds 0x0 0
es 0x0 0
fs 0x63 99
gs 0x0 0
fctrl 0x37f 895
fstat 0x0 0
ftag 0xffff 65535
fiseg 0x0 0
fioff 0x0 0
foseg 0x0 0
fooff 0x0 0
fop 0x0 0
mxcsr 0x1fa0 [ PE IM DM ZM OM UM PM ]
========> Please tell me what is wrong in this case?
I'm trying to use -O0 to disable optimizer but i don't sure.
Thanks.
Here is my backtrace with correct souce file:
#0 finishCurlMulti (envP=0x0, curlMultiP=0x12e2580, timeoutType=timeout_yes, deadline=..., interruptP=0x0) at xmlrpc_curl_transport.c:572
#1 0x00002abe7f51d0b4 in finishAsynch (clientTransportP=0x12e24c0, timeoutType=timeout_yes, timeout=10000) at xmlrpc_curl_transport.c:1301
#2 0x00002abe7f72f5c6 in xmlrpc_c::clientXmlTransport_http::finishAsync (this=0x12e2470, timeout=...) at client.cpp:624
#3 0x00002abe7f72f64a in xmlrpc_c::client_xml::finishAsync (this=0x1304bf0, timeout=...) at client.cpp:893
#4 0x00002aaaab57c26d in UrlStruct::runXmlRpc (this=0x122d140, method="mediacontrol.onEvent", paramList=<value optimized out>, result=<value optimized out>) at Utils.cpp:146
#5 0x00002aaaab57c526 in IVRUtils::executeXmlRpc (controllerUrl=0x12e2580, methodName=Traceback (most recent call last):
#6 0x00002aaaab54366a in IvrCoreSession::_exec_xmlrpc_cmd (this=0x2aaab48277f0, paramList=..., result=0x41228cb0) at IvrCoreSession.cpp:307
#7 0x00002aaaab544c95 in IvrCoreSession::fireEndCallEvent (this=0x2aaab48277f0) at IvrCoreSession.cpp:504
#8 0x00002aaaab54752d in IvrCoreSession::~IvrCoreSession (this=0x2aaab48277f0, __in_chrg=<value optimized out>) at IvrCoreSession.cpp:101
#9 0x000000000047c15d in AmSessionContainer::clean_sessions (this=0x10cbdd0) at AmSessionContainer.cpp:94
#10 0x000000000047c898 in AmSessionContainer::run (this=0x10cbdd0) at AmSessionContainer.cpp:132
#11 0x000000000049266c in AmThread::_start (_t=<value optimized out>) at AmThread.cpp:70
#12 0x000000397ec0673d in start_thread () from /lib64/libpthread.so.0
#13 0x000000397e0d40cd in clone () from /lib64/libc.so.6
This bug occur every 6 days. And we use xmlrpc-c lib with curl build option --enable-threaded-resolver. Please give us some idea.
Thanks.

This looks dangerous:
warning: Source file is more recent than executable
This means the debug symbols don't match your source code. Build and try again; you might be hunting a bug that has already been fixed.
Also check the code in performCurlTransaction() at xmlrpc_curl_transport.c:1036 because this function gets envP != null but it calls finishCurlMulti with null.

Related

Why does `sstableloader` hangs while running it in parallel for multiple keyspaces?

Why does sstableloader hang while running it in parallel for multiple keyspaces?
0 S root 8312 8036 24 80 0 - 2304478 futex_ 12:46 ? 00:25:55 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.345.b01-1.el7_9.x86_64/jre//bin/java -javaagent:/root/dse-6.8.25/resources/cassandra/bin/../../../resources/cassandra/lib/jamm-0.3.3.jar -javaagent:/root/dse-6.8.25/resources/cassandra/bin/../.............********..................../lib/dse-spark-6.8.25.jar -Dguice_include_stack_traces=OFF -Ddse.system_memory_in_mb=64265 -Dcassandra.config.loader=com.datastax.bdp.config.DseConfigurationLoader -Dclient.hosts=1X.1XX.1XX.1X -Xmx4096M -XX:MaxDirectMemorySize=2G -Dcassandra.storagedir=/root/dse-6.8.25/resources/cassandra/bin/../../../resources/cassandra/data -Dlogback.configurationFile=logback-tools.xml com.datastax.bdp.tools.ShellToolWrapper org.apache.cassandra.tools.BulkLoader -ap com.datastax.driver.dse.auth.DseGSSAPIAuthProvider -cph 2 -d 1X.1XX.1XX.1X /var/lib/cassandra/data/allkey_function22/alldata1-26def030452311ed8bcf47e54b6e7ca3/
Process stack trace :->
pstack 8312 |more
Thread 37 (Thread 0x7f9b10d0d700 (LWP 8313)):
#0 0x00007f9b108f6a35 in pthread_cond_wait##GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1 0x00007f9b0f790ec4 in Parker::park(bool, long) () from /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.345.b01-1.el7_9.x86_64/jre/
lib/amd64/server/libjvm.so
#2 0x00007f9b0f98012e in Unsafe_Park () from /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.345.b01-1.el7_9.x86_64/jre/lib/amd64/ser
ver/libjvm.so
#3 0x00007f9af92ecfea in ?? ()
#4 0x00000006c0014f58 in ?? ()
#5 0x00000006c008d7f8 in ?? ()
#6 0x00000006c0014f58 in ?? ()
#7 0x00007f9b10d0c048 in ?? ()
#8 0x00007f9abc37bfb0 in ?? ()
#9 0x00007f9b10d0c0a0 in ?? ()
#10 0x00007f9abc37c800 in ?? ()
#11 0x0000000000000000 in ?? ()
Thread 36 (Thread 0x7f9b0c8a7700 (LWP 8314)):
#0 0x00007f9b108f6a35 in pthread_cond_wait##GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1 0x00007f9b0f79011b in os::PlatformEvent::park() () from /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.345.b01-1.el7_9.x86_64/jre
/lib/amd64/server/libjvm.so
#2 0x00007f9b0f73c327 in Monitor::IWait(Thread*, long) () from /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.345.b01-1.el7_9.x86_64
/jre/lib/amd64/server/libjvm.so
#3 0x00007f9b0f73ceaf in Monitor::wait(bool, long, bool) () from /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.345.b01-1.el7_9.x86_
64/jre/lib/amd64/server/libjvm.so
#4 0x00007f9b0f426a9a in GCTaskManager::get_task(unsigned int) () from /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.345.b01-1.el7_
9.x86_64/jre/lib/amd64/server/libjvm.so
#5 0x00007f9b0f4285be in GCTaskThread::run() () from /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.345.b01-1.el7_9.x86_64/jre/lib/a
md64/server/libjvm.so
#6 0x00007f9b0f787942 in java_start(Thread*) () from /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.345.b01-1.el7_9.x86_64/jre/lib/a
md64/server/libjvm.so
#7 0x00007f9b108f2ea5 in start_thread () from /lib64/libpthread.so.0
#8 0x00007f9b0fff296d in clone () from /lib64/libc.so.6
Thread 35 (Thread 0x7f9b0c7a6700 (LWP 8315)):
seen below exception on destination node :-
e9717] All sessions completed org.apache.cassandra.streaming.StreamState#32eb4373
ERROR [Stream-Deserializer-/10.10.xx.xx:40933-3bd1b85a] 2022-10-15 00:41:24,001 StreamingInboundHandler.java:314 - [Stream channel: 3bd1b85a] stream operation from /10.10.xx.xx:40933 failed
java.lang.IllegalStateException: Unknown stream session: 37afd600-4bf3-11ed-9915-d5bc16ce9717 - 1
at org.apache.cassandra.streaming.messages.IncomingFileMessage$1.deserialize(IncomingFileMessage.java:57)
at org.apache.cassandra.streaming.messages.IncomingFileMessage$1.deserialize(IncomingFileMessage.java:48)
at org.apache.cassandra.streaming.messages.StreamMessage.deserialize(StreamMessage.java:98)
at org.apache.cassandra.streaming.async.StreamingInboundHandler$StreamDeserializingTask.run(StreamingInboundHandler.java:263)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:750)
INFO [OptionalTasks:1] 2022-10-15 00:44:59,282 StatusLogger.java:174 -
Pool Name Active Pending Backpressure Delayed Shared Stolen Completed Blocked All Time Blocked
AuthzStage 0 0 N/A N/A N/A N/A 0 0 0

Java 11 on latest Mac OS seems to lock the file system for minutes at a time

Since upgrading to java 11 on my Macbook Pro (latest OS, etc.) compiling projects seems to often lock the entire file system for long periods of time. Anyone else having this problem? Any ideas how to debug it?
Update: I did a dtruss on the process and I see endless output like this. I don't know if this is significant or not.
gettimeofday(0x700001D00D98, 0x0, 0x0) = 0 0
gettimeofday(0x7000011DCE18, 0x0, 0x0) = 0 0
psynch_cvwait(0x7F8EF6417C10, 0x89A0100089B00, 0x0) = -1 316
gettimeofday(0x700001D00D98, 0x0, 0x0) = 0 0
psynch_cvwait(0x7F8EF6417C10, 0x89B0100089C00, 0x0) = -1 316
gettimeofday(0x700001D00D98, 0x0, 0x0) = 0 0
psynch_cvwait(0x7F8EF6417C10, 0x89C0100089D00, 0x0) = -1 316
gettimeofday(0x700001D00D98, 0x0, 0x0) = 0 0
psynch_cvwait(0x7F8EF6417C10, 0x89D0100089E00, 0x0) = -1 316
gettimeofday(0x700001D00D98, 0x0, 0x0) = 0 0
psynch_cvwait(0x7F8EF6417C10, 0x89E0100089F00, 0x0) = -1 316
Just endless calls to that and then every once in a while:
stat64("<xxxx>.class\0", 0x700000CCBF30, 0x0) = 0 0
lstat64("<xxxx>.class\0", 0x700000CCBDE8, 0x0) = 0 0
Update: well, it's in the bug db now: https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8257477

double precision no truncation when typecast to int

The following:
double x = .43;
BigDecimal bd = new BigDecimal(z);
System.out.println(bd);
outputs:
.4299999.....
why does
double u = z*100;
bd = new BigDecimal(u);
System.out.println(u);
output:
43?
more generally I'm trying to find a case where the double representation causes a truncation problem. Consider the following:
double d;
int j;
BigDecimal bd;
for(int i = 0; i<10000;i++){
d= (double)(i/100.);
j = (int)(d*100.);
bd = new BigDecimal(j);
System.out.println(bd);
}
In not a single case is truncating occurring
In not a single case is truncating occurring
That is incorrect. Truncation occurs many times, you just didn't look close enough.
E.g. for i = 29:
int i = 29;
double d= i / 100.;
int j = (int)(d * 100.);
BigDecimal bd = new BigDecimal(j);
System.out.println(bd);
Output
28
OOPS!!!
Though I don't know what the point of converting j to bd is, since new BigDecimal(int) is always exact.
If you want to see all the truncation errors, try this:
for (int i = 0; i < 10000; i++){
double d = i / 100.;
int j = (int)(d * 100.);
if (i != j)
System.out.println(i + ": " + j);
}
Output
29: 28
57: 56
58: 57
113: 112
114: 113
115: 114
116: 115
201: 200
203: 202
205: 204
207: 206
226: 225
228: 227
230: 229
232: 231
251: 250
253: 252
255: 254
402: 401
406: 405
410: 409
414: 413
427: 426
431: 430
435: 434
439: 438
452: 451
456: 455
460: 459
464: 463
477: 476
481: 480
485: 484
489: 488
502: 501
506: 505
510: 509
803: 802
804: 803
812: 811
820: 819
828: 827
829: 828
837: 836
845: 844
853: 852
854: 853
862: 861
870: 869
878: 877
879: 878
887: 886
895: 894
903: 902
904: 903
912: 911
920: 919
928: 927
929: 928
937: 936
945: 944
953: 952
954: 953
962: 961
970: 969
978: 977
979: 978
987: 986
995: 994
1003: 1002
1004: 1003
1012: 1011
1020: 1019
1606: 1605
1608: 1607
1615: 1614
1624: 1623
1631: 1630
1633: 1632
1640: 1639
1649: 1648
1656: 1655
1658: 1657
1665: 1664
1674: 1673
1681: 1680
1683: 1682
1690: 1689
1699: 1698
1706: 1705
1708: 1707
1715: 1714
1724: 1723
1731: 1730
1733: 1732
1740: 1739
1749: 1748
1756: 1755
1758: 1757
1765: 1764
1774: 1773
1781: 1780
1783: 1782
1790: 1789
1799: 1798
1806: 1805
1808: 1807
1815: 1814
1824: 1823
1831: 1830
1833: 1832
1840: 1839
1849: 1848
1856: 1855
1858: 1857
1865: 1864
1874: 1873
1881: 1880
1883: 1882
1890: 1889
1899: 1898
1906: 1905
1908: 1907
1915: 1914
1924: 1923
1931: 1930
1933: 1932
1940: 1939
1949: 1948
1956: 1955
1958: 1957
1965: 1964
1974: 1973
1981: 1980
1983: 1982
1990: 1989
1999: 1998
2006: 2005
2008: 2007
2015: 2014
2024: 2023
2031: 2030
2033: 2032
2040: 2039
3205: 3204
3212: 3211
3216: 3215
3223: 3222
3230: 3229
3237: 3236
3241: 3240
3248: 3247
3255: 3254
3262: 3261
3266: 3265
3273: 3272
3280: 3279
3287: 3286
3291: 3290
3298: 3297
3305: 3304
3312: 3311
3316: 3315
3323: 3322
3330: 3329
3337: 3336
3341: 3340
3348: 3347
3355: 3354
3362: 3361
3366: 3365
3373: 3372
3380: 3379
3387: 3386
3391: 3390
3398: 3397
3405: 3404
3412: 3411
3416: 3415
3423: 3422
3430: 3429
3437: 3436
3441: 3440
3448: 3447
3455: 3454
3462: 3461
3466: 3465
3473: 3472
3480: 3479
3487: 3486
3491: 3490
3498: 3497
3505: 3504
3512: 3511
3516: 3515
3523: 3522
3530: 3529
3537: 3536
3541: 3540
3548: 3547
3555: 3554
3562: 3561
3566: 3565
3573: 3572
3580: 3579
3587: 3586
3591: 3590
3598: 3597
3605: 3604
3612: 3611
3616: 3615
3623: 3622
3630: 3629
3637: 3636
3641: 3640
3648: 3647
3655: 3654
3662: 3661
3666: 3665
3673: 3672
3680: 3679
3687: 3686
3691: 3690
3698: 3697
3705: 3704
3712: 3711
3716: 3715
3723: 3722
3730: 3729
3737: 3736
3741: 3740
3748: 3747
3755: 3754
3762: 3761
3766: 3765
3773: 3772
3780: 3779
3787: 3786
3791: 3790
3798: 3797
3805: 3804
3812: 3811
3816: 3815
3823: 3822
3830: 3829
3837: 3836
3841: 3840
3848: 3847
3855: 3854
3862: 3861
3866: 3865
3873: 3872
3880: 3879
3887: 3886
3891: 3890
3898: 3897
3905: 3904
3912: 3911
3916: 3915
3923: 3922
3930: 3929
3937: 3936
3941: 3940
3948: 3947
3955: 3954
3962: 3961
3966: 3965
3973: 3972
3980: 3979
3987: 3986
3991: 3990
3998: 3997
4005: 4004
4012: 4011
4016: 4015
4023: 4022
4030: 4029
4037: 4036
4041: 4040
4048: 4047
4055: 4054
4062: 4061
4066: 4065
4073: 4072
4080: 4079
4087: 4086
4091: 4090
6407: 6406
6410: 6409
6421: 6420
6424: 6423
6432: 6431
6435: 6434
6446: 6445
6449: 6448
6457: 6456
6460: 6459
6471: 6470
6474: 6473
6482: 6481
6485: 6484
6496: 6495
6499: 6498
6507: 6506
6510: 6509
6521: 6520
6524: 6523
6532: 6531
6535: 6534
6546: 6545
6549: 6548
6557: 6556
6560: 6559
6571: 6570
6574: 6573
6582: 6581
6585: 6584
6596: 6595
6599: 6598
6607: 6606
6610: 6609
6621: 6620
6624: 6623
6632: 6631
6635: 6634
6646: 6645
6649: 6648
6657: 6656
6660: 6659
6671: 6670
6674: 6673
6682: 6681
6685: 6684
6696: 6695
6699: 6698
6707: 6706
6710: 6709
6721: 6720
6724: 6723
6732: 6731
6735: 6734
6746: 6745
6749: 6748
6757: 6756
6760: 6759
6771: 6770
6774: 6773
6782: 6781
6785: 6784
6796: 6795
6799: 6798
6807: 6806
6810: 6809
6821: 6820
6824: 6823
6832: 6831
6835: 6834
6846: 6845
6849: 6848
6857: 6856
6860: 6859
6871: 6870
6874: 6873
6882: 6881
6885: 6884
6896: 6895
6899: 6898
6907: 6906
6910: 6909
6921: 6920
6924: 6923
6932: 6931
6935: 6934
6946: 6945
6949: 6948
6957: 6956
6960: 6959
6971: 6970
6974: 6973
6982: 6981
6985: 6984
6996: 6995
6999: 6998
7007: 7006
7010: 7009
7021: 7020
7024: 7023
7032: 7031
7035: 7034
7046: 7045
7049: 7048
7057: 7056
7060: 7059
7071: 7070
7074: 7073
7082: 7081
7085: 7084
7096: 7095
7099: 7098
7107: 7106
7110: 7109
7121: 7120
7124: 7123
7132: 7131
7135: 7134
7146: 7145
7149: 7148
7157: 7156
7160: 7159
7171: 7170
7174: 7173
7182: 7181
7185: 7184
7196: 7195
7199: 7198
7207: 7206
7210: 7209
7221: 7220
7224: 7223
7232: 7231
7235: 7234
7246: 7245
7249: 7248
7257: 7256
7260: 7259
7271: 7270
7274: 7273
7282: 7281
7285: 7284
7296: 7295
7299: 7298
7307: 7306
7310: 7309
7321: 7320
7324: 7323
7332: 7331
7335: 7334
7346: 7345
7349: 7348
7357: 7356
7360: 7359
7371: 7370
7374: 7373
7382: 7381
7385: 7384
7396: 7395
7399: 7398
7407: 7406
7410: 7409
7421: 7420
7424: 7423
7432: 7431
7435: 7434
7446: 7445
7449: 7448
7457: 7456
7460: 7459
7471: 7470
7474: 7473
7482: 7481
7485: 7484
7496: 7495
7499: 7498
7507: 7506
7510: 7509
7521: 7520
7524: 7523
7532: 7531
7535: 7534
7546: 7545
7549: 7548
7557: 7556
7560: 7559
7571: 7570
7574: 7573
7582: 7581
7585: 7584
7596: 7595
7599: 7598
7607: 7606
7610: 7609
7621: 7620
7624: 7623
7632: 7631
7635: 7634
7646: 7645
7649: 7648
7657: 7656
7660: 7659
7671: 7670
7674: 7673
7682: 7681
7685: 7684
7696: 7695
7699: 7698
7707: 7706
7710: 7709
7721: 7720
7724: 7723
7732: 7731
7735: 7734
7746: 7745
7749: 7748
7757: 7756
7760: 7759
7771: 7770
7774: 7773
7782: 7781
7785: 7784
7796: 7795
7799: 7798
7807: 7806
7810: 7809
7821: 7820
7824: 7823
7832: 7831
7835: 7834
7846: 7845
7849: 7848
7857: 7856
7860: 7859
7871: 7870
7874: 7873
7882: 7881
7885: 7884
7896: 7895
7899: 7898
7907: 7906
7910: 7909
7921: 7920
7924: 7923
7932: 7931
7935: 7934
7946: 7945
7949: 7948
7957: 7956
7960: 7959
7971: 7970
7974: 7973
7982: 7981
7985: 7984
7996: 7995
7999: 7998
8007: 8006
8010: 8009
8021: 8020
8024: 8023
8032: 8031
8035: 8034
8046: 8045
8049: 8048
8057: 8056
8060: 8059
8071: 8070
8074: 8073
8082: 8081
8085: 8084
8096: 8095
8099: 8098
8107: 8106
8110: 8109
8121: 8120
8124: 8123
8132: 8131
8135: 8134
8146: 8145
8149: 8148
8157: 8156
8160: 8159
8171: 8170
8174: 8173
8182: 8181
8185: 8184
That is 573 times, i.e. 5.73% of the time.

Error in JNI method returning ArrayList of Points

I'm trying to use JNI to import a c++ library that I will use in my java project. I have successfully gotten the library method to be called and am trying to return an ArrayList of Point objects from the JNI function. However, I'm getting an error with a rather vague description ('Problematic frame:
V [libjvm.dylib+0x30bab5] JNI_ArgumentPusherVaArg::JNI_ArgumentPusherVaArg(_jmethodID*, __va_list_tag*)+0xd
'). I have no clue what's going on, does anyone know what's going on or how I should interpret this console output? I can attach the log file if anyone wants it.
Console output:
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x000000010550bab5, pid=4633, tid=6403
#
# JRE version: Java(TM) SE Runtime Environment (7.0_51-b13) (build 1.7.0_51-b13)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (24.51-b03 mixed mode bsd-amd64 compressed oops)
# Problematic frame:
# V [libjvm.dylib+0x30bab5] JNI_ArgumentPusherVaArg::JNI_ArgumentPusherVaArg(_jmethodID*, __va_list_tag*)+0xd
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /Users/zalbhathena/Documents/workspace/Thesis-Test-Application/HPA* Program/hs_err_pid4633.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.sun.com/bugreport/crash.jsp
#
Hello World!
ASDFse_dcdt.cpp 284 : Starting init()...
SeDcdt::initfoo.512se_dcdt.cpp 303 : Calculating External Polygon for domain with 4 points...
se_dcdt.cpp 317 : Creating External Polygon...
SeDcdt::initse_dcdt.cpp 326 : Backface v1: -14 -14
se_dcdt.cpp 329 : Backface v2: -14 14
se_dcdt.cpp 332 : Backface v3: 14 14
se_dcdt.cpp 335 : Backface v4: 14 -14
se_triangulator.cpp 417 : insert_point_in_edge...
se_triangulator.cpp 473 : propagate_delaunay...
se_triangulator.cpp 480 : optimizing in constrained mode...4
se_triangulator.cpp 538 : Ok.
se_triangulator.cpp 387 : insert_point_in_face...
se_triangulator.cpp 473 : propagate_delaunay...
se_triangulator.cpp 480 : optimizing in constrained mode...3
se_triangulator.cpp 538 : Ok.
se_triangulator.cpp 417 : insert_point_in_edge...
se_triangulator.cpp 473 : propagate_delaunay...
se_triangulator.cpp 480 : optimizing in constrained mode...4
se_triangulator.cpp 538 : Ok.
se_triangulator.cpp 387 : insert_point_in_face...
se_triangulator.cpp 473 : propagate_delaunay...
se_triangulator.cpp 480 : optimizing in constrained mode...3
se_triangulator.cpp 538 : Ok.
se_triangulator.cpp 417 : insert_point_in_edge...
se_triangulator.cpp 473 : propagate_delaunay...
se_triangulator.cpp 480 : optimizing in constrained mode...4
se_triangulator.cpp 538 : Ok.
se_triangulator.cpp 387 : insert_point_in_face...
se_triangulator.cpp 473 : propagate_delaunay...
se_triangulator.cpp 480 : optimizing in constrained mode...3
se_triangulator.cpp 538 : Ok.
se_triangulator.cpp 387 : insert_point_in_face...
se_triangulator.cpp 473 : propagate_delaunay...
se_triangulator.cpp 480 : optimizing in constrained mode...3
se_triangulator.cpp 538 : Ok.
1
2
3
4
HPAProgram.cpp
/*
* HPAProgram.c++
*
* Created on: Feb 4, 2014
* Author: zalbhathena
*/
//=#include <jni.h>
#include <stdio.h>
#include "HPAProgram.h"
#include "DCDTWrapper.h"
JNIEXPORT jobject JNICALL Java_HPAProgram_sayHello (JNIEnv *env, jobject obj) {
printf("Hello World!\n");
GsArray<GsPnt2> edges;
create_dcdt(&edges);
printf("1\n");
jclass arraylist_class = (*env).FindClass("java/util/ArrayList");
jclass point_class = (*env).FindClass("java/awt/Point");
jmethodID init_arraylist = (*env).GetMethodID(arraylist_class, "<init>", "()V");
jmethodID init_point = (*env).GetMethodID(point_class, "<init>", "(II)V");
jmethodID add_arraylist = (*env).GetMethodID(arraylist_class, "add", "(java/lang/Object)V");
jobject return_obj = (*env).NewObject(arraylist_class, init_arraylist);
printf("2\n");
for (int n=0;n<edges.size();n++)
{
jfloat x = 1;
jfloat y = 1;
printf("3\n");
jobject point_obj = (*env).NewObject(point_class, init_point,x,y);
printf("4\n");
(*env).CallVoidMethod(return_obj, add_arraylist, point_obj);
printf("5\n");
}
return nullptr;
}
DCDTWrapper.cpp
# define END 12345.6
# define FIRST_EXAMPLE Example1
//# include "DCDTsrc/se_dcdt.h"
//# include "DCDTsrc/gs_polygon.h"
//# include <stdlib.h>
# include "DCDTWrapper.h"
static double Example1[] =
{ -10, -10, 10, -10, 10, 10, -10, 10, END,
1, 1, 7, 3, 3, 8, END,
END };
static const double* CurExample = FIRST_EXAMPLE;
static SeDcdt TheDcdt;
static GsPolygon CurPath;
static GsPolygon CurChannel;
static float CurX1=0, CurY1=0, CurX2=0, CurY2=0;
static int CurSelection=0; // -2,-1: moving point, >0: moving polygon
void create_dcdt (GsArray<GsPnt2>* edges)
{
printf("ASDF");
const double* data = CurExample;
GsPolygon pol;
// domain:
while ( *data!=END ) { pol.push().set((float)data[0],(float)data[1]); data+=2; }
TheDcdt.init ( pol, 0.00001f );
while ( *++data!=END )
{ pol.size(0);
while ( *data!=END ) { pol.push().set((float)data[0],(float)data[1]); data+=2; }
TheDcdt.insert_polygon ( pol );
}
GsArray<GsPnt2> unconstr;
TheDcdt.get_mesh_edges(edges, &unconstr);
for(int i = 0; i < unconstr.size(); i++) {
edges -> push(unconstr.get(i));
}
}
HPAProgram.java
import java.util.ArrayList;
public class HPAProgram {
/* static {
//System.out.println(new File(".").getAbsolutePath());
System.loadLibrary("libhpaprogram"); // hello.dll (Windows) or libhello.so (Unixes)
}
//private native void sayHello();
*/
public native ArrayList<String> sayHello();
public static void main(String[] args) {
System.loadLibrary("HPAProgram");
HPAProgram s = new HPAProgram();
s.sayHello();
MapWindowController map = new MapWindowController();
}
}
Function addfrom class ArrayList has return type boolean not void so in c code you have to call CallBooleanMethod from env instead of CallVoidMethod.
Edit: And you need to correct the signature of the add method as well.
You need to change the method signature for "add" element in arrayList as below:
jmethodID add_arraylist = (*env).GetMethodID(arraylist_class, "add", "(java/lang/Object)Z");
instead of
jmethodID add_arraylist = (*env).GetMethodID(arraylist_class, "add", "(java/lang/Object)V");

'Not in gzip format" error when decompressing gzip inputstream in java

My code is attempting to decompress an input stream read from a gzipped file.
Here is the code snippet:
InputStream is = new GZIPInputStream(new ByteArrayInputStream(fcontents.getBytes()));
The file itself is fine:
$cat storefront3.gz | gunzip
180028796
80026920
180028796
180026921
8002790180
800001
1800002
1800007
800008
800009
The data read in prior to the top code snippet via FileInputStream sure looks like gzip stuff (note the original file was storefront3.tsv):
��[�Rstorefront3.tsvu���0k{)�?�/FBģ��Y'��Q�a���s~���}6���d�{2+���O���D�m~�O��
But get the following:
Caused by: java.io.IOException: Not in GZIP format
at java.util.zip.GZIPInputStream.readHeader(GZIPInputStream.java:141)
at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:56)
at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:65)
Here is a hex dump of the .gz file
23:40:44/storefronts:72 $od -cx storefront3.gz
0000000 037 213 \b \b 201 [ 347 R \0 003 s t o r e f
8b1f 0808 5b81 52e7 0300 7473 726f 6665
0000020 r o n t 3 . t s v \0 u 212 273 025 200 0
6f72 746e 2e33 7374 0076 8a75 15bb 3080
0000040 \f 003 k { 032 ) 200 ? 373 / F B ģ ** 302 131
030c 7b6b 291a 3f80 2ffb 4246 a3c4 cdc2
0000060 Y ' 261 200 Q 331 a 276 276 350 001 s ~ 222 262 175
2759 80b1 d951 be61 e8be 7301 927e dcb2
0000100 } 6 226 231 367 d 200 { 2 + 211 337 342 020 O 022
367d 9996 64f7 7b80 2b32 df89 10e2 f14f
0000120 022 343 035 246 D 211 m ~ 003 326 O 235 030 236 \0 \0
e312 a61d 8944 7e6d d603 9d4f 9e18 0000
0000140 \0
0000
UPDATE
I also tried to use FileInputStream. Following gives same error
GZIPInputStream strm = new GZIPInputStream(new FileInputStream(tmpFileName));
Since fcontents contains your gzipped data it should be a byte[] and not a String?
I recommend using IOUtils for reading the file into a byte array as reading it into a string will most likely corrupt your data.

Categories