1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
|
#
# All file and line numbers from debug build using commit 60e6f5f67c5bc2a8fb26e8f2ef76c169c5b78813
#
# See <https://www.valgrind.org/docs/manual/mc-manual.html#mc-manual.suppfiles>
# See <https://wiki.wxwidgets.org/Valgrind_Suppression_File_Howto>
#
# direct_bt::LFRingbuffer::* utilizes SC-DRF atomic acquire (read) and release (write)
# not detected by helgrind. See unit test test_mm_sc_drf (passed).
#
# ==1175024== ---Thread-Announcement------------------------------------------
# ==1175024== Thread #2 was created
# ==1175024== by 0x49434C1: direct_bt::DBTManager::DBTManager(direct_bt::BTMode) (DBTManager.cpp:333)
# ==1175024== Thread #2: Bug in libpthread: write lock granted on mutex/rwlock which is currently wr-held by a different thread
# ==1175024== by 0x13283A: _ZN9jau10ringbufferISt10shared_ptrINS_9MgmtEventEELDnEE7putImplERKS3_bbi (LFRingbuffer.hpp:240)
# (see below: cpp_unique_lock_cond_wait_002)
{
jau_ringbuffer_lock_and_wait_001
Helgrind:Misc
fun:mutex_lock_WRK
...
fun:*jau*ringbuffer*putImpl*
...
obj:*libdirect_bt.so*
}
# direct_bt::LFRingbuffer::* utilizes SC-DRF atomic acquire (read) and release (write)
# not detected by helgrind. See uni test test_mm_sc_drf (passed).
#
# ==1175024== Thread #1 is the program's root thread
# ==1175024== Thread #2 unlocked lock at 0x13F628 currently held by thread #1
# ==1175024== by 0x132913: _ZN9jau10ringbufferISt10shared_ptrINS_9MgmtEventEELDnEE7putImplERKS3_bbi (LFRingbuffer.hpp:240)
# {
# 240 std::unique_lock<std::mutex> lockRead(syncRead); // SC-DRF w/ getImpl via same lock
# size++;
# writePos = localWritePos; // SC-DRF release atomic writePos
# cvRead.notify_all(); // notify waiting getter
# }
# ==1175024== Lock at 0x13F628 was first observed
# ==1175024== by 0x131EDC: _ZN9jau10ringbufferISt10shared_ptrINS_9MgmtEventEELDnEE7getImplEbbi (LFRingbuffer.hpp:181)
# if( blocking ) {
# 181 std::unique_lock<std::mutex> lockRead(syncRead); // SC-DRF w/ putImpl via same lock
# while( localReadPos == writePos ) {
# ..
# cvRead.wait(lockRead); or cvRead.wait_until(lockRead, ..);
# }
# }
{
jau_ringbuffer_lock_and_wait_002
Helgrind:UnlockForeign
fun:mutex_unlock_WRK
...
fun:*jau*ringbuffer*putImpl*
...
obj:*libdirect_bt.so*
}
#
# direct_bt::LFRingbuffer::* utilizes SC-DRF atomic acquire (read) and release (write)
# not detected by helgrind. See uni test test_mm_sc_drf (passed).
#
# ==1175024== Possible data race during read of size 8 at 0x4F490E8 by thread #1
# ==1175024== Locks held: 3, at addresses 0x13F480 0x13F650 0x13F7B0
# ==1175024== at 0x131D90: std::__shared_ptr<direct_bt::MgmtEvent, (__gnu_cxx::_Lock_policy)2>::__shared_ptr(std::__shared_ptr<direct_bt::MgmtEvent, (__gnu_cxx::_Lock_policy)2> const&) (shared_ptr_base.h:1181)
# ==1175024== by 0x131DDA: std::shared_ptr<direct_bt::MgmtEvent>::shared_ptr(std::shared_ptr<direct_bt::MgmtEvent> const&) (shared_ptr.h:149)
# ==1175024== by 0x1320B0: _ZN9jau10ringbufferISt10shared_ptrINS_9MgmtEventEELDnEE7getImplEbbi (LFRingbuffer.hpp:198)
#
# ==1175024== This conflicts with a previous write of size 8 by thread #2
# ==1175024== Locks held: 1, at address 0x13F6A0
# ==1175024== at 0x130E6D: std::__shared_ptr<direct_bt::MgmtEvent, (__gnu_cxx::_Lock_policy)2>::operator=(std::__shared_ptr<direct_bt::MgmtEvent, (__gnu_cxx::_Lock_policy)2> const&) (shared_ptr_base.h:1182)
# ==1175024== by 0x130EB4: std::shared_ptr<direct_bt::MgmtEvent>::operator=(std::shared_ptr<direct_bt::MgmtEvent> const&) (shared_ptr.h:358)
# ==1175024== by 0x13281D: _ZN9jau10ringbufferISt10shared_ptrINS_9MgmtEventEELDnEE7putImplERKS3_bbi (LFRingbuffer.hpp:237)
{
jau_ringbuffer_sc_drf_atomic_001
Helgrind:Race
...
fun:*jau*ringbuffer*getImpl*
...
obj:*libdirect_bt.so*
}
#
# DBTManager
#
# ==1175024== Possible data race during read of size 8 at 0x4F49690 by thread #1
# ==1175024== Locks held: 2, at addresses 0x13F480 0x13F7B0
# ==1175024== at 0x494261F: direct_bt::DBTManager::sendWithReply(direct_bt::MgmtCommand&) (DBTManager.cpp:205)
# ==1175024== by 0x494359D: direct_bt::DBTManager::DBTManager(direct_bt::BTMode) (DBTManager.cpp:350)
#
# ==1175024== Address 0x4f49690 is 0 bytes inside a block of size 48 alloc'd
# ==1175024== at 0x4839E3F: operator new(unsigned long) (vg_replace_malloc.c:342)
# ==1175024== by 0x493C244: direct_bt::MgmtEvent::getSpecialized(unsigned char const*, int) (MgmtTypes.cpp:243)
{
jau_ringbuffer_sc_drf_atomic_011
Helgrind:Race
...
fun:*jau*DBTManager*sendWithReply*
...
obj:*libdirect_bt.so*
}
{
jau_ringbuffer_sc_drf_atomic_012
Helgrind:Race
...
fun:*direct_bt*DBTManager*BTMode*
...
# obj:*libdirect_bt.so*
}
{
jau_ringbuffer_sc_drf_atomic_013
Helgrind:Race
...
fun:_ZN9direct_bt9MgmtEventD1Ev
...
obj:*libdirect_bt.so*
}
{
jau_ringbuffer_sc_drf_atomic_014
Helgrind:Race
...
# fun:*direct_bt*MgmtEvtCmdComplete*getStatus*
# fun:*direct_bt*MgmtEvtCmdStatus*getStatus*
fun:*direct_bt*MgmtEvtCmd*getStatus*
...
obj:*libdirect_bt.so*
}
{
jau_ringbuffer_sc_drf_atomic_015
Helgrind:Race
...
fun:*direct_bt*DBTManager*close*
...
}
#
# GATTHandler
#
{
jau_ringbuffer_sc_drf_atomic_021
Helgrind:Race
...
fun:*direct_bt*GATTHandler*sendWithReply*
...
obj:*libdirect_bt.so*
}
{
jau_ringbuffer_sc_drf_atomic_022
Helgrind:Race
...
fun:_ZN9direct_bt11GATTHandlerC1ERKSt10shared_ptrINS_9DBTDeviceEE
...
# obj:*libdirect_bt.so*
}
{
jau_ringbuffer_sc_drf_atomic_023
Helgrind:Race
...
# fun:*direct_bt*GATTHandler*discoverPrimaryServices*
# fun:*direct_bt*GATTHandler*discoverCharacteristics*
fun:*direct_bt*GATTHandler*discoverCompletePrimaryServices*
...
obj:*libdirect_bt.so*
}
{
jau_ringbuffer_sc_drf_atomic_024
Helgrind:Race
...
fun:_ZN9direct_bt9AttPDUMsgD1Ev
...
obj:*libdirect_bt.so*
}
{
jau_ringbuffer_sc_drf_atomic_025
Helgrind:Race
...
fun:*direct_bt*GATTHandler*readValue*
...
obj:*libdirect_bt.so*
}
{
jau_ringbuffer_sc_drf_atomic_026
Helgrind:Race
...
fun:*direct_bt*GATTHandler*writeValue*
...
obj:*libdirect_bt.so*
}
#
# HCIHandler
#
{
jau_ringbuffer_sc_drf_atomic_031
Helgrind:Race
...
fun:*direct_bt*HCIHandler*getNextReply*
...
obj:*libdirect_bt.so*
}
{
jau_ringbuffer_sc_drf_atomic_032
Helgrind:Race
...
fun:*direct_bt*HCIHandler*sendWithCmdCompleteReply*
...
obj:*libdirect_bt.so*
}
{
jau_ringbuffer_sc_drf_atomic_033
Helgrind:Race
...
fun:*direct_bt*HCIHandler*BTMode*
...
obj:*libdirect_bt.so*
}
{
jau_ringbuffer_sc_drf_atomic_034
Helgrind:Race
...
fun:_ZN9direct_bt9HCIPacketD1Ev
...
obj:*libdirect_bt.so*
}
{
jau_ringbuffer_sc_drf_atomic_035
Helgrind:Race
...
fun:_ZNSt10shared_ptrIN9direct_bt8HCIEventEED1Ev
...
obj:*libdirect_bt.so*
}
{
jau_ringbuffer_sc_drf_atomic_036
Helgrind:Race
...
fun:*direct_bt*HCIHandler*processCommandComplete*
...
obj:*libdirect_bt.so*
}
{
jau_ringbuffer_sc_drf_atomic_037
Helgrind:Race
...
fun:*direct_bt*HCIHandler*processCommandStatus*
...
obj:*libdirect_bt.so*
}
{
jau_ringbuffer_sc_drf_atomic_038
Helgrind:Race
...
fun:*direct_bt*HCIHandler*le_set_scan_param*
...
obj:*libdirect_bt.so*
}
{
jau_ringbuffer_sc_drf_atomic_039
Helgrind:Race
...
fun:*direct_bt*HCIHandler*getLocalVersion*
...
obj:*libdirect_bt.so*
}
{
jau_cow_vector_sc_drf_atomic_041
Helgrind:Race
...
fun:*jau*cow_vector*
...
}
{
jau_cow_vector_sc_drf_atomic_042
Helgrind:Race
...
fun:*direct_bt*AdapterStatusListenerEED1Ev
...
}
{
jau_cow_vector_sc_drf_atomic_043
Helgrind:Race
...
fun:*direct_bt*GATTCharacteristicListenerEED1Ev
...
}
{
jau_cow_vector_sc_drf_atomic_043
Helgrind:Race
...
fun:*jau*FunctionDef*shared_ptr*
...
}
#
# DRD
#
{
jau_ringbuffer_lock_and_wait_001
drd:CondErr
...
fun:*jau*ringbuffer*putImpl*
...
}
{
jau_ringbuffer_lock_and_wait_002
drd:MutexErr
...
fun:*jau*ringbuffer*putImpl*
...
}
{
jau_ringbuffer_lock_and_wait_002
drd:CondErr
...
fun:_ZN9jau10ringbufferISt10shared_ptrIKNS_9AttPDUMsgEELDnEED1Ev
...
}
{
jau_ringbuffer_lock_and_wait_021
drd:MutexErr
...
fun:_ZNSt15_Sp_counted_ptrIPN9direct_bt11GATTHandlerELN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv
...
}
{
jau_ringbuffer_lock_and_wait_031
drd:CondErr
...
fun:_ZN9jau10ringbufferISt10shared_ptrINS_8HCIEventEELDnEED1Ev
...
}
{
jau_ringbuffer_lock_and_wait_031
drd:CondErr
...
fun:_ZN9jau10ringbufferISt10shared_ptrINS_9MgmtEventEELDnEED1Ev
...
}
{
jau_ringbuffer_lock_and_wait_032
drd:MutexErr
...
fun:_ZNSt15_Sp_counted_ptrIPN9direct_bt10HCIHandlerELN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv
...
}
{
jau_ringbuffer_sc_drf_atomic_001
drd:MutexErr
...
fun:*jau*ringbuffer*getImpl*
...
}
{
jau_ringbuffer_sc_drf_atomic_001
drd:ConflictingAccess
...
fun:*jau*ringbuffer*getImpl*
...
}
{
jau_ringbuffer_sc_drf_atomic_011
drd:ConflictingAccess
...
fun:*direct_bt*DBTManager*sendWithReply*
...
}
{
jau_ringbuffer_sc_drf_atomic_012
drd:ConflictingAccess
...
fun:*direct_bt*DBTManager*get*BTMode*
...
}
{
jau_ringbuffer_sc_drf_atomic_013
drd:ConflictingAccess
...
fun:_ZN9direct_bt9MgmtEventD1Ev
...
}
{
jau_ringbuffer_sc_drf_atomic_014
drd:ConflictingAccess
...
# fun:*direct_bt*MgmtEvtCmdComplete*getStatus*
# fun:*direct_bt*MgmtEvtCmdStatus*getStatus*
fun:*direct_bt*MgmtEvtCmd*getStatus*
...
}
{
jau_ringbuffer_sc_drf_atomic_015
drd:ConflictingAccess
...
fun:*direct_bt*MgmtEvent*getOpcode*
...
}
{
jau_ringbuffer_sc_drf_atomic_016
drd:ConflictingAccess
...
fun:*direct_bt*DBTManager*close*
...
}
{
jau_ringbuffer_sc_drf_atomic_021
drd:ConflictingAccess
...
fun:*direct_bt*GATTHandler*sendWithReply*
...
}
{
jau_ringbuffer_sc_drf_atomic_022
drd:ConflictingAccess
...
fun:_ZN9direct_bt11GATTHandlerC1ERKSt10shared_ptrINS_9DBTDeviceEE
...
}
{
jau_ringbuffer_sc_drf_atomic_023
drd:ConflictingAccess
...
# fun:*direct_bt*GATTHandler*discoverPrimaryServices*
# fun:*direct_bt*GATTHandler*discoverCharacteristics*
fun:*direct_bt*GATTHandler*discoverCompletePrimaryServices*
...
}
{
jau_ringbuffer_sc_drf_atomic_024
drd:ConflictingAccess
...
fun:_ZN9direct_bt9AttPDUMsgD1Ev
...
}
{
jau_ringbuffer_sc_drf_atomic_025
drd:ConflictingAccess
...
fun:*direct_bt*GATTHandler*readValue*
...
}
{
jau_ringbuffer_sc_drf_atomic_026
drd:ConflictingAccess
...
fun:*direct_bt*GATTHandler*writeValue*
...
}
{
jau_ringbuffer_sc_drf_atomic_031
drd:ConflictingAccess
...
fun:*direct_bt*HCIHandler*getNextReply*
...
}
{
jau_ringbuffer_sc_drf_atomic_032
drd:ConflictingAccess
...
fun:*direct_bt*HCIHandler*sendWithCmdCompleteReply*
...
}
{
jau_ringbuffer_sc_drf_atomic_033
drd:ConflictingAccess
...
fun:*direct_bt*HCIHandler*BTMode*
...
}
{
jau_ringbuffer_sc_drf_atomic_034
drd:ConflictingAccess
...
fun:_ZN9direct_bt9HCIPacketD1Ev
...
}
{
jau_ringbuffer_sc_drf_atomic_035
drd:ConflictingAccess
...
fun:_ZNSt10shared_ptrIN9direct_bt8HCIEventEED1Ev
...
}
{
jau_ringbuffer_sc_drf_atomic_036
drd:ConflictingAccess
...
fun:*direct_bt*HCIHandler*processCommandComplete*
...
}
{
jau_ringbuffer_sc_drf_atomic_037
drd:ConflictingAccess
...
fun:*direct_bt*HCIHandler*processCommandStatus*
...
}
{
jau_ringbuffer_sc_drf_atomic_038
drd:ConflictingAccess
...
fun:*direct_bt*HCIHandler*le_set_scan_param*
...
}
{
jau_ringbuffer_sc_drf_atomic_039
drd:ConflictingAccess
...
fun:*direct_bt*HCIHandler*getLocalVersion*
...
}
{
jau_cow_vector_sc_drf_atomic_041
drd:ConflictingAccess
...
fun:*jau*cow_vector*
...
}
{
jau_cow_vector_sc_drf_atomic_042
drd:ConflictingAccess
...
fun:*direct_bt*AdapterStatusListenerEED1Ev
...
}
{
jau_cow_vector_sc_drf_atomic_043
drd:ConflictingAccess
...
fun:*direct_bt*GATTCharacteristicListenerEED1Ev
...
}
{
jau_cow_vector_sc_drf_atomic_043
drd:ConflictingAccess
...
fun:*jau*FunctionDef*shared_ptr*
...
}
{
jau_check2_01
Memcheck:Cond
...
fun:*Catch*RunContext*
...
}
#
# Memcheck:Leak
#
# ==672244== 304 bytes in 1 blocks are possibly lost in loss record 1 of 1
# ==672244== at 0x483AB65: calloc (vg_replace_malloc.c:760)
# ==672244== by 0x4012D16: allocate_dtv (dl-tls.c:343)
# ==672244== by 0x4012D16: _dl_allocate_tls (dl-tls.c:589)
# ==672244== by 0x5051B81: allocate_stack (allocatestack.c:622)
# ==672244== by 0x5051B81: pthread_create@@GLIBC_2.2.5 (pthread_create.c:660)
# ==672244== by 0x4DEA144: std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28)
# ==672244== by 0x4ABD4B0: std::thread::thread<void (jau::service_runner::*)(), jau::service_runner*, void>(void (jau::service_runner::*&&)(), jau::service_runner*&&) (thread:149)
# ==672244== by 0x4ABBD88: jau::service_runner::start() (service_runner.cpp:164)
# ==672244== by 0x4B67FE7: direct_bt::BTManager::initialize(std::shared_ptr<direct_bt::BTManager> const&) (BTManager.cpp:385)
# ==672244== by 0x43A753: direct_bt::BTManager::make_shared() (BTManager.hpp:287)
# ==672244== by 0x43A7BA: direct_bt::BTManager::get() (BTManager.hpp:335)
# ==672244== by 0x43CB6F: BaseDBTClientServer::BaseDBTClientServer(bool) (dbt_base_client_server.hpp:67)
# ==672244== by 0x43CC4B: BaseDBTClientServer::get(bool) (dbt_base_client_server.hpp:80)
# ==672244== by 0x4320FB: __static_initialization_and_destruction_0(int, int) (dbt_client_server1x.hpp:38)
# ==672244== by 0x43241E: _GLOBAL__sub_I_catch_auto_run (test_client_server10_NoEnc.cpp:75)
# ==672244== by 0x55C024: __libc_csu_init (in /usr/local/projects/zafena/direct_bt/build-amd64/trial/direct_bt/test_client_server10_NoEnc)
# ==672244== by 0x5090C99: (below main) (libc-start.c:264)
# ==672244==
#
{
direct_bt_btmanager_01_thread
Memcheck:Leak
match-leak-kinds: possible
fun:calloc
...
fun:pthread_create*
fun:_ZNSt6thread15_M_start_threadESt10unique_ptrINS_6_StateESt14default_deleteIS1_EEPFvvE
fun:_ZNSt6threadC1IMN3jau14service_runnerEFvvEJPS2_EvEEOT_DpOT0_
fun:_ZN3jau14service_runner5startEv
fun:_ZN9direct_bt9BTManager10initializeERKSt10shared_ptrIS0_E
fun:_ZN9direct_bt9BTManager11make_sharedEv
fun:_ZN9direct_bt9BTManager3getEv
...
}
|