# C Extension rb\_block\_call Weirdness

**URL:** <https://www.ruby-forum.com/t/c-extension-rb-block-call-weirdness/191362>\
**Category:** Ruby\
**Created:** [July 10, 2010, 12:35pm UTC](https://www.ruby-forum.com/t/c-extension-rb-block-call-weirdness/191362 "2010-07-10T12:35:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![asher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/dc4da7/32.png) [@asher](https://www.ruby-forum.com/u/asher)\
**Post date:** [July 10, 2010, 12:35pm UTC](https://www.ruby-forum.com/t/c-extension-rb-block-call-weirdness/191362/1 "2010-07-10T12:35:06Z")

</div>

I’ve already posted a description of my problem at Stackoverflow, but  
realized it might be most appropriate to post here as well, so I will  
summarize and then link.

I am having this problem consistently with 1.9.1-p378 and with 1.9.2rc1.

The short of it is that when I call rb\_block\_call, the called block  
function receives the yield value and data2 appropriately, but argc is  
always set at 1 (no matter what I pass) while argv[0] and argv[2] ==  
yield value, and argv[1] == Qfalse.

More detail and my code can be found here:

> <https://stackoverflow.com/questions/3217624/ruby-1-9-1-p378-c-extension-rb-block-call-weirdness>

Any insight is appreciated, as I am at a point where it is difficult to  
move on until this is worked out.

Asher

---

<div class="post-metadata">

**Author:** ![asher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/dc4da7/32.png) [@asher](https://www.ruby-forum.com/u/asher)\
**Post date:** [July 11, 2010, 1:41pm UTC](https://www.ruby-forum.com/t/c-extension-rb-block-call-weirdness/191362/2 "2010-07-11T13:41:41Z")

</div>

Resolved:

The documentation should read: Calls a method on the recv, with the  
method name specified by the symbol mid, with argc arguments in argv,  
supplying func as the block. When func is called as the block, it will  
receive the value from yield as the first argument, and data2 as the  
second argument.

In other words, argc and argv are for the Ruby iteration method and not  
for the “func” callback function, as the documentation suggests.
