Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

freopen with NULL filepath fails #2470

Closed
aamcampbell opened this issue Aug 16, 2016 · 5 comments
Closed

freopen with NULL filepath fails #2470

aamcampbell opened this issue Aug 16, 2016 · 5 comments
Labels

Comments

@aamcampbell
Copy link

According to the C standard for freopen() (as stated in POSIX),

"If filename is a null pointer, the freopen() function shall attempt to change the mode of the stream to that specified by mode, as if the name of the file currently associated with the stream had been used."
(http://pubs.opengroup.org/onlinepubs/009695399/functions/freopen.html)

However, when I call freopen(NULL, "mode", pFile) in ARM mbed, it fails and returns NULL. The call fails whether or not the mode is the same as pFile was originally opened with.

@0xc0170
Copy link
Contributor

0xc0170 commented Aug 17, 2016

Can you specify the toolchain + target you use?

@aamcampbell
Copy link
Author

Sorry, I meant to include that in my original report:
yotta (mbed OS 3) with arm GCC on the FRDM-K64F.

@sg-
Copy link
Contributor

sg- commented Aug 25, 2016

Can you provide a test case in the form of a program we can work against?

@aamcampbell
Copy link
Author

aamcampbell commented Aug 26, 2016

Sure! Reproducing it requires a filesystem. Reliance Edge is the only filesystem that I know officially supports mbed OS 3, and it's proprietary; so I figured out how to do it with mbed 5 CLI instead so we can use FAT. The issue appears there as well.

Here are steps to create a test program:

mbed import http://mbed.org/users/neilt6/code/SDFileSystem_HelloWorld/
cd SDFileSystem_HelloWorld/mbed
mbed update
cd ../SDFileSystem/FATFileSystem
mbed update
cd ../../
  • Open SDFileSystem_HelloWorld/main.cpp.
  • Change lines 5-6 to the following:
DigitalIn button(PTC6, PullUp);
SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd");
  • At the top of the file, add:
#include <cassert>
#include <cstdio>
  • After line ~96 (printf("success!\n");), add:
        FILE *f=fopen("/sd/file", "w");
        assert(f != NULL);
        f = freopen(NULL, "w", f);
        assert(f != NULL);
  • Compile: mbed compile -t GCC_ARM -m K64F --options debug-info
  • Insert FAT-formatted SD card to the K64F, start debugging, and press SW2 after a second. If FAT mounts fine, it will crash on the assert() after freopen().

@sg- sg- added the tracking label Sep 19, 2016
@ciarmcom
Copy link
Member

ARM Internal Ref: IOTMORF-487

@ghost ghost closed this as completed Oct 27, 2017
artokin pushed a commit to artokin/mbed-os that referenced this issue Oct 28, 2020
…..d207f4d

d207f4d Merge branch 'release_internal' into release_external
d166c89 MPL: buffered max limit increased to 8k (ARMmbed#2482)
0f6666a Fixed Unit test's
1ff9b1d LLC drop a packet if FHSS shedule is not configured.
7cecc28 Fixed missing asynch trigle setup stop at if down process
7a8b2bf Wi-SUN fhss API default value setting fixes
164a370 Fixed coverity issues from management API
8b5b433 Corrected out of bounds access coverity warning (ARMmbed#2475)
4ffe6a1 Multicast forwarding is separated from the routing flag
30f4315 Wi-SUN discovery staten enter upxdate
083b84e Iotthd 4308 (ARMmbed#2473)
fcc33d5 Removed time increment from NVM time read function on interface up
9c8e3af fhss_tx_handle update
5491a6b Fixed UFSI update print function (ARMmbed#2470)
86f64c5 FHSS WS: Check if BC schedule is stopped before computing timeout delay (ARMmbed#2469)
a0b112a Corrected defects and coding style
2f4678a Corrected trace macro
5e96751 Distributed key storage NVM writes to longer time period
9b3891f FHSS WS: handle blocked interrupts (ARMmbed#2466)
a792e83 Added validation at MAC ack buffer handler
2a465b2 DNS configuration lifetime validation

git-subtree-dir: features/nanostack/sal-stack-nanostack
git-subtree-split: d207f4d
artokin pushed a commit to artokin/mbed-os that referenced this issue Nov 10, 2020
…9d9e24..715ae9a

715ae9a Merge remote-tracking branch 'origin/release_internal' into release_external
42c9807 Nanostak trace level configuration (ARMmbed#2489)
6f52171 Bug fix: socket reference count made 16-bit (ARMmbed#2490)
f51669a Bug fix: Do not print UFSI drift when fixed channel is used (ARMmbed#2488)
18fa048 RPL DAO timeout update:
660e178 Clear debug traces.
cbac0bb DIO init send block for node
fed5d1c Created different MPL configuration based on network size
7ad7e81 Wi-SUN recovery and BR BSI update:
d207f4d Merge branch 'release_internal' into release_external
d166c89 MPL: buffered max limit increased to 8k (ARMmbed#2482)
0f6666a Fixed Unit test's
1ff9b1d LLC drop a packet if FHSS shedule is not configured.
7cecc28 Fixed missing asynch trigle setup stop at if down process
7a8b2bf Wi-SUN fhss API default value setting fixes
164a370 Fixed coverity issues from management API
8b5b433 Corrected out of bounds access coverity warning (ARMmbed#2475)
4ffe6a1 Multicast forwarding is separated from the routing flag
30f4315 Wi-SUN discovery staten enter upxdate
083b84e Iotthd 4308 (ARMmbed#2473)
fcc33d5 Removed time increment from NVM time read function on interface up
9c8e3af fhss_tx_handle update
5491a6b Fixed UFSI update print function (ARMmbed#2470)
86f64c5 FHSS WS: Check if BC schedule is stopped before computing timeout delay (ARMmbed#2469)
a0b112a Corrected defects and coding style
2f4678a Corrected trace macro
5e96751 Distributed key storage NVM writes to longer time period
9b3891f FHSS WS: handle blocked interrupts (ARMmbed#2466)
a792e83 Added validation at MAC ack buffer handler
2a465b2 DNS configuration lifetime validation

git-subtree-dir: connectivity/nanostack/sal-stack-nanostack
git-subtree-split: 715ae9a
artokin pushed a commit to artokin/mbed-os that referenced this issue Nov 10, 2020
…..715ae9a

715ae9a Merge remote-tracking branch 'origin/release_internal' into release_external
42c9807 Nanostak trace level configuration (ARMmbed#2489)
6f52171 Bug fix: socket reference count made 16-bit (ARMmbed#2490)
f51669a Bug fix: Do not print UFSI drift when fixed channel is used (ARMmbed#2488)
18fa048 RPL DAO timeout update:
660e178 Clear debug traces.
cbac0bb DIO init send block for node
fed5d1c Created different MPL configuration based on network size
7ad7e81 Wi-SUN recovery and BR BSI update:
d207f4d Merge branch 'release_internal' into release_external
d166c89 MPL: buffered max limit increased to 8k (ARMmbed#2482)
0f6666a Fixed Unit test's
1ff9b1d LLC drop a packet if FHSS shedule is not configured.
7cecc28 Fixed missing asynch trigle setup stop at if down process
7a8b2bf Wi-SUN fhss API default value setting fixes
164a370 Fixed coverity issues from management API
8b5b433 Corrected out of bounds access coverity warning (ARMmbed#2475)
4ffe6a1 Multicast forwarding is separated from the routing flag
30f4315 Wi-SUN discovery staten enter upxdate
083b84e Iotthd 4308 (ARMmbed#2473)
fcc33d5 Removed time increment from NVM time read function on interface up
9c8e3af fhss_tx_handle update
5491a6b Fixed UFSI update print function (ARMmbed#2470)
86f64c5 FHSS WS: Check if BC schedule is stopped before computing timeout delay (ARMmbed#2469)
a0b112a Corrected defects and coding style
2f4678a Corrected trace macro
5e96751 Distributed key storage NVM writes to longer time period
9b3891f FHSS WS: handle blocked interrupts (ARMmbed#2466)
a792e83 Added validation at MAC ack buffer handler
2a465b2 DNS configuration lifetime validation

git-subtree-dir: features/nanostack/sal-stack-nanostack
git-subtree-split: 715ae9a
artokin pushed a commit to artokin/mbed-os that referenced this issue Nov 18, 2020
…..715ae9a

715ae9a Merge remote-tracking branch 'origin/release_internal' into release_external
42c9807 Nanostak trace level configuration (ARMmbed#2489)
6f52171 Bug fix: socket reference count made 16-bit (ARMmbed#2490)
f51669a Bug fix: Do not print UFSI drift when fixed channel is used (ARMmbed#2488)
18fa048 RPL DAO timeout update:
660e178 Clear debug traces.
cbac0bb DIO init send block for node
fed5d1c Created different MPL configuration based on network size
7ad7e81 Wi-SUN recovery and BR BSI update:
d207f4d Merge branch 'release_internal' into release_external
d166c89 MPL: buffered max limit increased to 8k (ARMmbed#2482)
0f6666a Fixed Unit test's
1ff9b1d LLC drop a packet if FHSS shedule is not configured.
7cecc28 Fixed missing asynch trigle setup stop at if down process
7a8b2bf Wi-SUN fhss API default value setting fixes
164a370 Fixed coverity issues from management API
8b5b433 Corrected out of bounds access coverity warning (ARMmbed#2475)
4ffe6a1 Multicast forwarding is separated from the routing flag
30f4315 Wi-SUN discovery staten enter upxdate
083b84e Iotthd 4308 (ARMmbed#2473)
fcc33d5 Removed time increment from NVM time read function on interface up
9c8e3af fhss_tx_handle update
5491a6b Fixed UFSI update print function (ARMmbed#2470)
86f64c5 FHSS WS: Check if BC schedule is stopped before computing timeout delay (ARMmbed#2469)
a0b112a Corrected defects and coding style
2f4678a Corrected trace macro
5e96751 Distributed key storage NVM writes to longer time period
9b3891f FHSS WS: handle blocked interrupts (ARMmbed#2466)
a792e83 Added validation at MAC ack buffer handler
2a465b2 DNS configuration lifetime validation

git-subtree-dir: features/nanostack/sal-stack-nanostack
git-subtree-split: 715ae9a
artokin pushed a commit to artokin/mbed-os that referenced this issue Jan 19, 2021
…..3183d87

3183d87 Merge branch 'release_internal' into release_external
9e27a77 Disabled BR IID verify from DODAG ID
33ac791 Merge pull request ARMmbed#2548 from PelionIoT/sync_with_mbed_os
6f8b282 compile out trace when not available
825373d Add SPDX license identifier to Arm files
3ec3bc6 fixed warnings: static method defined but not used
ee34352 Check if RX channel needs to be updated when RX slot detected (ARMmbed#2540)
d59dc5d Fix doxygen 1.8.17 warnings (ARMmbed#2546)
1e0beb3 Update unit tests to support Ubuntu 2020_04 LTS (ARMmbed#2545)
b9b2ffd Fixed FHSS get retry period (ARMmbed#2543)
a0bf6ae Check if RX channel needs to be updated after broadcast received (ARMmbed#2539)
fde325e Wi-SUN Neighbour ARO registration failure handling update:
1e1f9c6 RPL dio Handler update:
0421502 Asynch message advertiment enable added to DAO done when disabled.
0374f74 Corrected memory leak on key storage allocation on low memory situation
23c2f7e Disable ASYNCH messages at enter Local repair state.
c1df6b0 Added Poison_count check for First DIO time blocker.
944f934 Added channel mask size to FHSS configuration (ARMmbed#2536)
20e79e0 RPL Local repair disable clear advertised_dodag_membership_since_last_repair state
8a46380 Fix doxygen comments (ARMmbed#2534)
fe06236 MAC ACK RX guarantee update
2388a80 MAC layer send ack allways when it requirement's
29b387b RPL dao dynamic timeout
00bbd02 Don't allow TX slot length go below allowed minimum (ARMmbed#2528)
8333faa Out of memory improvement to remove packets from routing
0a12aeb Support channel plan IDs 1, 2 and 5 with NA and BZ bands (ARMmbed#2526)
ee4333d Wi-SUN Timing configuration is selected based on network size and data rate
a5b2a26 WS: API to set PHY mode and Channel plan IDs as defined by FAN 1.1 (ARMmbed#2520)
b86a044 Update nanostack v12.7.0 changelog (ARMmbed#2525)
35b95da Remove unnecessary files from release
0717432 Merge remote-tracking branch 'origin/release_internal' into release_external
f68126b Adaptation layer MCPS confirmation handle update
e483a07 Added OFDM configurations and FEC in RF config structure (ARMmbed#2513)
b88abfa BUG fix: Fixed broken Brodcast MAC overflow handling
9cad478 Random early detection congestion API update
00aed73 Modified the Wi-SUN stack Latency estimates a bit slower
6b83d82 Remove periodic PAN version increase from Wi-SUN border router
ef670e2 Integrated ReD congestion packet drop to Wi-SUN bootstrap interface.
b956d9e Revert "Improved transmission in high traffic (ARMmbed#2511)" (ARMmbed#2512)
01749c2 Improved transmission in high traffic (ARMmbed#2511)
3158e96 Adaption layer queue trace update
5a32f4a Update changelog, random_early_detection_congestion_check nameupdate and minor comment fix.
b818f12 Extented network status for support dropped tx congestion packet.
11c0763 Added new service Random early detection
f2c358d Optimized medium NWK MPL parameters to 40 second multicast interval (ARMmbed#2508)
c013bc7 Added traces to EAPOL TX failure
c29ee94 Changed TLS return value to int32_t
501a2c8 Added trace for mbed TLS errors
9d7cd22 Updated change log
1290225 Corrected radius message memory allocation
7b1c596 Removed trace print's
efb8393 Adaptation layer MCPS confirmation handle update
ac1025e Bug Fix: Accept only next possible BSI for detect BR reboot and drop unkown's.
58f0e56 Updated change log
102e525 Nanostack now indicates connection down on RPL local repair start
395791d FHSS WS: Do not allow broadcast TX on unicast channel (ARMmbed#2501)
72f8ecb Updated changelog.md
2376208 Activated higher priority by traffic class CS6 for NS/NA and RPL, EAPOL/ DHCP Relay messages.
afbe906 Adaptation layer update
13fb2bf Update CHANGELOG.md
af81c48 DIO init TX filter update
13a872c Fix typos in github template (ARMmbed#2498)
1af20e1 Initial version of CHANGELOG (ARMmbed#2497)
d9874ed Feature update: Improved MAC TX queue purge
6926442 Wi-SUN Aro registration temporary address registation bug fix.
d3170ed Removed generic event and wrong trace info.
0db3486 Removed trace from place which is normal and not needed
a080f18 Added debug tarce for dropped unsecured and MPL packets.
51cd564 Wi-SUN NS probe update:
579f756 Adaptation layer: Do not push CCA failed packet back to MAC (Wi-SUN) (ARMmbed#2487)
715ae9a Merge remote-tracking branch 'origin/release_internal' into release_external
42c9807 Nanostak trace level configuration (ARMmbed#2489)
6f52171 Bug fix: socket reference count made 16-bit (ARMmbed#2490)
f51669a Bug fix: Do not print UFSI drift when fixed channel is used (ARMmbed#2488)
18fa048 RPL DAO timeout update:
660e178 Clear debug traces.
cbac0bb DIO init send block for node
fed5d1c Created different MPL configuration based on network size
7ad7e81 Wi-SUN recovery and BR BSI update:
d207f4d Merge branch 'release_internal' into release_external
d166c89 MPL: buffered max limit increased to 8k (ARMmbed#2482)
0f6666a Fixed Unit test's
1ff9b1d LLC drop a packet if FHSS shedule is not configured.
7cecc28 Fixed missing asynch trigle setup stop at if down process
7a8b2bf Wi-SUN fhss API default value setting fixes
164a370 Fixed coverity issues from management API
8b5b433 Corrected out of bounds access coverity warning (ARMmbed#2475)
4ffe6a1 Multicast forwarding is separated from the routing flag
30f4315 Wi-SUN discovery staten enter upxdate
083b84e Iotthd 4308 (ARMmbed#2473)
fcc33d5 Removed time increment from NVM time read function on interface up
9c8e3af fhss_tx_handle update
5491a6b Fixed UFSI update print function (ARMmbed#2470)
86f64c5 FHSS WS: Check if BC schedule is stopped before computing timeout delay (ARMmbed#2469)
a0b112a Corrected defects and coding style
2f4678a Corrected trace macro
5e96751 Distributed key storage NVM writes to longer time period
9b3891f FHSS WS: handle blocked interrupts (ARMmbed#2466)
a792e83 Added validation at MAC ack buffer handler
2a465b2 DNS configuration lifetime validation

git-subtree-dir: features/nanostack/sal-stack-nanostack
git-subtree-split: 3183d87
artokin pushed a commit to artokin/mbed-os that referenced this issue Jan 21, 2021
…..3183d87

3183d87 Merge branch 'release_internal' into release_external
9e27a77 Disabled BR IID verify from DODAG ID
33ac791 Merge pull request ARMmbed#2548 from PelionIoT/sync_with_mbed_os
6f8b282 compile out trace when not available
825373d Add SPDX license identifier to Arm files
3ec3bc6 fixed warnings: static method defined but not used
ee34352 Check if RX channel needs to be updated when RX slot detected (ARMmbed#2540)
d59dc5d Fix doxygen 1.8.17 warnings (ARMmbed#2546)
1e0beb3 Update unit tests to support Ubuntu 2020_04 LTS (ARMmbed#2545)
b9b2ffd Fixed FHSS get retry period (ARMmbed#2543)
a0bf6ae Check if RX channel needs to be updated after broadcast received (ARMmbed#2539)
fde325e Wi-SUN Neighbour ARO registration failure handling update:
1e1f9c6 RPL dio Handler update:
0421502 Asynch message advertiment enable added to DAO done when disabled.
0374f74 Corrected memory leak on key storage allocation on low memory situation
23c2f7e Disable ASYNCH messages at enter Local repair state.
c1df6b0 Added Poison_count check for First DIO time blocker.
944f934 Added channel mask size to FHSS configuration (ARMmbed#2536)
20e79e0 RPL Local repair disable clear advertised_dodag_membership_since_last_repair state
8a46380 Fix doxygen comments (ARMmbed#2534)
fe06236 MAC ACK RX guarantee update
2388a80 MAC layer send ack allways when it requirement's
29b387b RPL dao dynamic timeout
00bbd02 Don't allow TX slot length go below allowed minimum (ARMmbed#2528)
8333faa Out of memory improvement to remove packets from routing
0a12aeb Support channel plan IDs 1, 2 and 5 with NA and BZ bands (ARMmbed#2526)
ee4333d Wi-SUN Timing configuration is selected based on network size and data rate
a5b2a26 WS: API to set PHY mode and Channel plan IDs as defined by FAN 1.1 (ARMmbed#2520)
b86a044 Update nanostack v12.7.0 changelog (ARMmbed#2525)
35b95da Remove unnecessary files from release
0717432 Merge remote-tracking branch 'origin/release_internal' into release_external
f68126b Adaptation layer MCPS confirmation handle update
e483a07 Added OFDM configurations and FEC in RF config structure (ARMmbed#2513)
b88abfa BUG fix: Fixed broken Brodcast MAC overflow handling
9cad478 Random early detection congestion API update
00aed73 Modified the Wi-SUN stack Latency estimates a bit slower
6b83d82 Remove periodic PAN version increase from Wi-SUN border router
ef670e2 Integrated ReD congestion packet drop to Wi-SUN bootstrap interface.
b956d9e Revert "Improved transmission in high traffic (ARMmbed#2511)" (ARMmbed#2512)
01749c2 Improved transmission in high traffic (ARMmbed#2511)
3158e96 Adaption layer queue trace update
5a32f4a Update changelog, random_early_detection_congestion_check nameupdate and minor comment fix.
b818f12 Extented network status for support dropped tx congestion packet.
11c0763 Added new service Random early detection
f2c358d Optimized medium NWK MPL parameters to 40 second multicast interval (ARMmbed#2508)
c013bc7 Added traces to EAPOL TX failure
c29ee94 Changed TLS return value to int32_t
501a2c8 Added trace for mbed TLS errors
9d7cd22 Updated change log
1290225 Corrected radius message memory allocation
7b1c596 Removed trace print's
efb8393 Adaptation layer MCPS confirmation handle update
ac1025e Bug Fix: Accept only next possible BSI for detect BR reboot and drop unkown's.
58f0e56 Updated change log
102e525 Nanostack now indicates connection down on RPL local repair start
395791d FHSS WS: Do not allow broadcast TX on unicast channel (ARMmbed#2501)
72f8ecb Updated changelog.md
2376208 Activated higher priority by traffic class CS6 for NS/NA and RPL, EAPOL/ DHCP Relay messages.
afbe906 Adaptation layer update
13fb2bf Update CHANGELOG.md
af81c48 DIO init TX filter update
13a872c Fix typos in github template (ARMmbed#2498)
1af20e1 Initial version of CHANGELOG (ARMmbed#2497)
d9874ed Feature update: Improved MAC TX queue purge
6926442 Wi-SUN Aro registration temporary address registation bug fix.
d3170ed Removed generic event and wrong trace info.
0db3486 Removed trace from place which is normal and not needed
a080f18 Added debug tarce for dropped unsecured and MPL packets.
51cd564 Wi-SUN NS probe update:
579f756 Adaptation layer: Do not push CCA failed packet back to MAC (Wi-SUN) (ARMmbed#2487)
715ae9a Merge remote-tracking branch 'origin/release_internal' into release_external
42c9807 Nanostak trace level configuration (ARMmbed#2489)
6f52171 Bug fix: socket reference count made 16-bit (ARMmbed#2490)
f51669a Bug fix: Do not print UFSI drift when fixed channel is used (ARMmbed#2488)
18fa048 RPL DAO timeout update:
660e178 Clear debug traces.
cbac0bb DIO init send block for node
fed5d1c Created different MPL configuration based on network size
7ad7e81 Wi-SUN recovery and BR BSI update:
d207f4d Merge branch 'release_internal' into release_external
d166c89 MPL: buffered max limit increased to 8k (ARMmbed#2482)
0f6666a Fixed Unit test's
1ff9b1d LLC drop a packet if FHSS shedule is not configured.
7cecc28 Fixed missing asynch trigle setup stop at if down process
7a8b2bf Wi-SUN fhss API default value setting fixes
164a370 Fixed coverity issues from management API
8b5b433 Corrected out of bounds access coverity warning (ARMmbed#2475)
4ffe6a1 Multicast forwarding is separated from the routing flag
30f4315 Wi-SUN discovery staten enter upxdate
083b84e Iotthd 4308 (ARMmbed#2473)
fcc33d5 Removed time increment from NVM time read function on interface up
9c8e3af fhss_tx_handle update
5491a6b Fixed UFSI update print function (ARMmbed#2470)
86f64c5 FHSS WS: Check if BC schedule is stopped before computing timeout delay (ARMmbed#2469)
a0b112a Corrected defects and coding style
2f4678a Corrected trace macro
5e96751 Distributed key storage NVM writes to longer time period
9b3891f FHSS WS: handle blocked interrupts (ARMmbed#2466)
a792e83 Added validation at MAC ack buffer handler
2a465b2 DNS configuration lifetime validation

git-subtree-dir: features/nanostack/sal-stack-nanostack
git-subtree-split: 3183d87
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants