From: Bram R. <bra...@nx...> - 2006-10-30 09:15:35
|
Dear Jan, others, Thanks for the excellent code exerpt that showed the problem. Indeed, you isolated a bug that exists already for years. It is now resolved in the code repository. Here is the description from the Readme.txt.file: - Application segmentation fault on Linux. Following calling sequence failed at the p_read_header() routine: p_create_header(&out_header, P_COLOR_444_PL, P_50HZ); p_write_header("test.yuv", &out_header); p_close_file("test.yuv"); p_read_header("test.yuv", &out_header); More general: the program may crash when accessing a closed file in a different mode than it was previously used. Underlaying cause: when accessing a file in a different mode, it is first closed, then opened in the appropriate mode. This test was incomplete: erreonously, a closed file is closed again, effectively calling fclose(NULL). This is implementation specific; some platforms ignore fclose(NULL). I guess this bug only surfaced now, because: - use of p_open_file() and p_close_file() is rare - use of these functions in different modes is even more rare - the erronous behaviour is platform dependent Anyhow, it is good that this is now resolved. I could not find a workaround in the application. Note that the problem is platform dependent, on HP, I know it will run ok. I order to continue with your application, you can path a cpfspd release as follows. The modification is in the first "if" statement. File cpfspd_low.c Routine p_get_file_pointer() Old code: /* If open file found */ if (idx != -1) { /* Opened as read, write access required? Close it */ /* Opened as write, read access required? Close it */ if ( ((mode != p_mode_read) && (p_files[idx].mode == p_mode_read)) || ((mode == p_mode_read) && (p_files[idx].mode == p_mode_write)) ) { p_close_idx(idx); /* Ignore status - we'll access the same file later */ } } New code: /* If open file found */ if ((idx != -1) && (p_files[idx].fp != NULL)) { /* Opened as read, write access required? Close it */ /* Opened as write, read access required? Close it */ if ( ((mode != p_mode_read) && (p_files[idx].mode == p_mode_read)) || ((mode == p_mode_read) && (p_files[idx].mode == p_mode_write)) ) { p_close_idx(idx); /* Ignore status - we'll access the same file later */ } } Regards, Bram -- Bram Riemens, Principal Scientist Research, Systems and Algorithms NXP Semiconductors Office: WDC 3.41, Postbox WDC-03 <--- New address since Sept. 15, 2006 High Tech Campus 31, 5656 AE Eindhoven, The Netherlands Tel: +31 40 27 43833, Fax: +31 40 27 44639 E-mail: bra...@nx... www.nxp.com The information contained in this message is confidential and may be legally privileged. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, dissemination, or reproduction is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original message. Jan Caussyn Sent by: pfs...@gf... 27-10-2006 17:14 To pfs...@gf... cc Subject [Pfspd-users@philips] pfspd file re-open Classification Hi, Who has a solution to this one ? In a certain case, I want to make a clean start with a certain file, so I close it using p_close_file. However, this causes an unhandled exception in a subsequent p_read_header. An example you find below : This crashes : #include "cpfspd.h" #include <stdlib.h> /* main declaration */ /************************************************************************/ int main(int argc,char *argv[]) { pT_header out_header ; pT_status status ; int xdim, ydim, nframes ; int xcount, ycount, framecount ; status = p_create_header (&out_header, P_COLOR_444_PL, P_50HZ) ; status = p_write_header ("test.yuv", &out_header ); p_close_file ("test.yuv") ; status = p_read_header ("test.yuv", &out_header) ; p_fatal_error_fileio (status, "test.yuv", stderr) ; exit(0) ; } If you put the p_close_file line in comment, it works fine, but that is not what I am looking for. I tried 1.10.1, 1.9.2 and 1.8.2, it's all the same. Any comments appreciated, Regards, Jan __________________________________________________________ Jan Caussyn Philips Innovative Applications NV Brugge Phone : +32 (0)50 455 750 Product Development Fax : +32 (0)50 455 722 Entrance 2 Pathoekeweg 11 B8000 Brugge, Belgium mailto : jan...@ph... _______________________________________________ Pfspd-users mailing list Pfs...@gf... http://ithilien.natlab.research.philips.com/mailman/listinfo/pfspd-users |