msel-source / pymef

Python wrapper for MEF library
Other
5 stars 3 forks source link

Segmentation fault? #11

Closed nelagri closed 5 years ago

nelagri commented 5 years ago

Hello. While using the newest version of Pymef library I encounter a problem. When I am writing a MEF file, approximately 3 out of 10 attempts cause a crash of the program (even though I am using the sample code). Do you have any idea what is the source of this behaviour?

Thank you in advance. Nela

cimbi commented 5 years ago

Hi Nela, we need more details. For starters what OS are you on? The sample code would be really useful too.

nelagri commented 5 years ago

Dear Jan, thank you for the reply. I am running Windows 10 Pro, the sample code is attached.

[writer_example.zip](https://github.com/msel-source/pymef/files/3367296/writer_example.zip)

cimbi commented 5 years ago

Hi Nela, thanks. This seems to be Windows specific. I'll try to replicate/fix this next week

nelagri commented 5 years ago

Hi Jan, thank you very much!

pá 12. 7. 2019 v 14:36 odesílatel Jan Cimbalnik notifications@github.com napsal:

Hi Nela, thanks. This seems to be Windows specific. I'll try to replicate/fix this next week

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/msel-source/pymef/issues/11?email_source=notifications&email_token=ABZUXC5Y4XHJMOLDMOYNT3LP7B3ERA5CNFSM4HXXF5IKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZZUGOI#issuecomment-510870329, or mute the thread https://github.com/notifications/unsubscribe-auth/ABZUXC7F5AQIRXZN6DYSW63P7B3ERANCNFSM4HXXF5IA .

cimbi commented 5 years ago

Hi Nela, I found two problems. 1) You are trying to write an empty list of records. This sometimes leads to segmentation faults. Obviously this should be fixed in pymef. But in the meantime could you just do: if len(record_list): ms.write_mef_records(pwd1, pwd2, start_time, end_time, rec_offset, record_list)

2) You are writing the raw data as int64. This should be also fixed in pymef. But in the meanwhile: ms.write_mef_ts_segment_data(ts_chname, iseg, pwd1, pwd2, samps_per_block, raw_data.astype('int32'))

The fixes will be introduced in the next pymef version.

nelagri commented 5 years ago

Hi Jan, thank you very much! I fixed my code according to your suggestions.

The overall performance is better now, but the program still crushes with error code 0xc0000005 (Access Violation) from time to time. Do you have iany dea what is the cause?

Thank you.

cimbi commented 5 years ago

ok. I haven't tested on windows yet. will do it soon hoepefully

cimbi commented 5 years ago

Hi Nela, I was not able to replicate your error (I am on windows 7 though). Could you download the development version of pymef, build from source and try it? I might have fixed the issue inone of the last commits. Alternatively, wait for the release of the new version. Hopefully tomorrow.

nelagri commented 5 years ago

Hi Jan, thank you. I downloaded the latest version and I still encounter this problem.

cimbi commented 5 years ago

Ok. I will try to get hold of windows 10 machine and replicafe the issue

nelagri commented 5 years ago

Hi Jan, I downloaded the version 1.1.2 and everything is still the same - pymef (more often than often) crashes with exit code -1073741819 (0xC0000005). Should I provide my sample code again? Thank you.

cimbi commented 5 years ago

I think I am able to reproduce the problem. Could you just check form me it is caused by the line ms.write_mef_ts_segment_metadata(ts_chname, iseg, pwd1, pwd2, stime, etime, section2, section3)

Just put print statements before and after the line.

nelagri commented 5 years ago

Hi Jan, yes, I can confirm that it is caused by this line.

cimbi commented 5 years ago

Perfect! Found the bug. Fix will be in next version. Sorry it took so long.