Skip to content

Commit 235b169

Browse files
authored
[Docs] Improve function pointer docs (#26667)
The message mentioned was for asm.js, not wasm. Also mention the clang flag for warnings on casts in another place.
1 parent 6ea9c28 commit 235b169

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

site/source/docs/porting/Debugging.rst

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -329,15 +329,13 @@ unaligned. To do so you can:
329329
Function Pointer Issues
330330
-----------------------
331331

332-
If you get an ``abort()`` from a function pointer call to ``nullFunc`` or ``b0``
333-
or ``b1`` (possibly with an error message saying "incorrect function pointer"),
334-
the problem is that the function pointer was not found in the expected function
335-
pointer table when called.
336-
337-
.. note:: ``nullFunc`` is the function used to populate empty index entries in
338-
the function pointer tables (``b0`` and ``b1`` are shorter names used for
339-
``nullFunc`` in more optimized builds). A function pointer to an invalid
340-
index will call this function, which simply calls ``abort()``.
332+
If you get ::
333+
334+
RuntimeError: null function or function signature mismatch
335+
336+
(or, in certain build types, an ``abort()`` or an error of "incorrect function
337+
pointer"), the problem is that a function of the correct type was not found in
338+
the function pointer table when called.
341339

342340
There are several possible causes:
343341

site/source/docs/porting/guidelines/function_pointer_issues.rst

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,20 @@ There are two main issues with function pointers:
1010
#.
1111
Function pointer casts can cause function pointer calls to fail.
1212

13-
Function pointers must be called with the correct type: it is undefined behavior in C and C++ to cast a function pointer to another type and call it that way. This does work in most native platforms, however, despite it being UB, but in Wasm it can fail. In that case, you may see an ``abort(10)`` or some other number, and if assertions are on you may see a message with details that start with
13+
Function pointers must be called with the correct type: it is undefined behavior in C/C++ to cast a function pointer to another type and call it that way. This does work in most native platforms, however, despite it being UB, but in Wasm it can fail. In that case, you may see an error like this:
14+
15+
::
16+
17+
RuntimeError: null function or function signature mismatch
18+
19+
or
1420

1521
::
1622

1723
Invalid function pointer called
1824

25+
or ``abort(10)`` or some other number (depending on the type of build).
26+
1927
Rarely, you may see a compiler warning like this:
2028

2129
::
@@ -38,6 +46,12 @@ Debugging function pointer issues
3846

3947
The ``SAFE_HEAP`` and ``ASSERTION`` options can catch some of these errors at runtime and provide useful information. You can also see if ``EMULATE_FUNCTION_POINTER_CASTS`` fixes things for you, but see later down about the overhead.
4048

49+
You can get compiler errors for some of these problems with
50+
51+
::
52+
53+
-Werror=cast-function-type
54+
4155
Working around function pointer issues
4256
======================================
4357

0 commit comments

Comments
 (0)