Ask Reuben – May 14, 2025

C-extension initialization failed with status -1

What does the error “FORMS statement error number -6221. C-extension initialization failed with status -1” mean?

The error message in the title “FORMS statement error number -6221. C-extension initialization failed with status -1” stumps a lot of developers and results in support calls.  I’d like to think first thing you try is to look up the error in our documentation, for instance -6221.

(A little tip, if you note the URL https://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/r_fgl_errors_001.html#r_fgl_errors_001__error-6221   ends in the error number, I have a bookmark setup pointing to an error and then I launch that bookmark and then change the number at the end to the error number I am looking up).

Now in this case, the documentation for the error message is a little vague …

C extension failed to initialize and returned the status shown in the error message.

Check the C extension source or documentation.

… as a number of things can occur can lead to this error.

More information about the cause of the error might have been written to stderr.  The Progam Stopped Error Message box that was introduced in 3.10 does not display this extra information.    So make sure you are capturing this information rather than have it disappear into the ether. For GAS users, the VM log captures what is written to stdout andstderr.

I would also like to point out, the error is non-trappable.  That means it is not safe for the runtime to continue, hence why your Genero application is stopping at this point.

The other gotcha in this area is that when you look at the line number, it is either the the MAIN statement or it relates to the call of a function in another module.  There isn’t anything wrong with the line of code doing the call, the problem relates to what you can see at the top of the called functions 4gl.  So in something like this …

#! main.4gl
IMPORT FGL foo

MAIN
   MENU ""
      ON ACTION go
         CALL foo.bar()  # error message points to this line
   END MENU
END MAIN

#! foo.4gl
IMPORT com
IMPORT security
IMPORT xml

FUNCTION bar()
   DISPLAY "foo.bar"
END FUNCTION

… whilst the error message line number points to a CALL foo.bar(), the issue lies with the IMPORT module at the top of foo.4gl.

When the runtime makes a call across to a call in another module, the first time it loads that module and that module might have some initialisation that is executed when it is first loaded.  The error can indicate that …

  • an unexpected version of the imported module is being loaded.
  • an error occurs within the initialisation process of that module.

If it is an unexpected version of the imported module, it normally hints at an environment issue.   For example, an older or newer set of crypto or database libraries being found before the expected set

If it is within the initialisation process, it normally hints at an issue with FGLPROFILE settings.  We typically see this with Web Services, the fglprofile setting for Web Services might reference an incorrect value and this error will occur.

With the above example, edit your fglprofile to hhave the following nonsense line added

security.global.ca = "foo.bar"

If you run the program you will get a dialog box that says …

Program stopped at 'filename.4gl' line number 5.
FORM statement error number -6221
C extension initialization failed with status -1

… and if you look in the VM log you will see …

Cannot load the Certificate Authorities file.

With this same example, if you shift the IMPORT lines into the module containing the MAIN, the program won’t even start so you won’t get the Program Stopped Error Message box but you will see lines in the VM log minus a line pointing at a filename and line number.

Like all computer things there is logic, the difficulty is finding the logic!  The logic here lies in the error message, “C-extension initialization failed”.

  • “C-extension” –  could be referring to the likes of IMPORT com, IMPORT security, IMPORT xml, not necessarily your own C-extension.  As one person said, “I am not using a C-extension”, and the answer to that is “you are, it is a C-extension we supply” and you reference with IMPORT.
  • “Initialization Failed” – Initialization includes the finding, loading, and processing that occurs to make it ready to use.