OpenNTF / org.openntf.domino

Open replacement for lotus.domino package in HCL Domino
Apache License 2.0
66 stars 34 forks source link

Error Handling for "Shared Memory from a previous Notes/Domino run has been detected, this process will exit now" #164

Closed fortezhuo closed 5 years ago

fortezhuo commented 6 years ago

I found issue that cause Domino crashed with message : "Shared Memory from a previous Notes/Domino run has been detected, this process will exit now."

How to reproduce :

Database database = session.getCurrentDatabase(); Form form = database.getForm(null)

I think this problem should be provided better error handling instead throw "Shared Memory error" and cause Domino crashed.

And here openntf log :

2017-12-21T06:13:23 [WARNING]: lotus.domino.local.Database.NgetForm - null NotesException: A required argument has not been provided at lotus.domino.local.Database.NgetForm(Native Method) at lotus.domino.local.Database.getForm(Unknown Source) at org.openntf.domino.impl.Database.getForm(Database.java:1385) at com.forte.servlet.ForteServlet.setAll(ForteServlet.java:111) at com.forte.servlet.GetApprover.doService(GetApprover.java:40) at com.forte.servlet.ForteServlet.service(ForteServlet.java:42)

Environment :

paulswithers commented 6 years ago

In this case, we're just passing onto the core API. There are other places as well - probably more than we're aware of - where passing a null value into the core Domino API can cause a crash. replaceItemValue() is one, where if the itemName is null, it will crash the server. I remember someone hitting that (possibly David Leedy) with SSJS.

We'll discuss the best approach for this. You're welcome to join the ODA channel in the OpenNTF Slack channel (you can join the OpenNTF Slack from a link on the OpenNTF home page).

fortezhuo commented 6 years ago

I have tried to handle null value, but sometimes shared memory error still occurs, and I have no idea what's wrong with my script, and have no error message clue while I try to printStackTrace()

public String getImportedNoteID(Document doc, String key) throws ForteException {
        String noteId = null;
        try {
            Session session = doc.getAncestorSession();
            Database database = doc.getAncestorDatabase();
            DxlImporter dxlImport = session.createDxlImporter();
            View view = database.getView("forteMailTemplate");
            Document docTemplate = view.getFirstDocumentByKey(key);
            if(docTemplate==null) {
                throw new ForteException(422,"No Forte Mail Template found for "+key);          
            } else {
                String output = exportDxl(docTemplate);
                Vector<String> keys = getKeys(output);
                String result = replace(output,doc,keys);
                dxlImport.importDxl(result, database);
                noteId = dxlImport.getFirstImportedNoteID(); // <= this will cause crash    
            }
            return noteId;
        } catch (Exception e) {
            e.printStackTrace();
            noteId = null;
            throw new ForteException(422,e.getMessage());           
        }   
    }