Opened 12 years ago
Last modified 10 years ago
#5339 new Bugs
asio async_read throws boost::asio::error::invalid_argument on mac OS X
Reported by: | Owned by: | chris_kohlhoff | |
---|---|---|---|
Milestone: | To Be Determined | Component: | asio |
Version: | Boost 1.45.0 | Severity: | Problem |
Keywords: | asio invalid_argument mac os x async_read | Cc: | wjwwood@… |
Description
I am trying to write a serial library using Boost's asio, but on mac OS X the async_read throws boost::asio::error::invalid_argument. I have created a custom completion condition to ignore the invalid_argument exceptions, but this causes a busy wait (using a lot of cpu time) yet does not prevent data from being read.
I have attached source code and output from both linux and os x.
Linux: Ubuntu 10.10 i386 - Boost 1.42.0 Mac OS X: 10.6.6 - Boost 1.45.0
Attachments (5)
Change History (14)
by , 12 years ago
Attachment: | serial.cpp added |
---|
by , 12 years ago
by , 12 years ago
Attachment: | test_serial.cpp added |
---|
by , 12 years ago
Attachment: | osx.transcript added |
---|
by , 12 years ago
Attachment: | linux.transcript added |
---|
comment:1 by , 12 years ago
comment:2 by , 12 years ago
Try adding -DBOOST_ASIO_DISABLE_KQUEUE
to your compiler command line to disable kqueue.
Apparently, character devices residing on an HFS partition are incompatible with kqueue. See this forum post for example.
Please consider raising a bug with Apple if this is important to you.
follow-up: 4 comment:3 by , 12 years ago
Thanks this seems to allow expected behavior in OS X. I had two follow up questions though.
- Does disabling kqueue for a select based implementation have many if any drawbacks? (Is this documented somewhere?)
- Would you advise define'ing the BOOST_ASIO_DISABLE_KQUEUE in the compiler arguments or in the source code?
Sorry if these seems like easy questions, I am still a bit new to c++ and boost.
Thanks!
comment:4 by , 12 years ago
Replying to anonymous:
- Does disabling kqueue for a select based implementation have many if any drawbacks? (Is this documented somewhere?)
If you use select then "the number of file descriptors in the process cannot be permitted to exceed FD_SETSIZE". This defaults to 1024 on Mac OS X.
(From http://www.boost.org/doc/libs/1_46_1/doc/html/boost_asio/overview/implementation.html)
- Would you advise define'ing the BOOST_ASIO_DISABLE_KQUEUE in the compiler arguments or in the source code?
You should prefer the compiler command line for these sorts of options. It helps ensure the option is consistent across your whole program.
comment:5 by , 11 years ago
Could you add a note about this to the Mac OS X platform-specific implementation notes? This is the first place I looked when this bit me. I wouldn't have wasted a bunch of time on it if it were already documented.
comment:6 by , 10 years ago
Hello! ggacbad interesting ggacbad site! I'm really like it! Very, very ggacbad good!
comment:7 by , 10 years ago
Hello! cfdeeef interesting cfdeeef site! I'm really like it! Very, very cfdeeef good!
comment:8 by , 10 years ago
Hello! gddfbdd interesting gddfbdd site! I'm really like it! Very, very gddfbdd good!
comment:9 by , 10 years ago
Hello! kbbaeea interesting kbbaeea site! I'm really like it! Very, very kbbaeea good!
Just a bit more info...
The Linux transcript is the expected behavior. The characters are coming into the serial port at 1Hz (Arduino microcontroller) and the timeout is set to 250 milliseconds, so there should be three time outs to every read with data.
The problem seems to allow data to be read on os x, but it prevents serial_port.cancel from working properly and therefore keeping my deadline_timer based timeout from working properly.
The serial.h and serial.cpp should compile with just Boost, but the test_serial.cpp uses ROS (ros.org), but the example is simple enough to reproduce with out quickly.