delete database when log out and create again after log in dart - database

I am developing an app in Flutter and dart , using SQFLite database and Firestore , I want when the user click on logout button , app deletes the sqflite database and return the user to Log In Screen and when Log In fetch the data user info log in from Firestore ,and it deletes the DB , but the problem is when I want to log in again to app , it shows me this error ..
Please need help
[ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: DatabaseException(database_closed 1)
#0 wrapDatabaseException (package:sqflite/src/exception_impl.dart:12:7)
E/flutter (28706): <asynchronous suspension>
E/flutter (28706): #1 SqfliteDatabaseFactoryImpl.wrapDatabaseException
(package:sqflite/src/factory_impl.dart:25:7)
E/flutter (28706): #2 SqfliteDatabaseMixin.safeInvokeMethod
(package:sqflite/src/database_mixin.dart:188:15)
E/flutter (28706): #3 SqfliteDatabaseMixin.txnRawInsert.<anonymous closure>
(package:sqflite/src/database_mixin.dart:363:14)
E/flutter (28706): #4 SqfliteDatabaseMixin.txnSynchronized.<anonymous closure>
(package:sqflite/src/database_mixin.dart:307:22)
E/flutter (28706): #5 BasicLock.synchronized (package:synchronized/src/basic_lock.dart:32:26)
E/flutter (28706): #6 SqfliteDatabaseMixin.txnSynchronized
(package:sqflite/src/database_mixin.dart:303:43)
E/flutter (28706): #7 SqfliteDatabaseMixin.txnWriteSynchronized
(package:sqflite/src/database_mixin.dart:325:7)
E/flutter (28706): #8 SqfliteDatabaseMixin.txnRawInsert
(package:sqflite/src/database_mixin.dart:362:12)
E/flutter (28706): #9 SqfliteDatabaseExecutorMixin.rawInsert
(package:sqflite/src/database_mixin.dart:49:15)
E/flutter (28706): #10 SqfliteDatabaseExecutorMixin.insert
(package:sqflite/src/database_mixin.dart:59:12)
E/flutter (28706): #11 SQFliteDBHelper.SAVE_USER
(package:health_calorie_db/settings_in_app/sqflite_db_helper.dart:86:20)
E/flutter (28706): <asynchronous suspension>
E/flutter (28706): #12 userServices.saveToSQFLiteDB
(package:health_calorie_db/dbServicesManager/userServices.dart:72:13)
E/flutter (28706): #13 userServices.logInCheck
(package:health_calorie_db/dbServicesManager/userServices.dart:99:10)
E/flutter (28706): <asynchronous suspension>
E/flutter (28706): #14 loginState.checkValidationForms
(package:health_calorie_db/ui_classes/log_in_up_pages/log_in_page.dart:25:22)
E/flutter (28706): #15 loginState.build.<anonymous closure>.<anonymous closure>
(package:health_calorie_db/ui_classes/log_in_up_pages/log_in_page.dart:112:60)
E/flutter (28706): #16 _createButton.build.<anonymous closure>
(package:health_calorie_db/ui_classes/log_in_up_pages/log_in_page.dart:165:9)
E/flutter (28706): #17 _InkResponseState._handleTap
(package:flutter/src/material/ink_well.dart:706:14)
E/flutter (28706): #18 _InkResponseState.build.<anonymous closure>
(package:flutter/src/material/ink_well.dart:789:36)
E/flutter (28706): #19 GestureRecognizer.invokeCallback
(package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter (28706): #20 TapGestureRecognizer.handleTapUp
(package:flutter/src/gestures/tap.dart:486:11)
E/flutter (28706): #21 BaseTapGestureRecognizer._checkUp
(package:flutter/src/gestures/tap.dart:264:5)
E/flutter (28706): #22 BaseTapGestureRecognizer.acceptGesture
(package:flutter/src/gestures/tap.dart:236:7)
E/flutter (28706): #23 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
E/flutter (28706): #24 GestureBinding.handleEvent
(package:flutter/src/gestures/binding.dart:222:20)
E/flutter (28706): #25 GestureBinding.dispatchEvent
(package:flutter/src/gestures/binding.dart:198:22)
E/flutter (28706): #26 GestureBinding._handlePointerEvent
(package:flutter/src/gestures/binding.dart:156:7)
E/flutter (28706): #27 GestureBinding._flushPointerEventQueue
(package:flutter/src/gestures/binding.dart:102:7)
E/flutter (28706): #28 GestureBinding._handlePointerDataPacket
(package:flutter/src/gestures/binding.dart:86:7)
E/flutter (28706): #29 _rootRunUnary (dart:async/zone.dart:1138:13)
E/flutter (28706): #30 _CustomZone.runUnary (dart:async/zone.dart:1031:19)
E/flutter (28706): #31 _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7)
E/flutter (28706): #32 _invoke1 (dart:ui/hooks.dart:273:10)
E/flutter (28706): #33 _dispatchPointerDataPacket (dart:ui/hooks.dart:182:5)
and here is the Code
FlatButton(
child: Text('Yes'),
onPressed: ()async {
setState(() {
dbHelper.deleteDB();
var duration = new Duration(seconds: 8);
return new Timer(duration, (){
exitApp();
});
});
},
Future<bool> deleteDB() async {
try{
deleteDatabase(path);
}catch( e){
print(e.toString());
}
print('deleting db');
}
exitApp()async {
Navigator.of(context).pushAndRemoveUntil(new MaterialPageRoute(builder: (context)=>login()),
(Route<dynamic> route) => false);
}
Future logInCheck(String name , String email, BuildContext buildContext) async
{
userModel user ;
final QuerySnapshot result = await userCollection.where('user_email', isEqualTo: email)
.where('user_name' , isEqualTo: name).limit(1).getDocuments(); // searching for a particular user
if(result.documents .length > 0){
final List<DocumentSnapshot> ds = result.documents;
for(int i=0; i< 1; i++ )
{
user = new userModel(ds[i].documentID, ds[i]['user_name'],ds[i]['user_email'],
ds[i]['user_gender'],
ds[i]['user_weight'],ds[i]['user_height'] ,ds[i]['cityPoint'] ,ds[i]['checkLogIn']);
print(user.user_email + ' : ' +user.user_id);
saveToSQFLiteDB(user);
print('Added');
}
nav.HOMEnavigate(buildContext,email);
} // if
else{
String msg = 'Couldnt find user with email \n fill with correct info' ;
nav.showSnackBar(buildContext , msg);
}
}
void saveToSQFLiteDB(userModel user) {
userInApp u = new userInApp(user.user_id, user.user_name, user.user_email, user.user_weight,
user.user_height, user.cityPoint.latitude, user.cityPoint.longitude,user.checkLogIN);
dbHelper.SAVE_USER(u);
}
Future<userInApp> SAVE_USER (userInApp user) async{
var dbClient = await datebase;
//user.user_id =
await dbClient.insert(userTable, user.toMap()).toString();
print('user has been saved');
return user;
}

I found the problem , I have to set db = null before deleting db , When I change deleteDB method to this , I t worked As I want .. Thanks
Future<void> deleteDB() async {
try{
print('deleting db');
db=null;
deleteDatabase(path);
}catch( e){
print(e.toString());
}
print('db is deleted');
}

Related

How to copy portion of char buffer into char[]?

I'm trying to read the process name from /proc/[pid]/stat and that is mostly successful. Yet valgrind complains about something, and the process crashes after some time. My code comes from procps-ng with a few modifications. What I've attempted to do is read the file into a buffer, then find a pointer to the start and end of the process name in that buffer. After that strncpy copies the selected section into the destination buffer and then I add null to the end.
Is this the wrong approach?
The relevant bit of code is here:
rc = file2str(path,"stat", &ub);
if (rc <= 0) return rc;
ub.buf = strchr(ub.buf, '(');
if (!ub.buf) return 0;
ub.buf++;
tmp = strrchr(ub.buf, ')');
if (!tmp || !tmp[1]) return 0;
strncpy(name, ub.buf, (tmp - ub.buf));
name[tmp - ub.buf + 1] = 0;
return (tmp - ub.buf);
The same file2str function is called from another place where it works reliably. I've tried to invoke it in the same way, so I am at a loss for why it fails here.
Valgrind says:
Syscall param read(buf) points to unaddressable byte(s)
at 0x4C4A912: read (read.c:26)
by 0x10D2F9: read (unistd.h:47)
by 0x10D2F9: file2str (procs.c:98)
by 0x10D6B0: stat2name (procs.c:159)
by 0x10DEAA: walk_and_draw (pidgrid.c:313)
by 0x4C55D72: trecurse_r (tsearch.c:739)
by 0x4C55D62: trecurse_r (tsearch.c:736)
by 0x4C55D62: trecurse_r (tsearch.c:736)
by 0x4C55D62: trecurse_r (tsearch.c:736)
by 0x4C55D62: trecurse_r (tsearch.c:736)
by 0x4C55D72: trecurse_r (tsearch.c:739)
by 0x4C55D72: trecurse_r (tsearch.c:739)
by 0x4C56B92: trecurse_r (tsearch.c:736)
by 0x4C56B92: twalk_r (tsearch.c:753)
Full code listing can be found here: https://github.com/robbieh/xscreensaver-pidgrid
edit #1
The var name gets filled. In this case with "Isolated Web Co". That gets written into text which contains "PID: 1737571 UID: 1000 RSS: 83241 VSIZE: 3037233152 STATE: S OOMSCORE: 670 -- Isolated Web Co".
Here's what I get out of GDB:
#0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=140737346060608) at pthread_kill.c:44
#1 __pthread_kill_internal (signo=6, threadid=140737346060608) at pthread_kill.c:80
#2 __GI___pthread_kill (threadid=140737346060608, signo=signo#entry=6) at pthread_kill.c:91
#3 0x00007ffff7b03476 in __GI_raise (sig=sig#entry=6) at ../sysdeps/posix/raise.c:26
#4 0x00007ffff7ae97b7 in __GI_abort () at abort.c:79
#5 0x00007ffff7b4a5e6 in __libc_message (action=action#entry=do_abort, fmt=fmt#entry=0x7ffff7c9c13d "%s\n") at ../sysdeps/posix/libc_fatal.c:155
#6 0x00007ffff7b61adc in malloc_printerr (str=str#entry=0x7ffff7c99e4b "realloc(): invalid old size") at malloc.c:5543
#7 0x00007ffff7b65534 in _int_realloc (av=av#entry=0x7ffff7cd5c60 <main_arena>, oldp=oldp#entry=0x555555cd1680, oldsize=<optimized out>, nb=nb#entry=1040) at malloc.c:4718
#8 0x00007ffff7b66149 in __GI___libc_realloc (oldmem=0x555555cd1690, bytes=1024) at malloc.c:3372
#9 0x00007ffff79c565f in ?? () from /lib/x86_64-linux-gnu/libfreetype.so.6
#10 0x00007ffff79c56be in ?? () from /lib/x86_64-linux-gnu/libfreetype.so.6
#11 0x00007ffff79c585c in ?? () from /lib/x86_64-linux-gnu/libfreetype.so.6
#12 0x00007ffff79d370e in ?? () from /lib/x86_64-linux-gnu/libfreetype.so.6
#13 0x00007ffff79da544 in ?? () from /lib/x86_64-linux-gnu/libfreetype.so.6
#14 0x00007ffff79dff6f in ?? () from /lib/x86_64-linux-gnu/libfreetype.so.6
#15 0x00007ffff79c4c88 in FT_Load_Glyph () from /lib/x86_64-linux-gnu/libfreetype.so.6
#16 0x00007ffff7a1371b in ?? () from /lib/x86_64-linux-gnu/libfreetype.so.6
#17 0x00007ffff79c5161 in FT_Load_Glyph () from /lib/x86_64-linux-gnu/libfreetype.so.6
#18 0x00007ffff7f941aa in XftFontLoadGlyphs () from /lib/x86_64-linux-gnu/libXft.so.2
#19 0x00007ffff7f990f3 in XftGlyphRender () from /lib/x86_64-linux-gnu/libXft.so.2
#20 0x00007ffff7f99333 in XftDrawGlyphs () from /lib/x86_64-linux-gnu/libXft.so.2
#21 0x00007ffff7f9994b in XftDrawStringUtf8 () from /lib/x86_64-linux-gnu/libXft.so.2
#22 0x0000555555559f97 in walk_and_draw (what=<optimized out>, which=<optimized out>, closure=0x555555592040) at pidgrid.c:326
#23 0x00007ffff7bdfd73 in trecurse_r (vroot=0x555555bbb790, action=0x5555555597b0 <walk_and_draw>, closure=0x555555592040) at tsearch.c:739
#24 0x00007ffff7bdfd73 in trecurse_r (vroot=0x555555bb5fb0, action=0x5555555597b0 <walk_and_draw>, closure=0x555555592040) at tsearch.c:739
#25 0x00007ffff7bdfd73 in trecurse_r (vroot=0x555555baaff0, action=0x5555555597b0 <walk_and_draw>, closure=0x555555592040) at tsearch.c:739
#26 0x00007ffff7bdfd63 in trecurse_r (vroot=0x555555bc0f70, action=0x5555555597b0 <walk_and_draw>, closure=0x555555592040) at tsearch.c:736
#27 0x00007ffff7bdfd63 in trecurse_r (vroot=0x555555bece70, action=0x5555555597b0 <walk_and_draw>, closure=0x555555592040) at tsearch.c:736
#28 0x00007ffff7bdfd73 in trecurse_r (vroot=0x555555b95070, action=0x5555555597b0 <walk_and_draw>, closure=0x555555592040) at tsearch.c:739
#29 0x00007ffff7bdfd73 in trecurse_r (vroot=0x555555ae5470, action=0x5555555597b0 <walk_and_draw>, closure=0x555555592040) at tsearch.c:739
#30 0x00007ffff7bdfd73 in trecurse_r (vroot=0x555555a35870, action=0x5555555597b0 <walk_and_draw>, closure=0x555555592040) at tsearch.c:739
#31 0x00007ffff7be0b83 in trecurse_r (closure=0x555555592040, action=0x5555555597b0 <walk_and_draw>, vroot=0x5555555a9b60) at tsearch.c:739
#32 __GI___twalk_r (vroot=0x5555555a9b60, action=0x5555555597b0 <walk_and_draw>, closure=0x555555592040) at tsearch.c:753
#33 0x000055555555a35b in pidgrid_draw (dpy=<optimized out>, window=<optimized out>, closure=0x555555592040) at pidgrid.c:616
#34 0x00005555555586ef in run_screenhack_table (ft=<optimized out>, window2=<optimized out>, window=<optimized out>, dpy=<optimized out>) at screenhack.c:593
#35 main (argc=<optimized out>, argv=<optimized out>) at screenhack.c:996

Segmentation fault occurred when providing incorrect HTTP_PROXY_OPTIONS in azure iot sdk c

I am developing a small application that uses the azure iot sdk in C (lts_07_2021). All my test cases worked well except for one that is related to the proxy. When providing a working/correct proxy server information, my application successfully connected without any problems. But when I provided a non-working proxy information, it produces a segfault. I expected that the SDK will provide some sort of error message but not the segfault.
It can also be reproduced using the example provided by azure in azure-iot-sdk-c/iothub_client/samples/iothub_ll_telemetry_sample
I just added the following options:
HTTP_PROXY_OPTIONS proxy;
memset(&proxy, 0, sizeof(HTTP_PROXY_OPTIONS));
proxy.host_address = "x.x.x.x"; //non-working proxy server
proxy.port = 3128;
(void)IoTHubDeviceClient_LL_SetOption(device_ll_handle, OPTION_HTTP_PROXY,&proxy);
Heres the terminal output when running iothub_ll_telemetry_sample provided by azure + INCORRECT PROXY:
https://github.com/Azure/azure-iot-sdk-c/blob/lts_07_2021/iothub_client/samples/iothub_ll_telemetry_sample/iothub_ll_telemetry_sample.c
[iothub_ll_telemetry_sample]$ ./iothub_ll_telemetry_sample
Creating IoTHub Device handle
Sending message 1 to IoTHub
Error: Time:Tue Feb 8 13:14:51 2022 File:/isolated/azure-iot-sdk-c/c-utility/adapters/socketio_berkeley.c Func:wait_for_connection Line:415 Failure: select failure.
Error: Time:Tue Feb 8 13:14:51 2022 File:/isolated/azure-iot-sdk-c/c-utility/adapters/socketio_berkeley.c Func:socketio_open Line:833 wait_for_connection failed
Error: Time:Tue Feb 8 13:14:51 2022 File:/isolated/azure-iot-sdk-c/c-utility/src/http_proxy_io.c Func:on_underlying_io_open_complete Line:280 Underlying IO open failed
Error: Time:Tue Feb 8 13:14:51 2022 File:/isolated/azure-iot-sdk-c/umqtt/src/mqtt_client.c Func:onOpenComplete Line:454 Error: failure opening connection to endpoint
The device client has been disconnected
Error: Time:Tue Feb 8 13:14:51 2022 File:/isolated/azure-iot-sdk-c/c-utility/adapters/tlsio_openssl.c Func:on_underlying_io_open_complete Line:849 Invalid tlsio_state. Expected state is TLSIO_STATE_OPENING_UNDERLYING_IO.
Error: Time:Tue Feb 8 13:14:51 2022 File:/isolated/azure-iot-sdk-c/c-utility/src/http_proxy_io.c Func:http_proxy_io_open Line:749 Cannot open the underlying IO.
Error: Time:Tue Feb 8 13:14:51 2022 File:/isolated/azure-iot-sdk-c/c-utility/adapters/tlsio_openssl.c Func:tlsio_openssl_open Line:1437 Failed opening the underlying I/O.
Error: Time:Tue Feb 8 13:14:51 2022 File:/isolated/azure-iot-sdk-c/c-utility/src/uws_client.c Func:uws_client_open_async Line:1700 Opening the underlying IO failed
Error: Time:Tue Feb 8 13:14:51 2022 File:/isolated/azure-iot-sdk-c/c-utility/src/wsio.c Func:wsio_open Line:519 Opening the uws instance failed.
Error: Time:Tue Feb 8 13:14:51 2022 File:/isolated/azure-iot-sdk-c/umqtt/src/mqtt_client.c Func:mqtt_client_connect Line:1118 Error: io_open failed
Error: Time:Tue Feb 8 13:14:51 2022 File:/isolated/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:SendMqttConnectMsg Line:2696 failure connecting to address xxxxxxxxxx.azure-devices.net.
Sending message 2 to IoTHub
Segmentation fault (core dumped)
Here's the backtrace:
It seems like the stack frames goes on and on... repeating
#0 0x00000000004383c7 in OptionHandler_Destroy ()
#1 0x00000000004403c1 in http_proxy_io_destroy_option ()
#2 0x0000000000437ea3 in DestroyInternal ()
#3 0x00000000004383cc in OptionHandler_Destroy ()
#4 0x00000000004403c1 in http_proxy_io_destroy_option ()
#5 0x0000000000437ea3 in DestroyInternal ()
#6 0x00000000004383cc in OptionHandler_Destroy ()
#7 0x00000000004403c1 in http_proxy_io_destroy_option ()
#8 0x0000000000437ea3 in DestroyInternal ()
#9 0x00000000004383cc in OptionHandler_Destroy ()
#10 0x00000000004403c1 in http_proxy_io_destroy_option ()
#11 0x0000000000437ea3 in DestroyInternal ()
#12 0x00000000004383cc in OptionHandler_Destroy ()
#13 0x00000000004403c1 in http_proxy_io_destroy_option ()
#14 0x0000000000437ea3 in DestroyInternal ()
#15 0x00000000004383cc in OptionHandler_Destroy ()
#16 0x00000000004403c1 in http_proxy_io_destroy_option ()
#17 0x0000000000437ea3 in DestroyInternal ()
#18 0x00000000004383cc in OptionHandler_Destroy ()
#19 0x00000000004403c1 in http_proxy_io_destroy_option ()
#20 0x0000000000437ea3 in DestroyInternal ()
#21 0x00000000004383cc in OptionHandler_Destroy ()
#22 0x00000000004403c1 in http_proxy_io_destroy_option ()
#23 0x0000000000437ea3 in DestroyInternal ()
#24 0x00000000004383cc in OptionHandler_Destroy ()
#25 0x00000000004403c1 in http_proxy_io_destroy_option ()
#26 0x0000000000437ea3 in DestroyInternal ()
#27 0x00000000004383cc in OptionHandler_Destroy ()
#28 0x00000000004403c1 in http_proxy_io_destroy_option ()
#29 0x0000000000437ea3 in DestroyInternal ()
#30 0x00000000004383cc in OptionHandler_Destroy ()
#31 0x00000000004403c1 in http_proxy_io_destroy_option ()
#32 0x0000000000437ea3 in DestroyInternal ()
#33 0x00000000004383cc in OptionHandler_Destroy ()
#34 0x00000000004403c1 in http_proxy_io_destroy_option ()
#35 0x0000000000437ea3 in DestroyInternal ()
#36 0x00000000004383cc in OptionHandler_Destroy ()
#37 0x00000000004403c1 in http_proxy_io_destroy_option ()
#38 0x0000000000437ea3 in DestroyInternal ()
#39 0x00000000004383cc in OptionHandler_Destroy ()
#40 0x00000000004403c1 in http_proxy_io_destroy_option ()
#41 0x0000000000437ea3 in DestroyInternal ()
#42 0x00000000004383cc in OptionHandler_Destroy ()
#43 0x00000000004403c1 in http_proxy_io_destroy_option ()
#44 0x0000000000437ea3 in DestroyInternal ()
#45 0x00000000004383cc in OptionHandler_Destroy ()
#46 0x00000000004403c1 in http_proxy_io_destroy_option ()
#47 0x0000000000437ea3 in DestroyInternal ()
#48 0x00000000004383cc in OptionHandler_Destroy ()
#49 0x00000000004403c1 in http_proxy_io_destroy_option ()
#50 0x0000000000437ea3 in DestroyInternal ()
#51 0x00000000004383cc in OptionHandler_Destroy ()
#52 0x00000000004403c1 in http_proxy_io_destroy_option ()
#53 0x0000000000437ea3 in DestroyInternal ()
#54 0x00000000004383cc in OptionHandler_Destroy ()
#55 0x00000000004403c1 in http_proxy_io_destroy_option ()
.
.
.
.
.
.#xxxxx repeatedly goes on and on
System information:
CentOS-7
cURL7.29
openssl1.0.2k
This issue was fixed by https://github.com/Azure/azure-c-shared-utility/commit/2d74785c2b475ca94321114a23f8007094bdac11
Updating to the latest lts_01_2022 solved this problem.
Thanks!

How to verify if a transaction is genuine in Stripe?

I am working on Cake PHP Ftramework. My task is to verify if a transaction is genuine. I am trying the following with transaction ID (recieved when payment success).
try {
$stripe = new \Stripe\StripeClient(STRIPE_SECRET_KEY);
$stripe->transfers->retrieve('pi_xxxxxxxxxxxxxxxxxxxxxx', []);
echo "<pre>"; print_r( $stripe ); die;
} catch(\Stripe\Error\Card $e) {
echo "<pre>in catch<br>"; print_r($e->getMessage());
die;
}
And here is what i am gettng in error logs.
Error: [Stripe\Exception\InvalidRequestException] No such transfer: 'pi_xxxxxxxxxxxxxxxxxxxxxxxxxxxx' (E:\Wamp64\www\TrainerSlate\vendor\stripe\stripe-php\lib\Exception\ApiErrorException.php:38)
#0 E:\Wamp64\www\TrainerSlate\vendor\stripe\stripe-php\lib\Exception\InvalidRequestException.php(35): Stripe\Exception\ApiErrorException::factory('No such transfe...', 404, '{\n "error": {\n...', Array, Object(Stripe\Util\CaseInsensitiveArray), 'resource_missin...')
#1 E:\Wamp64\www\TrainerSlate\vendor\stripe\stripe-php\lib\ApiRequestor.php(189): Stripe\Exception\InvalidRequestException::factory('No such transfe...', 404, '{\n "error": {\n...', Array, Object(Stripe\Util\CaseInsensitiveArray), 'resource_missin...', 'transfer')
#2 E:\Wamp64\www\TrainerSlate\vendor\stripe\stripe-php\lib\ApiRequestor.php(151): Stripe\ApiRequestor::_specificAPIError('{\n "error": {\n...', 404, Object(Stripe\Util\CaseInsensitiveArray), Array, Array)
#3 E:\Wamp64\www\TrainerSlate\vendor\stripe\stripe-php\lib\ApiRequestor.php(478): Stripe\ApiRequestor->handleErrorResponse('{\n "error": {\n...', 404, Object(Stripe\Util\CaseInsensitiveArray), Array)
#4 E:\Wamp64\www\TrainerSlate\vendor\stripe\stripe-php\lib\ApiRequestor.php(120): Stripe\ApiRequestor->_interpretResponse('{\n "error": {\n...', 404, Object(Stripe\Util\CaseInsensitiveArray))
#5 E:\Wamp64\www\TrainerSlate\vendor\stripe\stripe-php\lib\BaseStripeClient.php(134): Stripe\ApiRequestor->request('get', '/v1/transfers/p...', Array, Array)
#6 E:\Wamp64\www\TrainerSlate\vendor\stripe\stripe-php\lib\Service\AbstractService.php(59): Stripe\BaseStripeClient->request('get', '/v1/transfers/p...', Array, Object(Stripe\Util\RequestOptions))
#7 E:\Wamp64\www\TrainerSlate\vendor\stripe\stripe-php\lib\Service\TransferService.php(115): Stripe\Service\AbstractService->request('get', '/v1/transfers/p...', Array, NULL)
#8 E:\Wamp64\www\TrainerSlate\src\Controller\ApisController.php(4516): Stripe\Service\TransferService->retrieve('pi_1ILNxXKDtVMA...', Array)
#9 E:\Wamp64\www\TrainerSlate\vendor\cakephp\cakephp\src\Controller\Controller.php(609): App\Controller\ApisController->verifyTransaction()
#10 E:\Wamp64\www\TrainerSlate\vendor\cakephp\cakephp\src\Http\ActionDispatcher.php(120): Cake\Controller\Controller->invokeAction()
#11 E:\Wamp64\www\TrainerSlate\vendor\cakephp\cakephp\src\Http\ActionDispatcher.php(94): Cake\Http\ActionDispatcher->_invoke(Object(App\Controller\ApisController))
#12 E:\Wamp64\www\TrainerSlate\vendor\cakephp\cakephp\src\Http\BaseApplication.php(234): Cake\Http\ActionDispatcher->dispatch(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response))
#13 E:\Wamp64\www\TrainerSlate\vendor\cakephp\cakephp\src\Http\Runner.php(65): Cake\Http\BaseApplication->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response), Object(Cake\Http\Runner))
#14 E:\Wamp64\www\TrainerSlate\vendor\admad\cakephp-social-auth\src\Middleware\SocialAuthMiddleware.php(161): Cake\Http\Runner->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response))
#15 E:\Wamp64\www\TrainerSlate\vendor\cakephp\cakephp\src\Http\Runner.php(65): ADmad\SocialAuth\Middleware\SocialAuthMiddleware->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response), Object(Cake\Http\Runner))
#16 E:\Wamp64\www\TrainerSlate\vendor\cakephp\cakephp\src\Routing\Middleware\RoutingMiddleware.php(162): Cake\Http\Runner->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response))
#17 E:\Wamp64\www\TrainerSlate\vendor\cakephp\cakephp\src\Http\Runner.php(65): Cake\Routing\Middleware\RoutingMiddleware->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response), Object(Cake\Http\Runner))
#18 E:\Wamp64\www\TrainerSlate\vendor\cakephp\cakephp\src\Routing\Middleware\AssetMiddleware.php(88): Cake\Http\Runner->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response))
#19 E:\Wamp64\www\TrainerSlate\vendor\cakephp\cakephp\src\Http\Runner.php(65): Cake\Routing\Middleware\AssetMiddleware->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response), Object(Cake\Http\Runner))
#20 E:\Wamp64\www\TrainerSlate\vendor\cakephp\cakephp\src\Error\Middleware\ErrorHandlerMiddleware.php(96): Cake\Http\Runner->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response))
#21 E:\Wamp64\www\TrainerSlate\vendor\cakephp\cakephp\src\Http\Runner.php(65): Cake\Error\Middleware\ErrorHandlerMiddleware->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response), Object(Cake\Http\Runner))
#22 E:\Wamp64\www\TrainerSlate\vendor\cakephp\cakephp\src\Http\Runner.php(51): Cake\Http\Runner->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response))
#23 E:\Wamp64\www\TrainerSlate\vendor\cakephp\cakephp\src\Http\Server.php(97): Cake\Http\Runner->run(Object(Cake\Http\MiddlewareQueue), Object(Cake\Http\ServerRequest), Object(Cake\Http\Response))
#24 E:\Wamp64\www\TrainerSlate\webroot\index.php(40): Cake\Http\Server->run()
#25 {main}
Request URL: /Apis/verifyTransaction/
In this case to retrieve the PaymentIntent from the API using a pi_xxx PaymentIntent ID, then the PHP code to do this is [1]:
$pi = $stripe->paymentIntents->retrieve(
'pi_xxx',
[]
);
[1] https://stripe.com/docs/api/payment_intents/retrieve?lang=php

How Can I Solve This Problem in my flutter code sqlite

I have a problem in my code that occurs error in lunching in database_helper.dart
database_helper.dart is one file in Sqlite storing data learning project and i faced this issue , i tried many solutions like uninstall app and install it again .
I have edited my question and added the other code called User.dart, I hope you find a solution to this problem, I'm really stuck
class DataBaseHelper {
static Database _db ;
final String userT = 'userT' ;
final String columnId = 'id' ;
final String columnUserName = 'username' ;
final String columnPassword = 'password' ;
final String columnAge = 'age' ;
final String columnCity = 'city' ;
Future<Database> get dbase async {
if(_db != null) {
return _db ;
}
_db = await intDB();
return _db ;
}
intDB() async {
Directory docDirectory = await getApplicationDocumentsDirectory() ;
String path = join(docDirectory.path , 'myDB.db') ;
var myOwnDB = await openDatabase(path , version: 1 , onCreate: _onCreate ) ;
return myOwnDB ;
}
void _onCreate(Database db , int newVersion) async {
var sql = 'CREATE TABLE $userT ($columnId INTEGER PRIMARY KEY ,'
' $columnUserName TEXT , $columnPassword TEXT , $columnCity TEXT , $columnAge INTEGER)' ;
await db.execute(sql) ;
}
Future<int> saveInfo(User user) async {
var dbClient = await dbase ;
int result = await dbClient.insert('$userT', user.toMap()) ;
return result ;
}
Future<List> getInfo() async {
var dbClient = await dbase ;
var sql = 'SELECT * FROM $userT' ;
List result = await dbClient.rawQuery(sql) ;
return result.toList() ;
}
Future<int> getCount() async {
var dbClient = await dbase ;
var sql = 'SELECT COUNT(*) FROM $userT' ;
return Sqflite.firstIntValue( await dbClient.rawQuery(sql) ) ;
}
Future<User> getUser(int id) async {
var dbClient = await dbase ;
var sql = 'SELECT * FROM $userT WHERE $columnId = $id' ;
var result = await dbClient.rawQuery(sql) ;
if(result.length == 0) return null ;
return new User.fromMap(result.first) ;
}
Future<int> deleteUser(int id) async {
var dbClient = await dbase ;
return await dbClient.delete(userT , where: '$columnId = ?' , whereArgs: [id] ) ;
}
Future<int> updateUser(User user) async {
var dbClient = await dbase ;
return await dbClient.update(userT , user.toMap() , where: '$columnId = ?' , whereArgs: [user.id] ) ;
}
Future closeDb() async {
var dbClient = await dbase ;
return await dbClient.close() ;
}
}
and there is the file that called User.dart
class User {
String userName ;
String password ;
String userCity ;
int userAge ;
int id ;
User(this.userName , this.password , this.userCity , this.userAge ) ;
User.map(dynamic obj){
this.userName = obj['username'] ;
this.password = obj['password'] ;
this.userAge = obj['age'] ;
this.userCity = obj['city'] ;
this.id = obj['id'] ;
}
String get _uName => userName ;
String get _pass => password ;
String get _uCity => userCity ;
int get _uAge => userAge ;
int get _uId => id ;
Map<String , dynamic> toMap() {
var map = new Map<String , dynamic>() ;
map['username'] = _uName ;
map['password'] = _pass ;
map['city'] = _uCity ;
map['age'] = _uAge ;
if(id != null){
map['id'] = _uId ;
}
return map ;
}
User.fromMap(Map<String , dynamic>map) {
this.userName = map['username'] ;
this.password = map['password'] ;
this.userAge = map['age'] ;
this.userCity = map['city'] ;
this.id = map['id'] ;
}
}
and this is the error log
E/flutter ( 3969): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: type 'String' is not a subtype of type 'int' of 'index'
E/flutter ( 3969): #0 new User.map (package:was17savesqllite/model/user.dart:14:25)
E/flutter ( 3969): #1 main (package:was17savesqllite/main.dart:16:22)
E/flutter ( 3969): <asynchronous suspension>
E/flutter ( 3969): #2 _runMainZoned.<anonymous closure>.<anonymous closure> (dart:ui/hooks.dart:216:25)
E/flutter ( 3969): #3 _rootRun (dart:async/zone.dart:1124:13)
E/flutter ( 3969): #4 _CustomZone.run (dart:async/zone.dart:1021:19)
E/flutter ( 3969): #5 _runZoned (dart:async/zone.dart:1516:10)
E/flutter ( 3969): #6 runZoned (dart:async/zone.dart:1500:12)
E/flutter ( 3969): #7 _runMainZoned.<anonymous closure> (dart:ui/hooks.dart:208:5)
E/flutter ( 3969): #8 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:301:19)
E/flutter ( 3969): #9 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)
E/flutter ( 3969):
im really stuck here in tutorial , can any one help me plz ?
Looks like data types in your dynamic result does not match User object try casting
//inside
User.fromMap(Map<String , dynamic>map) {
this.userAge = int.parse(map['age'].toString());
this.id = int.parse(map['id'].toString()) ;
}

Random segfaults on a simple C/GTK+ software

I have this function inside the main.c file which create a simple dialog made of check boxes and entries:
void compute_sha2 (GtkWidget *, struct hashWidget_t *);
void compute_sha3 (GtkWidget *, struct hashWidget_t *);
void compute_md5 (struct hashWidget_t *);
void compute_sha1 (struct hashWidget_t *);
void compute_gost94 (struct hashWidget_t *);
void compute_whirlpool (struct hashWidget_t *);
static void
compute_hash ( GtkWidget *fileDialog,
GtkWidget *mainwin,
const gchar *filename)
{
gtk_widget_hide (GTK_WIDGET (fileDialog));
struct hashWidget_t HashWidget;
gsize lenFilename = g_utf8_strlen (filename, -1);
HashWidget.filename = g_malloc (lenFilename + 1);
if (HashWidget.filename == NULL)
{
g_printerr ("Error during memory allocation\n");
return;
}
g_utf8_strncpy (HashWidget.filename, filename, lenFilename);
HashWidget.filename[lenFilename] = '\0';
gint i, result;
const gchar *label[] = {"MD5", "SHA-1", "SHA-256", "SHA3-256", "SHA512", "SHA3-512", "WHIRLPOOL", "GOST94"};
GtkWidget *contentArea, *grid, *dialog;
GtkDialogFlags flags = GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT;
PangoFontDescription *newFont = pango_font_description_new ();
pango_font_description_set_family (newFont, "monospace");
dialog = gtk_dialog_new_with_buttons ("Select Hash",
GTK_WINDOW (mainwin),
flags,
_("Cancel"), GTK_RESPONSE_REJECT,
NULL);
gtk_widget_set_size_request (dialog, 250, 150);
contentArea = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
for (i = 0; i < NUM_OF_HASH; i++)
{
HashWidget.hashCheck[i] = gtk_check_button_new_with_label (label[i]);
HashWidget.hashEntry[i] = gtk_entry_new ();
gtk_editable_set_editable (GTK_EDITABLE (HashWidget.hashEntry[i]), FALSE);
gtk_widget_override_font (GTK_WIDGET (HashWidget.hashEntry[i]), newFont);
}
pango_font_description_free (newFont);
grid = gtk_grid_new ();
gtk_grid_set_row_homogeneous (GTK_GRID (grid), TRUE);
gtk_grid_set_column_homogeneous (GTK_GRID (grid), TRUE);
gtk_grid_set_row_spacing (GTK_GRID (grid), 5);
gtk_grid_attach (GTK_GRID (grid), HashWidget.hashCheck[0], 0, 0, 1, 1);
gtk_grid_attach (GTK_GRID (grid), HashWidget.hashEntry[0], 2, 0, 6, 1);
gtk_grid_attach (GTK_GRID (grid), HashWidget.hashCheck[1], 0, 1, 1, 1);
gtk_grid_attach (GTK_GRID (grid), HashWidget.hashEntry[1], 2, 1, 6, 1);
gtk_grid_attach (GTK_GRID (grid), HashWidget.hashCheck[2], 0, 2, 1, 1);
gtk_grid_attach (GTK_GRID (grid), HashWidget.hashEntry[2], 2, 2, 6, 1);
gtk_grid_attach (GTK_GRID (grid), HashWidget.hashCheck[3], 0, 3, 1, 1);
gtk_grid_attach (GTK_GRID (grid), HashWidget.hashEntry[3], 2, 3, 6, 1);
gtk_grid_attach (GTK_GRID (grid), HashWidget.hashCheck[4], 0, 4, 1, 1);
gtk_grid_attach (GTK_GRID (grid), HashWidget.hashEntry[4], 2, 4, 6, 1);
gtk_grid_attach (GTK_GRID (grid), HashWidget.hashCheck[5], 0, 5, 1, 1);
gtk_grid_attach (GTK_GRID (grid), HashWidget.hashEntry[5], 2, 5, 6, 1);
gtk_grid_attach (GTK_GRID (grid), HashWidget.hashCheck[6], 0, 6, 1, 1);
gtk_grid_attach (GTK_GRID (grid), HashWidget.hashEntry[6], 2, 6, 6, 1);
gtk_grid_attach (GTK_GRID (grid), HashWidget.hashCheck[7], 0, 7, 1, 1);
gtk_grid_attach (GTK_GRID (grid), HashWidget.hashEntry[7], 2, 7, 6, 1);
gtk_container_add (GTK_CONTAINER (contentArea), grid);
gtk_widget_show_all (dialog);
gtk_widget_set_name (GTK_WIDGET (HashWidget.hashCheck[2]), "BtSha256");
gtk_widget_set_name (GTK_WIDGET (HashWidget.hashCheck[3]), "BtSha3_256");
gtk_widget_set_name (GTK_WIDGET (HashWidget.hashCheck[4]), "BtSha512");
gtk_widget_set_name (GTK_WIDGET (HashWidget.hashCheck[5]), "BtSha3_512");
g_signal_connect_swapped (HashWidget.hashCheck[0], "clicked", G_CALLBACK (compute_md5), &HashWidget);
g_signal_connect_swapped (HashWidget.hashCheck[1], "clicked", G_CALLBACK (compute_sha1), &HashWidget);
g_signal_connect (HashWidget.hashCheck[2], "clicked", G_CALLBACK (compute_sha2), &HashWidget);
g_signal_connect (HashWidget.hashCheck[3], "clicked", G_CALLBACK (compute_sha3), &HashWidget);
g_signal_connect (HashWidget.hashCheck[4], "clicked", G_CALLBACK (compute_sha2), &HashWidget);
g_signal_connect (HashWidget.hashCheck[5], "clicked", G_CALLBACK (compute_sha3), &HashWidget);
g_signal_connect_swapped (HashWidget.hashCheck[6], "clicked", G_CALLBACK (compute_whirlpool), &HashWidget);
g_signal_connect_swapped (HashWidget.hashCheck[7], "clicked", G_CALLBACK (compute_gost94), &HashWidget);
result = gtk_dialog_run (GTK_DIALOG (dialog));
switch (result)
{
case GTK_RESPONSE_REJECT:
g_free (HashWidget.filename);
gtk_widget_destroy (dialog);
break;
}
}
The compute_* functions have the same codebase (except for sha2 and sha3 which have a 256/512 switch case):
static goffset get_file_size (const gchar *);
void
compute_sha3 ( GtkWidget *checkBt,
struct hashWidget_t *HashWidget)
{
gint bit;
if (g_strcmp0 (gtk_widget_get_name (checkBt), "BtSha3_256") == 0)
bit = 256;
else if (g_strcmp0 (gtk_widget_get_name (checkBt), "BtSha3_512") == 0)
bit = 512;
if (bit == 256)
{
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (HashWidget->hashCheck[3])))
{
gtk_entry_set_text (GTK_ENTRY (HashWidget->hashEntry[3]), "");
goto fine;
}
else if (g_utf8_strlen (gtk_entry_get_text (GTK_ENTRY (HashWidget->hashEntry[3])), -1) == 64)
goto fine;
}
else
{
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (HashWidget->hashCheck[5])))
{
gtk_entry_set_text (GTK_ENTRY (HashWidget->hashEntry[5]), "");
goto fine;
}
else if (g_utf8_strlen (gtk_entry_get_text (GTK_ENTRY (HashWidget->hashEntry[5])), -1) == 128)
goto fine;
}
guchar *digest;
gchar *hash;
GError *err = NULL;
gint fd, i, retVal;
goffset fileSize, doneSize = 0, diff = 0, offset = 0;
guint8 *fAddr;
struct sha3_256_ctx ctx256;
struct sha3_512_ctx ctx512;
if (bit == 256)
{
digest = g_malloc (SHA3_256_DIGEST_SIZE);
hash = g_malloc (65);
}
else
{
digest = g_malloc (SHA3_512_DIGEST_SIZE);
hash = g_malloc (129);
}
if (digest == NULL)
{
g_printerr ("sha2: error during memory allocation\n");
return;
}
if (hash == NULL)
{
g_printerr ("sha2: error during memory allocation\n");
g_free (digest);
return;
}
fd = g_open (HashWidget->filename, O_RDONLY | O_NOFOLLOW);
if (fd == -1)
{
g_printerr ("sha2: %s\n", g_strerror (errno));
return;
}
fileSize = get_file_size (HashWidget->filename);
if (bit == 256)
sha3_256_init (&ctx256);
else
sha3_512_init (&ctx512);
if (fileSize < BUF_FILE)
{
fAddr = mmap (NULL, fileSize, PROT_READ, MAP_FILE | MAP_SHARED, fd, 0);
if (fAddr == MAP_FAILED)
{
g_printerr ("sha2: %s\n", g_strerror (errno));
g_free (digest);
g_free (hash);
g_close (fd, &err);
return;
}
if (bit == 256)
sha3_256_update (&ctx256, fileSize, fAddr);
else
sha3_512_update (&ctx512, fileSize, fAddr);
retVal = munmap (fAddr, fileSize);
if (retVal == -1)
{
g_printerr ("sha2: %s\n", g_strerror (errno));
g_free (digest);
g_free (hash);
g_close (fd, &err);
return;
}
goto nowhile;
}
while (fileSize > doneSize)
{
fAddr = mmap (NULL, BUF_FILE, PROT_READ, MAP_FILE | MAP_SHARED, fd, offset);
if (fAddr == MAP_FAILED)
{
g_printerr ("sha2: %s\n", g_strerror (errno));
g_free (digest);
g_free (hash);
g_close (fd, &err);
return;
}
if (bit == 256)
sha3_256_update(&ctx256, BUF_FILE, fAddr);
else
sha3_512_update(&ctx512, BUF_FILE, fAddr);
doneSize += BUF_FILE;
diff = fileSize - doneSize;
offset += BUF_FILE;
if (diff < BUF_FILE && diff > 0)
{
fAddr = mmap (NULL, diff, PROT_READ, MAP_FILE | MAP_SHARED, fd, offset);
if (fAddr == MAP_FAILED)
{
g_printerr ("sha2: %s\n", g_strerror (errno));
g_free (digest);
g_free (hash);
g_close (fd, &err);
return;
}
if (bit == 256)
sha3_256_update(&ctx256, diff, fAddr);
else
sha3_512_update(&ctx512, diff, fAddr);
retVal = munmap(fAddr, BUF_FILE);
if(retVal == -1){
g_printerr ("sha2: %s\n", g_strerror (errno));
g_free (digest);
g_free (hash);
g_close (fd, &err);
return;
}
break;
}
retVal = munmap(fAddr, BUF_FILE);
if(retVal == -1)
{
g_printerr ("sha2: %s\n", g_strerror (errno));
g_free (digest);
g_free (hash);
g_close (fd, &err);
return;
}
}
nowhile:
if (bit == 256)
{
sha3_256_digest(&ctx256, SHA3_256_DIGEST_SIZE, digest);
for(i=0; i<32; i++)
g_sprintf (hash+(i*2), "%02x", digest[i]);
hash[64] = '\0';
gtk_entry_set_text (GTK_ENTRY (HashWidget->hashEntry[3]), hash);
}
else
{
sha3_512_digest(&ctx512, SHA3_512_DIGEST_SIZE, digest);
for(i=0; i<64; i++)
g_sprintf (hash+(i*2), "%02x", digest[i]);
hash[128] = '\0';
gtk_entry_set_text (GTK_ENTRY (HashWidget->hashEntry[5]), hash);
}
g_close (fd, &err);
g_free (digest);
g_free (hash);
fine:
return;
}
static goffset
get_file_size (const gchar *filePath)
{
GFileInfo *info;
GFile *file;
GError *error = NULL;
const gchar *attributes = "standard::*";
GFileQueryInfoFlags flags = G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS;
GCancellable *cancellable = NULL;
goffset fileSize;
file = g_file_new_for_path (filePath);
info = g_file_query_info (file, attributes, flags, cancellable, &error);
fileSize = g_file_info_get_size (info);
g_object_unref(file);
return fileSize;
}
The problem is that i'm getting a segfault when i'm trying to compute hashes (below there is the output of 3 segfault):
polcrypt[1678]: segfault at 7f48a40018d8 ip 00007f48e0ae9e8d sp 00007fff2ce02230 error 4 in libgtk-3.so.0.1200.2[7f48e08ac000+51a000]
gmain[1883]: segfault at 7f8814001b38 ip 00007f885f2a7f8b sp 00007f884ab1fc70 error 6 in libglib-2.0.so.0.4000.0[7f885f262000+130000]
polcrypt[1941]: segfault at 7f885c001b18 ip 00007f88868d045f sp 00007fffa35ddc60 error 7 in libglib-2.0.so.0.4000.0[7f888686c000+130000
Sometimes i got the segfault after 1 computation, sometimes after 3 and so on but what i have noticed is that the segfault occurs only when a file bigger than 10M is selected.
I think the problem is inside the main.c file because if i put a g_print at the end of the compute_* functions, the print statement is printed on the screen before getting the segfault.
I'm developing on Gentoo ~x64 and Fedora 20 both with GNOME 3.12, Glib 2.40, GCC 4.8 and libc-2.19
EDIT (core dump):
Reading symbols from polcrypt...(no debugging symbols found)...done.
[New LWP 8848]
[New LWP 8849]
[New LWP 8850]
[New LWP 8853]
warning: Could not load shared library symbols for linux-vdso.so.1.
Do you need "set solib-search-path" or "set sysroot"?
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Core was generated by `./polcrypt'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00007f38888fada7 in g_slice_alloc () from /usr/lib64/libglib-2.0.so.0
and then the full bt:
(gdb) bt full
#0 0x00007f38888fada7 in g_slice_alloc () from /usr/lib64/libglib-2.0.so.0
No symbol table info available.
#1 0x00007f38888b4d35 in g_array_sized_new () from /usr/lib64/libglib-2.0.so.0
No symbol table info available.
#2 0x00007f388a4d181f in gtk_widget_path_new () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#3 0x00007f388a4cdc76 in _gtk_widget_create_path () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#4 0x00007f388a2f2820 in gtk_container_real_get_path_for_child () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#5 0x00007f388a2f7cb7 in gtk_container_get_path_for_child () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#6 0x00007f388a2b265d in gtk_box_get_path_for_child () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#7 0x00007f388a2f7cb7 in gtk_container_get_path_for_child () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#8 0x00007f388a2f2820 in gtk_container_real_get_path_for_child () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#9 0x00007f388a2f7cb7 in gtk_container_get_path_for_child () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#10 0x00007f388a4cdc0d in gtk_widget_get_path () from /usr/lib64/libgtk-3.so.0
---Type <return> to continue, or q <return> to quit---
No symbol table info available.
#11 0x00007f388016d100 in adwaita_engine_render_focus () from /usr/lib64/gtk-3.0/3.0.0/theming-engines/libadwaita.so
No symbol table info available.
#12 0x00007f388a4293e1 in gtk_render_focus () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#13 0x00007f388a2e076c in gtk_check_button_draw () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#14 0x00007f388a392ebe in _gtk_marshal_BOOLEAN__BOXEDv () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#15 0x00007f388a4bd4dd in gtk_widget_draw_marshallerv () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#16 0x00007f3888bda53f in _g_closure_invoke_va () from /usr/lib64/libgobject-2.0.so.0
No symbol table info available.
#17 0x00007f3888bf2f98 in g_signal_emit_valist () from /usr/lib64/libgobject-2.0.so.0
No symbol table info available.
#18 0x00007f3888bf3bfa in g_signal_emit () from /usr/lib64/libgobject-2.0.so.0
No symbol table info available.
#19 0x00007f388a4cad16 in _gtk_widget_draw_internal.part.62 () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#20 0x00007f388a4cc6eb in _gtk_widget_draw () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
---Type <return> to continue, or q <return> to quit---
#21 0x00007f388a2f7abd in gtk_container_propagate_draw () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#22 0x00007f388a2f7b82 in gtk_container_draw () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#23 0x00007f388a3570a2 in gtk_grid_draw () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#24 0x00007f388a392ebe in _gtk_marshal_BOOLEAN__BOXEDv () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#25 0x00007f388a4bd4dd in gtk_widget_draw_marshallerv () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#26 0x00007f3888bda53f in _g_closure_invoke_va () from /usr/lib64/libgobject-2.0.so.0
No symbol table info available.
#27 0x00007f3888bf2f98 in g_signal_emit_valist () from /usr/lib64/libgobject-2.0.so.0
No symbol table info available.
#28 0x00007f3888bf3bfa in g_signal_emit () from /usr/lib64/libgobject-2.0.so.0
No symbol table info available.
#29 0x00007f388a4cad16 in _gtk_widget_draw_internal.part.62 () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#30 0x00007f388a4cc6eb in _gtk_widget_draw () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#31 0x00007f388a2f7abd in gtk_container_propagate_draw () from /usr/lib64/libgtk-3.so.0
---Type <return> to continue, or q <return> to quit---
No symbol table info available.
#32 0x00007f388a2f7b82 in gtk_container_draw () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#33 0x00007f388a2b4882 in gtk_box_draw () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#34 0x00007f388a392ebe in _gtk_marshal_BOOLEAN__BOXEDv () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#35 0x00007f388a4bd4dd in gtk_widget_draw_marshallerv () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#36 0x00007f3888bda53f in _g_closure_invoke_va () from /usr/lib64/libgobject-2.0.so.0
No symbol table info available.
#37 0x00007f3888bf2f98 in g_signal_emit_valist () from /usr/lib64/libgobject-2.0.so.0
No symbol table info available.
#38 0x00007f3888bf3bfa in g_signal_emit () from /usr/lib64/libgobject-2.0.so.0
No symbol table info available.
#39 0x00007f388a4cad16 in _gtk_widget_draw_internal.part.62 () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#40 0x00007f388a4cc6eb in _gtk_widget_draw () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#41 0x00007f388a2f7abd in gtk_container_propagate_draw () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
---Type <return> to continue, or q <return> to quit---
#42 0x00007f388a2f7b82 in gtk_container_draw () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#43 0x00007f388a4dd4a4 in gtk_window_draw () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#44 0x00007f388a392ebe in _gtk_marshal_BOOLEAN__BOXEDv () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#45 0x00007f388a4bd4dd in gtk_widget_draw_marshallerv () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#46 0x00007f3888bda5c7 in _g_closure_invoke_va () from /usr/lib64/libgobject-2.0.so.0
No symbol table info available.
#47 0x00007f3888bf2f98 in g_signal_emit_valist () from /usr/lib64/libgobject-2.0.so.0
No symbol table info available.
#48 0x00007f3888bf3bfa in g_signal_emit () from /usr/lib64/libgobject-2.0.so.0
No symbol table info available.
#49 0x00007f388a4cad16 in _gtk_widget_draw_internal.part.62 () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#50 0x00007f388a4cc35f in _gtk_widget_draw_windows () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#51 0x00007f388a4cc5af in _gtk_widget_draw () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#52 0x00007f388a4cc903 in gtk_widget_send_expose () from /usr/lib64/libgtk-3.so.0
---Type <return> to continue, or q <return> to quit---
No symbol table info available.
#53 0x00007f388a392435 in gtk_main_do_event () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#54 0x00007f3889f8414b in _gdk_window_process_updates_recurse_helper () from /usr/lib64/libgdk-3.so.0
No symbol table info available.
#55 0x00007f3889f82545 in gdk_window_process_updates_internal () from /usr/lib64/libgdk-3.so.0
No symbol table info available.
#56 0x00007f3889f8266f in gdk_window_process_updates_with_mode () from /usr/lib64/libgdk-3.so.0
No symbol table info available.
#57 0x00007f3888bda5c7 in _g_closure_invoke_va () from /usr/lib64/libgobject-2.0.so.0
No symbol table info available.
#58 0x00007f3888bf2f98 in g_signal_emit_valist () from /usr/lib64/libgobject-2.0.so.0
No symbol table info available.
#59 0x00007f3888bf4132 in g_signal_emit_by_name () from /usr/lib64/libgobject-2.0.so.0
No symbol table info available.
#60 0x00007f3889f7c8b0 in gdk_frame_clock_paint_idle () from /usr/lib64/libgdk-3.so.0
No symbol table info available.
#61 0x00007f3889f6ee68 in gdk_threads_dispatch () from /usr/lib64/libgdk-3.so.0
No symbol table info available.
#62 0x00007f38888e0283 in g_timeout_dispatch () from /usr/lib64/libglib-2.0.so.0
No symbol table info available.
---Type <return> to continue, or q <return> to quit---
#63 0x00007f38888df865 in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0
No symbol table info available.
#64 0x00007f38888dfbc8 in g_main_context_iterate.isra () from /usr/lib64/libglib-2.0.so.0
No symbol table info available.
#65 0x00007f38888dfe8a in g_main_loop_run () from /usr/lib64/libglib-2.0.so.0
No symbol table info available.
#66 0x00007f388a31a230 in gtk_dialog_run () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#67 0x000000000040a0be in compute_hash ()
No symbol table info available.
#68 0x000000000040871d in choose_file ()
No symbol table info available.
#69 0x00007f3888bda5c7 in _g_closure_invoke_va () from /usr/lib64/libgobject-2.0.so.0
No symbol table info available.
#70 0x00007f3888bf2f98 in g_signal_emit_valist () from /usr/lib64/libgobject-2.0.so.0
No symbol table info available.
#71 0x00007f3888bf3bfa in g_signal_emit () from /usr/lib64/libgobject-2.0.so.0
No symbol table info available.
#72 0x00007f388a2bfacd in gtk_button_do_release () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#73 0x00007f388a2bfb13 in gtk_real_button_released () from /usr/lib64/libgtk-3.so.0
---Type <return> to continue, or q <return> to quit---
No symbol table info available.
#74 0x00007f3888bda398 in g_closure_invoke () from /usr/lib64/libgobject-2.0.so.0
No symbol table info available.
#75 0x00007f3888beb467 in signal_emit_unlocked_R () from /usr/lib64/libgobject-2.0.so.0
No symbol table info available.
#76 0x00007f3888bf3939 in g_signal_emit_valist () from /usr/lib64/libgobject-2.0.so.0
No symbol table info available.
#77 0x00007f3888bf3bfa in g_signal_emit () from /usr/lib64/libgobject-2.0.so.0
No symbol table info available.
#78 0x00007f388a2bea31 in gtk_button_button_release () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#79 0x00007f388a392ebe in _gtk_marshal_BOOLEAN__BOXEDv () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#80 0x00007f3888bda5c7 in _g_closure_invoke_va () from /usr/lib64/libgobject-2.0.so.0
No symbol table info available.
#81 0x00007f3888bf2f98 in g_signal_emit_valist () from /usr/lib64/libgobject-2.0.so.0
No symbol table info available.
#82 0x00007f3888bf3bfa in g_signal_emit () from /usr/lib64/libgobject-2.0.so.0
No symbol table info available.
#83 0x00007f388a4c0b54 in gtk_widget_event_internal () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
---Type <return> to continue, or q <return> to quit---
#84 0x00007f388a39093c in propagate_event () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#85 0x00007f388a3923b5 in gtk_main_do_event () from /usr/lib64/libgtk-3.so.0
No symbol table info available.
#86 0x00007f3889f9cc72 in gdk_event_source_dispatch () from /usr/lib64/libgdk-3.so.0
No symbol table info available.
#87 0x00007f38888df984 in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0
No symbol table info available.
#88 0x00007f38888dfbc8 in g_main_context_iterate.isra () from /usr/lib64/libglib-2.0.so.0
No symbol table info available.
#89 0x00007f38888dfc6c in g_main_context_iteration () from /usr/lib64/libglib-2.0.so.0
No symbol table info available.
#90 0x00007f3888ebe0ec in g_application_run () from /usr/lib64/libgio-2.0.so.0
No symbol table info available.
#91 0x00000000004082ff in main ()
No symbol table info available.
Problem found!
The munmap function in this snippet must take diff as length arg and not BUF_FILE.
if (diff < BUF_FILE && diff > 0)
{
fAddr = mmap (NULL, diff, PROT_READ, MAP_FILE | MAP_SHARED, fd, offset);
retVal = munmap(fAddr, BUF_FILE); //wrong
retVal = munmap(fAddr, diff); //correct
break;
}

Resources